-
-
Notifications
You must be signed in to change notification settings - Fork 318
Should "contentSchema" have schema location behavior? #1307
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
Comments
Note that while I definitely have an opinion on this, if there's a clear majority in favor of giving |
I'm not too sure the distinction between this and #1288, they both seem primarily concerned with treating I think it is good to treat As just data, it should become a schema only considered as its own detached document, with the rules that apply to root schemas. This is a bit different than resource subschemas (subschemas with an $id).
|
Some further thoughts on describing this in the metaschema if it is not a thing $ref/$anchor interact with: I mentioned on the other issue that The metaschema could almost use the {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://json-schema.org/draft/2020-12/meta/content",
"$vocabulary": {"https://json-schema.org/draft/2020-12/vocab/content": true},
"$dynamicAnchor": "meta",
"title": "Content vocabulary meta-schema",
"type": ["object", "boolean"],
"properties": {
"contentEncoding": { "type": "string" },
"contentMediaType": { "type": "string" },
- "contentSchema": { "$dynamicRef": "#meta" }
+ "contentSchema": {
+ "contentMediaType": "application/schema+json",
+
+ // encoding is the wrong description but I think the right metaphor; this is how
+ // the content (schema-shaped json data) is within the instance (a schema).
+ "contentEncoding": "json",
+
+ "contentSchema": {
+ "$id": "content/contentSchema",
+ // ref is not dynamic - contentSchema is independent and has new, empty dynamic scope
+ "$ref": "/draft/2020-12/schema",
+ }
+ }
}
} Initially this seemed to me an interesting diversion to think about but one without practical use - a slight stretching of the metaphor, unusable because
If |
@notEthan thanks for replying and copying over that text.
That's not quite correct: It has a different retrieval URI (differing by the fragment), but since using a URI as a base URI disregards the fragment, that means that they end up with the same base URI. Proper resolution relative to that base URI would take the context schema into account, but if the context schema is not accessible (e.g. an API request evaluated an instance, got the annotations, and sent them back without providing access to the context schema), the application would not be able to resolve relative references into the context schema. Because the annotation data (at least as of the next release which will strengthen the annotation output requirements) MUST include the schema location with a JSON Pointer fragment, references within the extracted
Yes, that's what #1306 is about, although it's not that it would be exclusive to I believe that we should accept #1306 as it is important for reasons beyond |
I've been considering this off and on for a while, including the comments from @notEthan . I have come to the reluctant conclusion that it is better to give Using a
The only difference between the At this point, I am convinced by @jdesrosiers 's assertions that treating |
@notEthan you're welcome to object to the PR or continue to raise arguments here, btw. I should have left those comments up for a while before making a PR, but was having a bit of an off day and going on auto-pilot. |
For the purpose of this issue (and consistent with #1306), "schema location behavior" means that a keyword indicates that some part(s) of its value are schemas and MUST be recognized as such by an implementation. Being "recognized" means that an implementation knows to scan it for
$id
,$anchor
, etc. and associates the IRIs they create with the schema, along with the JSON Pointer fragment IRI (it's irrelevant whether any of this is done on load or at runtime).$defs
only has schema location behavior2020-12 classifies
$defs
as a location keyword, but the concept of "location keyword" is somewhat muddled.Schemas located through this behavior can be targeted by
$ref
(or anything else that might reference schemas with an IRI). I think we generally agree that$ref
-ing into applicators is a bad practice, but we don't (currently) forbid it. TBH, I wouldn't mind forbidding it, but I suspect I'm in the minority.contentSchema
is defined as an annotation, and was not intended to have schema location behavior.$ref
-ing intocontentSchema
is definitely at least as bad a practice as$ref
-ing into an inline applicator.My preference would be to forbid it by saying that
contentSchema
lacks this behavior. Framing it in terms of schema location behavior would make this part of the JSON Schema system rather than a weird exception.As noted in #1288, @jdesrosiers would prefer that
contentSchema
have schema location behavior.I'd like to get more opinions on this point, which doesn't change the outcome of #1288. So it's not necessary to read through all of that issue.
An alternative would be to change
contentSchema
from taking a schema to taking a string containing a schema. Which I almost did when I added it to ensure it was treated as data. If anyone likes this idea please speak up, but I am not expecting it to be popular.The text was updated successfully, but these errors were encountered: