Skip to content
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

Boolean schemas and the Schema Object in OAS 3.1 #2131

Closed
handrews opened this issue Feb 7, 2020 · 2 comments
Closed

Boolean schemas and the Schema Object in OAS 3.1 #2131

handrews opened this issue Feb 7, 2020 · 2 comments

Comments

@handrews
Copy link
Member

handrews commented Feb 7, 2020

In JSON Schema draft 2019-09, any schema can be either a boolean or an object. The false schema always fails validation, while the true schema always passes. Neither produces any annotations.

This is really valuable to express intent, particularly with false which can otherwise be written an endless number of ways, the most straightforward of which is {"not": {}}. It's easier for people reading the schemas, and in some cases tooling can optimize things a bit when booleans are used.

However, allowing the Schema Object (as opposed to a subschema, or a $ref target) to be a boolean as well as an object seems like it might be an incompatible change in terms of what's allowed for OAS 3.1.

I would have no object to excluding booleans replacing entire top-level Schema Objects, as the use cases for that are pretty strange and can be solved in other ways.

I can write up a PR to clarify this, and also update the proposed Schema Object meta-schema in #2016 to enforce it, if that is something we want to do.

@MikeRalphson
Copy link
Member

MikeRalphson commented Feb 7, 2020

As we're only loosening requirements here, (as we are doing with type now taking a string or array) I don't see that as a problem for a minor release like 3.1.

I think if we're saying 3.1 supports true JSON Schema, but then we add caveats, we're undermining one of the key selling points of 3.1.

I think we can file this under "Doctor, doctor, it hurts when I do this."

@handrews
Copy link
Member Author

handrews commented Feb 7, 2020

@MikeRalphson true, objects are still schemas, it's just that booleans are now also schemas.

@handrews handrews closed this as completed Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants