-
-
Notifications
You must be signed in to change notification settings - Fork 357
First pass a list of principles. #856
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -455,6 +455,68 @@ | |
|
|
||
| </section> | ||
|
|
||
| <section title="Principles"> | ||
| <t> | ||
| JSON Schema is built on several principles, which both explain various design | ||
| choices, and provide guidance on how to extend the specification effectively. | ||
| </t> | ||
| <!-- Links will be added to relevant spec parts after the sections are reorganized | ||
| to create the new schema loading section --> | ||
| <t> | ||
| <list> | ||
| <t> | ||
| All syntactically legal JSON documents with well-defined behavior are fully | ||
| supported as instance data. Notably, JSON objects with duplicate property | ||
| names are syntactically legal but not well-defined. | ||
| </t> | ||
| <t> | ||
| JSON Schema is defined over a data model, not JSON text. Therefore | ||
| JSON Schema can be used with any data format that can be reliably parsed | ||
| into the data model. | ||
handrews marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </t> | ||
| <t> | ||
| Locations in schemas and instances are always identified by URIs, | ||
| JSON Pointers, or Relative JSON Pointers. JSON Schema treats URIs as | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I only just noticed this now. Are relative json pointers now fair game to be used inside $refs? I think this is the first time that's been mentioned explicitly in the spec. (The metaschema itself just uses 'format: uri-reference' for the $ref syntax, and there are no examples of relative JSON pointers used.) It would be good to clarify this explicitly (probably in a separate patch). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @karenetheridge ignore this PR, it's way outdated. I should really just take it down, I may or may not revisit it, or this info may go on the web site, or something id. |
||
| identifiers only. Locating and retrieving URI-identified resources | ||
| is outside of the scope of this specification. | ||
|
Comment on lines
+480
to
+481
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Locating and retrieving is out of scope, but loading is in scope? This is a fine line and maybe we should define "locating" and "retrieving" vs "loading". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Will add to definitions section. |
||
| </t> | ||
| <t> | ||
| Schema URIs referenced or defined in JSON Schema's Core vocabulary MUST be | ||
| resolvable without instance data. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "resolvable without instance data" mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty much what it literally says- don't overthink it ;-) A URI reference in What this point was trying to establish is that you can safely pre-process a schema so that all of those URI references are converted to full URIs (starting with a scheme) before you're given any instance data. This makes applying the schema to any instance faster and simpler, because you don't have to keep track of base URIs and resolve references when you encounter them. However, this point doesn't quite work in 2019-09: the URI in We could actually change the internal mechanism for this to be simply "replace the entire resolved reference from If we were to lift that restriction and allow any URI reference as a See #868 for more details and hopefully eventually a decision on whether to require static (without instance) resolution for all keywords and a change to |
||
| </t> | ||
| <t> | ||
| Once schema URIs are resolved, the result of applying a schema object | ||
| to instance data is a function of that schema object and its | ||
| dynamic-scope subschemas. Parent schemas have no effect on results. | ||
Relequestual marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </t> | ||
| <t> | ||
| Each keyword's behavior falls into one or more behavioral classifications. | ||
| A keyword's classification MUST be the same for all values of the keyword. | ||
| </t> | ||
| <t> | ||
| Keywords produce a boolean assertion result, and an annotation result that | ||
| can be of any type. Depending on the classification, the assertion result | ||
| might always be true, or the annotation result might always be empty. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotations are keywords and they do not produce any assertion result, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This defines that all keywords produce both, but "annotation" keywords always produce a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gregsdennis that is correct. Might need to also clarify what "empty" annotation results mean. I put this in because in terms of generic extensions, just always returning the same sorts of things makes sense instead of "wait, what kind of keyword was this? does it return this kind of thing? yes? no?" If not otherwise specified, keywords return a This is open to debate, it just made the most sense as I was typing it. (this is exactly why laying out principles is a good idea, though! I don't think we've ever really discussed this) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. Fair. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the document, I can't see this defined explicitly. Are you saying it's implicit with the above wording? If so, could we ALSO make it explicit with requirement keywords? Tests will then have a requirements keyword to point to in the spec then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Relequestual I think we should make it explicit somewhere else. I specifically don't want any requirement keywords in the Principles section: They're principles, not requirements. They should drive the requirements. I will make a separate PR for clarifying the nature of results. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I'm taking the MAY out of one of the other principles and changing it to "can") |
||
| </t> | ||
| <t> | ||
| Keyword results MAY be defined in terms of the results of other keywords | ||
| in the same schema object, as long as no cyclic dependencies are produced. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "in the same schema object or its subschemas"? Maybe explicitly call out that subschema results can be acted on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The results of a keyword include the results of any subschemas. I'd rather keep these things orthogonal. If we need to have a principle about subschema result roll-up we can? Not sure if that's needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's a design principle, more of a consequence of processing. |
||
| </t> | ||
| <t> | ||
| JSON Schema assertions form a constraint system. The empty schema, | ||
| <spanx style="verb">{}</spanx>, allows everything and constrains nothing. | ||
| Each assertion keyword adds constraints; keywords MUST NOT remove constraints. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "MUST NOT remove or alter contraints." Also, I still think that we should mention that this does not conform to inheritance models such as polymorphism. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What sort of "alter" do you have in mind? 99% sure I agree, just want to be clear if something has come up in practice. And yeah, probably worth a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's me drifting off into an inheritance mindset where you can override members. The case I can think of is redefining something like This is fine, but it doesn't do what people thinking about inheritance would think it should do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.... yeah, that's an important point, I'll see if I can come up with concise wording. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trouble is, we DO have keywords which alter the behaviour of other keywords, so I don't think you can say that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be something here about applicators vs assertions. You can use applicators to change which subschema(s) apply to a location in the instance. But adding assertions to a given schema object always further constrains. The only way to effectively lift a constraint is to use applicators to change which schema object is used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't consider this as Maybe "override" would be a better word here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I intentionally didn't say (or at least didn't mean to say) that However, this instance: I'm 99% certain that if we just look at assertions, adding an assertion always reduces the set of valid instances (ignoring complex situations like I think it is always true that adding a pure assertion keyword (that is not also an applicator and/or annotation) to a schema object always reduces the set of valid instances according to that schema object (including its subschemas, because subschemas are never affected by parent schemas once you resolve URI references- that's one of the other principles). Applicators allow much more complex behavior, but it's still just changing how the subschemas results are combined. This is why there is never any override or merge or replacement. The operations are performed on subschema results, never on individual keywords. Aside from information returned in annotation results, subschemas are black boxes; the parent schema has no idea what keywords they contain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could the issue here be it's "assertions and annotations must not remove constraints" but applicator keywords will alter how constraints are applied?
Maybe it's worth noting that while constraints cannot be removed, the application of the schema they belong to may be altered as a side effect of the annotation results of other keywords? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Relequestual yeah what you're saying here is getting very close to it, I think. |
||
| </t> | ||
| <t> | ||
| JSON Schema annotations provide a flexible way to convey information for | ||
| an application to use. The information can be used with instance data, | ||
| or can be used directly from schemas to generate systems for use with | ||
| conforming instances. | ||
| </t> | ||
| </list> | ||
| </t> | ||
| </section> | ||
|
|
||
| <section title="Fragment Identifiers" anchor="fragments"> | ||
| <t> | ||
| In accordance with section 3.1 of <xref target="RFC6839">RFC 6839</xref>, | ||
|
|
||