-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Discriminator: how properly detect valid reference #2520
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
Comments
Any recommendations? |
(Note: I deleted my previous wrong response) I believe is example has a bug. The values of The discriminator in the example should be, discriminator:
propertyName: petType
mapping:
dog: '#/components/schemas/Dog' |
This example is taken from the specification (see the example in the end of discriminator object), i.e. I have not invented it. I understand correctly that you want to say that this is a bug in the documentation description (or bug in example in documentation)? If the construction of the At the moment I'm trying to figure out, should I handle this situation like this, or is it under discussion? |
I didn't think you made it up. I recognized it as the example is from the documentation. Yes, I believe the example from the documentation has a bug. I don't think that OpenAPI has a concept of a base URI, so I don't think you can resolve |
@jdesrosiers thanks for your reply.
Hmm... Maybe i misunderstood the documentation. Pay attention to part of the specification Relative References in URLs. For me, this part is not very clear and requires clarification.
I think what is meant here is about url in the subscheme
Thus, if OpenAPI is served by url http://example.com/openapi/desc, then it is the base url for
Suppose that this OpenAPI description served by url
|
I agree with your conclusion. This is what I missed,
That is very clear. So, I agree that in the previous example, |
This appears to have been fixed in the spec now. https://spec.openapis.org/oas/v3.1.0#discriminator-object has the example:
where the dog mapping properly has the uri reference, rather than just a snippet "Dog". |
No, it wasn't. Last example still use BTW, I've come here, because I've stumbled upon real openapi document which use this notation https://github.com/LandRegistry/digital-street-conveyancer-api/blob/master/src/main/resources/openapi.json#L730-L731 and expect it resolved to |
I was wrong that "schema names" are not allowed in I think the most reasonable thing to do would be to assume it's a schema name if it looks like a schema name and fallback to treating it like a URI if that schema doesn't exist. It would be nice if there was a linting rule to flag the use of schema names in |
PRs merged! closing. |
Suppose we have such OpenAPI document which served by location http://example.com/openapi/desc
it is not clear what mean Dog in the mapping subscheme.
Variants:
If i have subschema in another url (http://example.com/openapi/Dog) thеn Dog is relative link.
If i have subschema in components thеn Dog is #/components/schemas/Dog (which is also a relative link, but different)
How to correctly determine that Dog is a relative link or subschema in #/components/schema?
Sorry for bad english.
The text was updated successfully, but these errors were encountered: