-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Full definitons of swagger responses are possibly being replaced with brief definitions due to nested serializers #16670
Comments
As a side note, most likely caused by this change #15281 by @jeremystretch as im assuming that the generated model response is simply being replaced with nested definition of the same name. |
As "workaround" deleting if self.nested and not fields:
self._requested_fields = getattr(self.Meta, 'brief_fields', None) in serializers/base.py allows at least somewhat coherent swagger output but downside is that it also misrepresents the original nested field values that were correct with the brief representations |
What's happening is the nested=True serializer is getting instantiated first and it looks like Spectacular is caching the fields from this call and using that. So it is hit or miss depending if the full serializer or the nested serializer is getting hit first. I was able to see this in #16765 as nested=True serializer is getting instantiated first in CircuitSerializer for ProviderAccount - if you comment out the nested serializer in CircuitSerializer then ProviderAccount will show correctly in the API browser. Wondering if we need to do a proxy class on the serializers to bring back NestedSerializers and just have them set the fields. |
Deployment Type
Self-hosted
NetBox Version
v4.0.3
Python Version
3.11
Steps to Reproduce
Check swagger JSON, all model representations of responses are only using
brief
definitions.Expected Behavior
Swagger responses should
always
match real responses.Observed Behavior
Brief representations are being returned, making it effectivelly impossible to use the swagger json.
The text was updated successfully, but these errors were encountered: