Skip to content

enforce existence of composite applicator keyword adjacent to "discriminator" #3137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

karenetheridge
Copy link
Member

"The discriminator object is legal only when using one of the composite keywords oneOf, anyOf, allOf."
https://spec.openapis.org/oas/v3.1.0#discriminator-object

Copy link
Contributor

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish the spec said that discriminator should be ignored if there is no anyOf/oneOf/allOf. That would be more inline with JSON Schema conventions, but that's not what it says, so this change should be included.

Comment on lines 21 to 29
"if": {
"required": [ "discriminator" ]
},
"then": {
"anyOf": [
{ "required": [ "oneOf" ] },
{ "required": [ "anyOf" ] },
{ "required": [ "allOf" ] }
]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest going with dependentSchemas for this. The end result is the same, but it's a little more concise.

Suggested change
"if": {
"required": [ "discriminator" ]
},
"then": {
"anyOf": [
{ "required": [ "oneOf" ] },
{ "required": [ "anyOf" ] },
{ "required": [ "allOf" ] }
]
},
"dependentSchemas": {
"discriminator": {
"anyOf": [
{ "required": [ "oneOf" ] },
{ "required": [ "anyOf" ] },
{ "required": [ "allOf" ] }
]
}
},

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish the spec said that discriminator should be ignored if there is no anyOf/oneOf/allOf. That would be more inline with JSON Schema conventions, but that's not what it says, so this change should be included.

Indeed. This would be worthy of reconsidering for v3.2.

I suggest going with dependentSchemas for this. The end result is the same, but it's a little more concise.

Heh, I considered dependentRequired but totally forgot about dependentSchemas! :p

…minator"

"The discriminator object is legal only when using one of the composite
keywords oneOf, anyOf, allOf."
https://spec.openapis.org/oas/v3.1.0#discriminator-object
@karenetheridge karenetheridge force-pushed the ether/vocabulary-discriminator-allOf branch from bfd2767 to b3a612d Compare January 29, 2023 01:40
@darrelmiller
Copy link
Member

@OAI/tsc Can we get another set of eyes and a merge?

@MikeRalphson
Copy link
Member

@darrelmiller I'll reread up on dependentSchemas tomorrow unless someone else gets there first. I'm sure it's OK.

Copy link
Member

@MikeRalphson MikeRalphson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@MikeRalphson MikeRalphson merged commit a524a4c into OAI:main Mar 5, 2023
@karenetheridge karenetheridge deleted the ether/vocabulary-discriminator-allOf branch March 5, 2023 22:24
skryukov added a commit to skryukov/OpenAPI-Specification that referenced this pull request Oct 17, 2023
earth2marsh added a commit that referenced this pull request Dec 7, 2023
Revert enforce existence of composite applicator keyword adjacent to "discriminator" #3137
karenetheridge added a commit to karenetheridge/OpenAPI-Modern that referenced this pull request Feb 7, 2025
The requirement that oneOf, anyOf or allOf is required was added to the schema
in OAI/OpenAPI-Specification#3137 and then reverted
for v3.1.1 in OAI/OpenAPI-Specification#3405.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants