-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Add "$recurse" for extending recursive schemas #589
Conversation
This allows deleting most of the hyper-schema meta-schema.
jsonschema-core.xml
Outdated
<t> | ||
The presence of this keyword with a boolean true value indicates that, | ||
during processing, it MUST be treated as a reference to the schema document | ||
where processing was initiated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it MUST be treated as a reference to the schema document where processing was initiated.
vs
Note that even if processing began at a subschema within a document, the "$recurse" target MUST be the root of the document.
The first seems like its saying if we ref into a document at some lower level, it should recurse to THAT level, but the 2nd says it must be the root? Confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the key here is the wording "schema document" which is defined in section 4.3 in both draft-07 and the current HEAD commit. A schema document is a document, not a JSON object. So saying that it MUST be treated as a reference to the schema document where processing was initiated means exactly what the clarification says.
But I'm open to suggestion on how to word it better, preferably without entirely re-stating 4.3. Maybe just an <xref />
to it? I suspect the complete list of people who understand the distinction without having to look it consists of is @awwright and me.
jsonschema-core.xml
Outdated
} | ||
|
||
{ | ||
"$schema": " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
er... yeah, thanks!
Feedback from PR review.
8e5412b
to
f302ed1
Compare
This commit *only* includes formatting changes: * New overall section title * New section title for the now sub-section on "$ref" * "$ref" subsection indented and wrapped to 100 characters * "$recurse" section moved to right after "$ref" sub-section * "$recurse subsection indented and wrapped to 100 characters * Other reference subsections wrapped to 100 characters as needed The next commit will update the actual text.
Add an intro paragraph about reference keywords and their nature as indirect in-place applicators. "$ref" is no longer really targeted at recursive schemas, so tweak its wording slightly. Do a few further improvements to "$recurse" wording, particularly around root schemas and schema documents. Correct an apparent typo about a schema "against a schema", this is almost certainly supposed to be "against an instance", as the rest of the paragraph talks in terms of instance validation.
So remove the advice about that part.
How would I refer to extended schemas from schemas of my own? For example, suppose I have a media type that tries to represent HTML forms. It's an array of objects, each describing a form field. One of the properties is a schema that can describe a schema, and I want to {
type: "array",
items: {
type: "object",
properties: {
"name": { type: "string" },
"schema": { $ref: "http://json-schema.org/draft-nnn/hyper-schema" }
}
}
} where What happens when a JSON Schema validator hits |
@awwright that is an excellent question, and definitely a problem for this proposal as it stands. Embedding the meta-schema is a different use case than "extending" a schema (I hate to use the word "extending" as it makes people think of OOP, but JSON Schema is a constraint system which is very different- not sure what else to call it, though). But there is no way in this proposal to distinguish the two, so your example would break. And in a non-obvious way. The simplest fix would be to add something alongside the The thing I want to preserve about |
I'm going to move this discussion back to the issue and make some revised proposals there. |
Closing per #558 (comment) due to the problems noted by @awwright. I hope to revisit this, but as noted in the issue, it will be a while and we can get by without it if we must. |
Addresses #558.
The 3rd and 2nd to last two commits rework
$ref
and$recurse
as adjacent subsections in the "Schema Referencing" section, as most of their behavior is identical (particularly once #585 is complete).The third-to-last commit just moves things around with no content changes other than obvious section titles, while the second-to-last commit updates the text, including minor updates to
$ref
's subsection.