-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Extending a schema doesn't allow overrides #22
Comments
As I understand it, "additional", "constrain existing" and "add" are the key words there. Redefining is not specified or supported. Beyond that, it further says:
So in your example, you would require it to be both a string and an integer. |
I see how it would be interpreted that way, but it does seem significantly less useful without being able to do basic overriding... no? |
As @markolson said, the draft-03 specification (and the many discussions that occurred around it) state that extending a schema should be viewed as simply placing additional constraints on an existing schema. While I agree that overriding an attribute has a lot of use, I am aiming for meeting the JSON Schema specification; the language for "extends" is currently the same in draft-04 as is it in draft-03, which is currently being discussed. There has been some movement towards an "inherits" attribute that allows for multiple schema inheritance with a defined schema merge strategy, but that is still in the design stages. |
Understood, thanks for the response. I'll work around it for now. On Jan 17, 2012, at 7:33 AM, Kenny Hoxworth wrote:
|
Look into http://en.wikipedia.org/wiki/Liskov_substitution_principle "Extends" is only for substitutability, not for code reuse. If you want code reuse, build a code generator instead :) As for whether it is "useful" or not - building type coercion into a schema definition is begging for subtle bugs and giant headaches for any software that uses that schema definition. |
http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.26 where it says "A schema that extends another schema MAY define additional attributes, constrain existing attributes, or add other constraints."
Seems like it should allow me to extend a base schema and change the type of a property, for example:
If I attempt to validate a Child, it complains that the "id" property is not a string.
The text was updated successfully, but these errors were encountered: