-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
Allow boolean schemas everywhere (root and subschemas) #167
Conversation
Why is this PR so much bigger than #128? All it really needs to do is add |
@awwright LOL you're right, I'll fix it. |
@awwright Actually, that will fix the "bool" part, but not the "$ref" part, which still needs the reorganization of schemas. But I will simplify the bool part with types. |
@awwright if you want to see the meta-schema changes step-by-step take a look at json-schema-org/json-schema-org.github.io#57 |
This is an option for implementing issue json-schema-org#101, this time not just for subschemas but for all schemas including the root schema. The meta-schema changes will be added after PR json-schema-org#168 is approved, at which point the changes for this will be much simpler.
Better wording from @awwright
I prefer #128. I think allowing root schemas to be booleans is a bad idea. |
Why? You may have a schema that starts out with some constraints, but looses them as the API (or whatever) evolves. There is no functional difference here, except for enabling some slight optimizations in implementation. |
One reason is that schema should have id. Another is that root schema is JSON-document while subschema is not. |
A single boolean is a valid JSON document per RFC 7159 (this was a change from the previous RFC, recognizing that in practice, any JSON value is acceptable as a JSON document to most implementations). I think it is important to look at booleans-as-JSON Schema-documents not as a generally recommended practice, but as a consistency feature that is useful in evolving JSON Schema ecosystems. I would not write a standalone boolean schema when designing a new system, but I might end up with one. In particular, being able to declare a schema of |
This implements issue #101, including root schemas.
@awwright requested this form of the solution to compare against PR #128,
which only defines booleans for subschemas. The idea is that it is sometimes
useful to have an entire schema which always passes or always fails, and
the idiom should be the same everywhere.
Note that with RFC 7159,
the restriction that JSON documents could only be arrays or objects
was removed, so a single boolean value is a valid JSON document.
I slightly prefer this to PR #128, myself.
Also add JSON Reference objects as legal schemas in the meta-schema.
Since "$ref" is now only allowed as a JSON Reference where a schema
is acceptable, it can now be described in JSON Schema and included
in the "anyOf" that defines legal subschemas.