openapi icon indicating copy to clipboard operation
openapi copied to clipboard

Exception raised on enum query parameters without "type"

Open letmaik opened this issue 4 years ago • 0 comments

JSON Schema does not require "type" to be present for enums, see also https://json-schema.org/understanding-json-schema/reference/generic.html#enumerated-values.

The plugin however requires it for all query parameter schemas: https://github.com/sphinx-contrib/openapi/blob/4f78db9c8ca2cefc4e4c1eeb46552a8d9d432855/sphinxcontrib/openapi/openapi30.py#L279-L282

Sample error:

2021-01-12T14:38:38.9415027Z Exception occurred:
2021-01-12T14:38:38.9416063Z   File "/__w/1/s/env/lib/python3.8/site-packages/sphinxcontrib/openapi/openapi30.py", line 281, in _httpresource
2021-01-12T14:38:38.9416591Z     type=param['schema']['type'],
2021-01-12T14:38:38.9416959Z KeyError: 'type'

Sample parameter:

          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "enum": [
                "PENDING",
                "TRUSTED",
                "RETIRED"
              ]
            }
          }

letmaik avatar Jan 12 '21 17:01 letmaik