You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem, of course, is that this is NOT actually a hard-coded list of choices, it's determined at schema generation time from whatever set of Status objects happen to be defined. The moment a user adds, deletes, or edits any Status record, this part of the schema becomes inaccurate.
Most likely, the best solution here (albeit probably a breaking, i.e. 2.0 change) will be to change the status API field serializers so that they use a nested serializer like any other foreign-key reference, i.e. instead of:
This would also fix any schema generation warnings that can be seen after customizing the Statuses in your installation, e.g.:
(drf_spectacular.W001) Warning: enum naming encountered a non-optimally resolvable collision for fields named "status". The same name has been used for multiple choice sets in multiple components. The collision was resolved with "Status5a0Enum". add an entry to ENUM_NAME_OVERRIDES to fix the naming.
Straightforward enough to implement, thanks to extensive use of mixin classes. The bigger challenge will be making it backwards-compatible with older API versions - there are a lot of models with Statuses, so that'll be a lot of versioned serializers.
glennmatthews
changed the title
OpenAPI (Swagger) schema shouldn't provide choices for Status or Role references
OpenAPI (Swagger) schema shouldn't provide choices for Status references
Feb 3, 2023
Environment
Steps to Reproduce
Currently the OpenAPI schema generated by Nautobot will list a specific enum of permissible options for references to Status objects, e.g.
The problem, of course, is that this is NOT actually a hard-coded list of choices, it's determined at schema generation time from whatever set of Status objects happen to be defined. The moment a user adds, deletes, or edits any Status record, this part of the schema becomes inaccurate.
Most likely, the best solution here (albeit probably a breaking, i.e. 2.0 change) will be to change the
status
API field serializers so that they use a nested serializer like any other foreign-key reference, i.e. instead of:they instead use:
The text was updated successfully, but these errors were encountered: