-
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
OAS Dialect does not require the OAS vocabulary #3901
Comments
The So the dialect schema is correct, it's just that the meaning of |
The base dialect does actually "include" that vocabulary: it's at https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/dialect/base.schema.json#L23 (this is where the definitions of |
Thank you both for your responses. However my understanding is that Scenario 1components:
schemas:
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
mapping:
dog: Dog
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Cat`
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog` a plain 2020-12 validator validating against Or am I misunderstanding how |
And actually, even in the case of all/any/oneOf the result might be different, no? Scenario 2MyResponseType:
allOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
discriminator:
propertyName: petType { "petType": "Fish" }
Currently the specification only mandates listing all possible schemas explicitly for Scenario 3MyResponseType:
oneOf:
- $ref: '#/components/schemas/Fish'
- $ref: '#/components/schemas/Dog' # {"properties": { "bark": true }}
discriminator:
propertyName: petType { "petType": "Fish", "bark": "woof" } In |
I looked up the TSC agenda issue for that week but it does not elaborate (we've since gotten better about explaining decisions, but unless it's still possible to dig up old recordings, there's no way to look back at that one- I wasn't around at the time so I don't recall the details). Of course, as with many things in JSON Schema, it's possible to write things that don't work the way you'd want the to.
The correct behavior in this case is the JSON Schema behavior. This has been clarified for the forthcoming 3.1.1 and 3.0.4 releases- see PR #2618 and #3846.
The For validation purposes, if you validate using the I'll re-open while deciding if there's anything more to do to improve the wording. |
Thanks @handrews . I gotta say json-schema and OAS set the standard for community driven projects on decision making and documenting mechanisms. I started digging into the links you shared (and their own links) which might take a minute. But I'm clear now on the expected functionality. My question arises from a new json-schema implementation in Scala that I'm soon completing, and wanted to look into OAS support. Given the nature of my implementation and now understanding that I originally understood |
@jam01 thanks! If you look through that issue I linked to, I think it includes info on the proposed I'm pretty sure that part of the reason why "no impact on validation" was the decision is that implementing schema location and invocation in that |
Ah! I see So for example consider FHIRBundle:
allOf: [{ $ref: '#/hasBundleId' }, ...other bundle reqs ]
properties:
resources:
items:
allOf: [{ required: ['resourceType']}, { $ref: '#/hasBundleChildId' }, ...other bundle child reqs ]
discriminator:
propertyName: resourceType
ResourceA: {}
ResourceB: {} This way we can apply requirements that only apply to children of a Anyways, I'm aware this is unrelated to the OAS Vocab question. Thanks again. EDIT: fixed example a bit |
@jam01 I'm not entirely sure I follow the runtime thing, which is possibly complicated by what seems like two distinct hierarchies (one at the top object level, and the other within I'm going to close this because the PR for the original issue has been merged, but if you want to delve into that more, please feel free to open a discussion for it (because it's an open-ended topic rather than something that will necessarily be addressed by a PR). |
Schema Object#Properties states that
yet the dialect schema does not require that vocab:
https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/dialect/base.schema.json#L16C57-L16C62
The text was updated successfully, but these errors were encountered: