-
Notifications
You must be signed in to change notification settings - Fork 301
OpenApi Schema references non-existing JSON fields #1080
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
Hence, could you elaborate what you exactly mean with "does not exist"? |
Thank you for getting back so quickly! In the generated schema, an example of such an error would be that one of the components:
schemas:
type: 'REFERENCED VALUE' However, as you can see in the provided example in the original post, the This leads to errors when trying to use the openapi schema anywhere (e.g. swagger as explained in the DJA docs), as the created schema is invalid. |
@n2ygk could you have a look at this? Thanks. |
@sliverc @aseidma hmm, I see them defined in the source code: And when viewing that dict definition they appear to be set: >>> jsonapi_components["schemas"]["type"]
{'type': 'string', 'description': 'The [type](https://jsonapi.org/format/#document-resource-object-identification) member is used to describe resource objects that share common attributes and relationships.'}
>>> jsonapi_components["schemas"]["id"]
{'type': 'string', 'description': 'Each resource object’s type and id pair MUST [identify](https://jsonapi.org/format/#document-resource-object-identification) a single, unique resource.'} However when I do a generateschema of my demo app, I also see that this must have gotten overwritten somewhere. Definitely a bug. |
I'll try tracing this but I have to warn that Tom seems to have abandonded using internal schema generation in DRF and is recommending a different 3rd-party schema generator whose name escapes me at the moment. |
@sliverc @aseidma ugh, I totally forgot that you have to override the generateschema generator class like documented here
We could add a management command that overrides generateschema I suppose, but given the DRF trend away from an internal OAS schema generator, the effort is better put toward switching to using it. |
See #1082 |
@n2ygk Do I understand you correctly, once the generateschema command is run as above, OpenAPI works as expected? If so, I guess we should clarify the docs to make this clearer. As it is written now, it seems that a custom generator class is needed, which is not really the case. |
Description of the Bug Report
When generating an OpenApi schema using
python manage.py generateschema --file schema.yml
, the schema is generated without errors, but references non-existent fields via$ref
, making it unuseable.E.g.:
For reference, this is what
#/components
looks like in the generated file:Checklist
The text was updated successfully, but these errors were encountered: