List ChoiceField choices in Swagger as enum #3254

Closed
opened 2025-12-29 18:27:08 +01:00 by adam · 7 comments
Owner

Originally created by @deathbeam on GitHub (Jan 31, 2020).

Environment

  • Python version: 3.7.3
  • NetBox version: 2.7.2

Proposed Functionality

Based on this specification https://swagger.io/docs/specification/data-models/enums/ the ChoiceField choices for label and value can (and should) be listed as enums.

Use Case

Proper generation of API model from openapi specification for 3rd party projects without requirement to query OPTIONS for each endpoint to receive extra data from django. For example we are generating Java API for Netbox based on openapi spec from Netbox. Also having the choices listed on api/docs Swagger UI is very helpful when browsing through the API docs.

Database Changes

None

External Dependencies

None

Originally created by @deathbeam on GitHub (Jan 31, 2020). ### Environment * Python version: 3.7.3 * NetBox version: 2.7.2 ### Proposed Functionality Based on this specification https://swagger.io/docs/specification/data-models/enums/ the ChoiceField choices for label and value can (and should) be listed as enums. ### Use Case Proper generation of API model from openapi specification for 3rd party projects without requirement to query OPTIONS for each endpoint to receive extra data from django. For example we are generating Java API for Netbox based on openapi spec from Netbox. Also having the choices listed on api/docs Swagger UI is very helpful when browsing through the API docs. ### Database Changes None ### External Dependencies None
adam added the type: featurestatus: under review labels 2025-12-29 18:27:08 +01:00
adam closed this issue 2025-12-29 18:27:08 +01:00
Author
Owner

@deathbeam commented on GitHub (Jan 31, 2020):

screenie

Example of generated data with enum support

@deathbeam commented on GitHub (Jan 31, 2020): ![screenie](https://user-images.githubusercontent.com/5115805/73547863-12aaca80-4440-11ea-8d95-47102559ec22.png) Example of generated data with enum support
Author
Owner

@jeremystretch commented on GitHub (Jan 31, 2020):

This issue has been closed as it does not conform to one of the provided templates as required by the contributing guide. If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).

@jeremystretch commented on GitHub (Jan 31, 2020): This issue has been closed as it does not conform to one of the [provided templates](https://github.com/netbox-community/netbox/issues/new/choose) as required by the [contributing guide](https://github.com/netbox-community/netbox/blob/master/CONTRIBUTING.md). If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).
Author
Owner

@deathbeam commented on GitHub (Jan 31, 2020):

@jeremystretch Updated, can you reopen?

@deathbeam commented on GitHub (Jan 31, 2020): @jeremystretch Updated, can you reopen?
Author
Owner

@kobayashi commented on GitHub (Feb 3, 2020):

I would Approve this as Enhancement

@kobayashi commented on GitHub (Feb 3, 2020): I would Approve this as Enhancement
Author
Owner

@jeremystretch commented on GitHub (Feb 14, 2020):

I don't have any objection to this, but do we have a good understanding of what might break by making the change? Thinking about pynetbox specifically, and similar API clients.

(I'm not really sure if this constitutes an API change, but I've tagged it as such just to be safe.)

@jeremystretch commented on GitHub (Feb 14, 2020): I don't have any objection to this, but do we have a good understanding of what might break by making the change? Thinking about pynetbox specifically, and similar API clients. (I'm not really sure if this constitutes an API change, but I've tagged it as such just to be safe.)
Author
Owner

@deathbeam commented on GitHub (Feb 14, 2020):

It is just extra enum field next to type field that was not there before, so as long as consumers of the spec are ignoring unknown fields when parsing it should not affect anything.

@deathbeam commented on GitHub (Feb 14, 2020): It is just extra `enum` field next to `type` field that was not there before, so as long as consumers of the spec are ignoring unknown fields when parsing it should not affect anything.
Author
Owner

@kobayashi commented on GitHub (Mar 4, 2020):

Yes, this should not affect to pynetbox. While playing with pynetbox, this change seems to not affect to the client. For go-netbox, I can make some fix for this.

@kobayashi commented on GitHub (Mar 4, 2020): Yes, this should not affect to pynetbox. While playing with pynetbox, this change seems to not affect to the client. For go-netbox, I can make some fix for this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3254