-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Adding merge
construct
#674
Comments
Parent issue #579 |
@OAI/tdc we can discuss in the next call |
It looks like the first dog/animal example is missing the I think we're misusing terminology here and mixing json schema with the spec structure. Until now, we haven't used any JSON Schema directives outside the Schema object, and now we're 'borrowing' In the JSON Schema scope, I don't see how there can be schemas that are not valid (and that would become valid with a $merge). Of course, there's a tooling issue as well. I think it's a welcome change that will tackle several issues, but will it be widely supported? |
@webron 's point reflects my view that I've tried to express in other issues --- the OAS should be expressed at an abstraction layer above the syntax language in which it is expressed, and not rely too much on tricks/semantics of that encoding. It should not rely on YAML constructs (see OAI/Overlay-Specification#38 Traits or Mixins) or JSON constructs except where natural/necessary. Of course in the past the ability to copy/paste directly from Swagger definitions into JSON schema draft 4 capable tools was important, and will continue to be (does OAS have any Guiding Prinicples?), and hence using the notation the JSON Schema uses (JSON Pointer, JSON Reference) makes sense. I would be very wary of adopting something from draft 5 without fully understanding it (and I've found JSON schema specs particularly hard to grok). Any deviations must be considered with utmost care and probably only adopted if there are simple transformations (and tools) from OAS notation to external standards such as JSON schema. If OAS deviates, it may be better to not use |
not merging, lots to discuss on this still. |
Tackling PR: #741 |
@fehguy @webron An update on We are still working through the details for draft-08, but the most likely approaches to support the use cases in the various issues reference here are:
The data definition / code generation vocabulary should have its first draft either alongside of draft-08 or quickly following it. There are a lot of unknowns still, but there's also a lot of demand and interest which always helps move things along. The advantage of the data definition vocabulary approach is that a schema using its terms is still usable as a standard validation schema. The data definition keywords provide extra information of interest to tools that generate classes, database tables, etc., without interfering with or diverging from validation. |
My openapi-preprocessor tool provides a |
@webron any chance we can close this as won't fix? |
Implementing it as a strict preprocessor as @dolmen notes is a viable approach. What's not viable is the complex double-lazy evaluation needed when you start getting fancy with combinations of To the extent that that would be an official OAS thing, I think it would be folded in under the Overlays concept. |
I'm going to be daring and go ahead and close this for two reasons:
|
Propose that we introduce a construct from JSON Schema draft-5, but not exactly per the draft-5 proposal.
Background
The
allOf
construct requires that all members be proper JSON Schemas. For JSON-Schema draft-5,a
$merge
operator was proposed. The behavioral differences between the two include:$merge
operator allows for subtraction of values$merge
operator has operational order, which allows for a defined behavior when keys clash and have different values$merge
operator is pre-processed, constructing a (valid) schema before validation is actually performedThe JSON schema draft has a different syntax than proposed. Why? It's too verbose, and supports a
source
andwith
syntax (i.e. merge two objects). We need to merge multiple objects, and thesource
,with
is more wordy than we need.Examples
Similar to
allOf
, but with partial schemas:result:
In addition, since we can use
$merge
without full schemas, I propose afragments
section where non-validated schemas can be used.The effective result:
Modeling a common pattern
Effective result:
The text was updated successfully, but these errors were encountered: