1. Surely when extending an existing schema, one could override a required property to be not required in its new context? So I'm not sure why in your example you say you needed to define the optional one first.
2. With regard to your point about order, I don't think $ref should necessarily be only for backward references. Many hypertext documents allow forward URI references using fragment identifiers. A popular example is HTML with anchors containing fragment identifiers to anchored links defined later in the document. Should json-schema documents be different, and if so, why?
1. Surely when extending an existing schema, one could override a required property to be not required in its new context? So I'm not sure why in your example you say you needed to define the optional one first.
This is not correct according to the draft 3 definition of 'extends', http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.26. The extending schema does not overwrite attributes or restrictions, it simply adds to them. You can therefore run into situations where a schema can never be valid, such as in your example where the 'requred' attribute it set to 'true' in the extended schema and 'false' in the extending schema.
2. With regard to your point about order, I don't think $ref should necessarily be only for backward references. Many hypertext documents allow forward URI references using fragment identifiers. A popular example is HTML with anchors containing fragment identifiers to anchored links defined later in the document. Should json-schema documents be different, and if so, why?
The JSON schema spec does not formally specify whether forward references should be allowed, and thus the behavior is undefined. Because of this, some existing validators allow forward-reference and others do not.
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To post to this group, send email to json-...@googlegroups.com.
To unsubscribe from this group, send email to json-schema...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-schema?hl=en.
I agree completely; i support the issue of forward-referencing being
explicitly defined in the next draft.
To sum my understanding of the proposal: make the "requiredness" of object properties an attribute* of the containing object rather than as an attribute of the defined properties themselves.
Some points I'd like to raise with it:
1. Surely when extending an existing schema, one could override a required property to be not required in its new context? So I'm not sure why in your example you say you needed to define the optional one first.
2. With regard to your point about order, I don't think $ref should necessarily be only for backward references. Many hypertext documents allow forward URI references using fragment identifiers. A popular example is HTML with anchors containing fragment identifiers to anchored links defined later in the document. Should json-schema documents be different, and if so, why?
A better suggestion may be to deprecate "requires" and allow
"dependencies" to accept boolean values; where if a property in
"dependencies" is true, then that property of the instance object must
exist. Example:
{
"type" : "object",
"properties" : {
"a" : { "type" : "string" },
"b" : { "type" : "number" }
},
"dependencies" : {
"a" : true
}
}
-Gary