Array of objects is not validated
ursm opened this issue · comments
Keita Urashima commented
When I have the following schema and parameters:
xs:
type: array
items:
type: object
properties:
x:
type: integer
{
"xs": [
{
"y": 42
}
]
}
(Note that the property of the element is y
, not x
.)
I was expecting to get an error when validating this parameter, but it actually passed.
If I make the parameter not an array of objects, I get an error as expected.
{
"xs": 42
}
OpenAPIParser::ValidateError:
#/paths/~1validate_test/post/requestBody/content/application~1json/schema/properties/xs expected array, but received Integer: 42
Is there something I am missing?
ota42y commented
All property is optional by default in OpenAPI 3 specification, so the parameter which doesn't include x is valid.
If the parameter must have x, please set required
field
When there is a parameter other than the specified parameter ( i.e. the parameter must not have y
), please set additionalProperties is false (default true)