-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
$spread for including more properties #374
Comments
VOTE-A-RAMA!!! It's time to gauge community support for all re-use/extension/additionalProperties proposals and actually make some decisions for the next draft. Please use emoji reactions ON THIS COMMENT to indicate your support.
This is not a binding majority-rule vote, but it will be a very significant input into discussions. Here are the meanings for the emojis:
If you want to explain in more detail, feel free to add another comment, but please also vote on this comment. The vote should stay open for several weeks- I'll update this comment with specifics once we see how much feedback we are getting and whether any really obvious patterns emerge. |
I guess this is sort of how I thought $merge would work before reading. This could be a simpliar syntax for $merge. Thoughts @handrews ? |
At the first glance my problem with this is that this keyword gives confusing semantics for So my concern is the unclear way how keywords that affect object properties but they are not inside "properties" work. Thumbs down for this. I will support it in my implementation if this proposal makes into draft-7, but I'm not very happy about it. |
@erosb I consider it a critical feature of any re-use system that re-using a set of properties allows but does not force applying the same requirements. It is very common for me to need an object that is writeable in one context but read-only in others. |
@Relequestual I find this to basically be a simpler alternative to At this point, I think my primary concern is with being able to turn off whatever feature people insist on adding for this. |
Well, I still think that being able to create instances which are valid by the child schema, while invalid by the parent schema will cause confusions (and confusion isn't good, I'm quite sure about that if I implement the spec this way then a number of bugreports will be submitted for me, telling me that the implementation has a bug). The reason why I'm not strongly against this proposal is that is that |
I'm 100% with you on this, hence wanting to be able to turn it off / write re-usable schemas that do not allow splicing into other schemas, by whatever mechanism is chosen. So yes, in terms of its interaction with So... yeah, monkey-patching, not inheritance. And I'm not convinced JSON Schema needs either (for code generation concerns, we have a separate code generation vocabulary under development, so I don't regard that as a use case for validation). |
How would property named "$spread" be possible? Maybe it (or some other keyword) should be one level higher?... |
At the end of the vote-a-rama, I said that I would consolidate these issues to focus the discussion for draft-08. I've filed #515 which outlines the two possible competing approaches. It's pretty abstract, but once we choose an approach, deciding which exact keyword and behavior we want should be less controversial. Therefore I'm closing this in favor of #515. |
This is a proposal from @ruifortes. All words after this intro paragraph are his, copied from json-schema-org/json-schema-org.github.io#77 (comment) Note that this is sort-of a simplified version of #321.
Why not just use something like spread in js?
Instead of creating complicated semantics for the json-schema itself it could be assumed that some basic operations would be possible in simple json like "$ref" is.
"#ref" has nothing to do with the schema itself, just json.
So, why not use a similar approach using "$spread" like the js
obj2 = {...obj1, otherProp, yetAnotherOne}
but declarative.If you have to basic shemas
foo
andbar
you could extend foo like:
eventually $spread position in would be relevant for overriding props.
To create a foobar schema that extends both you could:
The idea would be that json-schema would be a simple schema definition without fancy inheritance semantics and there would be some json (object) declarative manipulations mechanism like $ref and something like $spread could be another one
The text was updated successfully, but these errors were encountered: