Exception raised when generating OpenAPI schema after adding new serializer fields #15570
Labels
severity: medium
Results in substantial degraded or broken functionality for specfic workflows
status: accepted
This issue has been accepted for implementation
type: bug
A confirmed report of unexpected behavior in the application
Deployment Type
NetBox Cloud
NetBox Version
v3.7.4
Python Version
3.10
Steps to Reproduce
I'm opening this issue to document a suspected bug uncovered during work on #15464. That FR entails defining new ManyToManyFields on the customer User and Group models introduced in NetBox v4.0 to track ObjectPermission assignments. Consequently, the API serializers for these models must each also have a field added to track these relationships. This is what has been added to the UserSerializer class:
Note that the field defines a
source
attribute different from its name, as the underlying relationship is referenced asobject_permissions
rather thanpermissions
.Expected Behavior
Adding this field to the model should not break the schema generation.
Observed Behavior
An exception is raised when generating the OpenAPI schema:
With some effort, I was able to track this down to the following lines in
NetBoxAutoSchema.get_writable_class()
:netbox/netbox/core/api/schema.py
Lines 159 to 160 in 69c0aac
Removing these lines results in the schema being generated successfully and, as far as I have been able to discern, accurately. Several of the request definitions are renamed (e.g.
PatchedWritableProviderRequest
becomesPatchedProviderRequest
) but otherwise unmodified, and the title and/or description are removed from a few fields. I believe this also removes the erroenous designation of several fields as required (e.g.vdcs
on Interface).The text was updated successfully, but these errors were encountered: