parameter with type=array style=form and explode=true marked as invalid
spaceone opened this issue · comments
Florian Best commented
https://swagger.io/docs/specification/serialization/#query and https://swagger.io/docs/specification/describing-parameters/#query-parameters say that query parameters may be type=array
with style=form
and explode=true
.
However, trying to validate such a parameter gives me a invalid
result:
$ python3 -m openapi_spec_validator openapi2.json
{'description': 'description', 'in': 'query', 'name': 'properties', 'schema': {'minItems': 1, 'maxItems': 5, 'explode': True, 'style': 'form', 'items': {'example': '*', 'type': 'string', 'minLength': 1, 'maxLength': 5, 'pattern': '.*'}, 'type': 'array'}} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['parameters']['items']:
{'oneOf': [{'$ref': '#/definitions/Parameter'},
{'$ref': '#/definitions/Reference'}]}
On instance['paths']['/foo']['get']['parameters'][0]:
{'$ref': '#/components/parameters/search.properties',
'x-scope': ['file:///…/openapi2.json']}
{
"components": {
"callbacks": {},
"examples": {},
"headers": {},
"links": {},
"parameters": {
"search.properties": {
"description": "description",
"in": "query",
"name": "properties",
"schema": {
"minItems": 1,
"maxItems": 5,
"explode": true,
"style": "form",
"items": {
"example": "*",
"type": "string",
"minLength": 1,
"maxLength": 5,
"pattern": ".*"
},
"type": "array"
}
}
},
"requestBodies": {},
"responses": {},
"schemas": {},
"securitySchemes": {}
},
"info": {
"description": "description",
"title": "",
"version": "1.0.0"
},
"openapi": "3.0.3",
"paths": {
"/foo": {
"get": {
"description": "description",
"operationId": "foo",
"parameters": [
{
"$ref": "#/components/parameters/search.properties"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"description": "description",
"type": "string"
}
}
},
"description": "description"
}
},
"summary": "summary",
"tags": [
"foo"
]
}
}
},
"security": [
],
"servers": [
{
"url": "https://localhost"
}
],
"tags": [
{
"description": "description",
"name": "foo"
}
]
}
when removing:
"explode": true,
"style": "form",
it is valid again.
Florian Best commented
ah, nvm.
Moving
"explode": true,
"style": "form",
upwards to the actual property instead of the schema fixes it.