-
Notifications
You must be signed in to change notification settings - Fork 35
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
How to force using JSONSchema decorator from parent? #39
Comments
I know there's this section in the docs:
However I'm a bit lost regarding how to actually use this, if you can help at all. Would be great to have a code example of this functionality in the docs as well. |
The example you posted doesn't contain any inheritance so the problem probably lies somewhere else. Can you post the exact JSON Schema you're getting in your use case? My guess is that in your example case we end up with a {
"properties": {
"name": {
"$ref": "<ref to LocalizedString schema>",
"description": "The name of the product and its translations."
}
}
} And since earlier JSON Schema drafts ignore all other than OpenAPI's reference objects likewise If that's the case, the solution is to either try some of the creative workarounds mentioned here https://stackoverflow.com/questions/33565090/json-schema-property-description-and-ref-usage or to introduce some sort of complex duplication logic into the library. Or we could wait for OpenAPI v3.1.0 which will finally support the latest JSON Schema draft in its entirety 🙂 |
From the docs:
This makes sense in theory, but in reality the fact that the parent class decorator doesn't take precedence is a bit backwards, I feel.
For example, I have this kind of class representing an object of localized strings:
This field is used in many of my other classes, for example for the name of a product:
With this kind of setup, the resulting JSON schema has the
name
field of the product described with the generic title and description fromLocalizedString
instead of the one I define inProduct
. I think it should work in exactly the opposite preference, as the case where I'm using it within a Product object is the more specific case, if you see what I mean.One solution would be to just remove the JSONSchema decorator from
LocalizedString
entirely, but I would still like to have at as I have a generic Model reference in my docs where it would be useful.Question is:
The text was updated successfully, but these errors were encountered: