Skip to content
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

List ChoiceField choices in Swagger as enum #4062

Closed
deathbeam opened this issue Jan 31, 2020 · 7 comments · Fixed by #4063
Closed

List ChoiceField choices in Swagger as enum #4062

deathbeam opened this issue Jan 31, 2020 · 7 comments · Fixed by #4063
Labels
status: under review Further discussion is needed to determine this issue's scope and/or implementation type: feature Introduction of new functionality to the application

Comments

@deathbeam
Copy link
Contributor

deathbeam commented 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

deathbeam added a commit to deathbeam/netbox that referenced this issue Jan 31, 2020
Fixes netbox-community#4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
@deathbeam
Copy link
Contributor Author

screenie

Example of generated data with enum support

@jeremystretch
Copy link
Member

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).

@deathbeam deathbeam changed the title List choices in Swagger as enums List ChoiceField choices in Swagger as enum Jan 31, 2020
@deathbeam
Copy link
Contributor Author

@jeremystretch Updated, can you reopen?

@DanSheps DanSheps reopened this Jan 31, 2020
@kobayashi
Copy link
Contributor

I would Approve this as Enhancement

@jeremystretch
Copy link
Member

jeremystretch commented 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 jeremystretch added API change status: under review Further discussion is needed to determine this issue's scope and/or implementation type: feature Introduction of new functionality to the application labels Feb 14, 2020
@deathbeam
Copy link
Contributor Author

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.

@kobayashi
Copy link
Contributor

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.

deathbeam added a commit to deathbeam/netbox that referenced this issue Mar 4, 2020
Fixes netbox-community#4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
deathbeam added a commit to deathbeam/netbox that referenced this issue Mar 4, 2020
Fixes netbox-community#4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
deathbeam added a commit to deathbeam/netbox that referenced this issue Mar 5, 2020
Fixes netbox-community#4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
kobayashi pushed a commit to deathbeam/netbox that referenced this issue Mar 6, 2020
Fixes netbox-community#4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: under review Further discussion is needed to determine this issue's scope and/or implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants