missing-required-property rule failed at anyOf required options
Closed this issue · 1 comments
dziaineka commented
Hi!
I have JSON schema
{
"$schema": "http://json-schema.org/draft-06/schema#",
"title": "Test object",
"type": "object",
"properties": {
"option1": {
"type": "string"
},
"option2": {
"type": "string"
}
},
"oneOf": [
{
"required": ["option1"]
},
{
"required": ["option2"]
}
],
"additionalProperties": false
}
linked by ref to YAML openapi 3.1 spec.
Running validator
docker run --volume "${PWD}:/data" jamescooke/openapi-validator lint-openapi docs/openapi/openapi.yaml
ends with errors:
errors
Message : Required property, option1, not in the schema
Rule : missing-required-property
Path : paths./v4/{broker}/notifications/{id}.get.responses.200.content.application/json.schema
Line : 91
Message : Required property, option2, not in the schema
Rule : missing-required-property
Path : paths./v4/{broker}/notifications/{id}.get.responses.200.content.application/json.schema
Line : 91
without oneOf block everything is fine.
Thank you!
dpopp07 commented
These are valid errors. Each entry in the oneOf
array is an individual JSON schema. You are saying the schemas have required properties but you aren't defining any properties on either schema. Those schemas don't inherit the properties you already defined.