[FEATURE] Choices Dropdown Menu in API Documentation
See original GitHub issueFeature Request:
It would be nice to document in the API, which what choices are available to the user as a drop-down menu in the UI. It helps prevent such documentation in the description\help of the parameter.
Context
flask_restplus
library is able to show choices in its Swagger UI, and is able to handle if incorrect choice is provided as an input by the user.
Preferred Solution:
Would like to see choices
parameter added to possibly fastapi.Query
class and possibly other classes that handle input from user.
Would be awesome if it was something like this
@api.get('/get_countries')
def get_something(
choice: str = Query('eu', choices=('eu,'us','cn,'ru'), description='foo bar')
):
do_something(choice)
Would be nice to see this feature in FastAPI
, as I/We would prefer to use FastAPI
over flask_restplus
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:18 (6 by maintainers)
Top Results From Across the Web
API to Create or Update dropdown list - Typeform Community
I'd like to update a dropdown part of my form with a list of today+7 to today+30 every night. Currently it looks like....
Read more >Dropdown | Dash for Python Documentation | Plotly
This is an example on how to update the options on the server depending on the search terms the user types. For example...
Read more >Dropdown Component - Appian 21.2
Function. Displays a list of choices for the user to select one item and saves a value based on the selected choice. If...
Read more >Dropdown Menu - Symphony Developers Documentation
A dropdown menu is a static list of items that appears whenever a piece of text or a button is clicked. This is...
Read more >Define option lists - Retool Docs
Many components present a list of options, such as the dropdown in a Select or the menu of a Split Button. Each option...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
after some digging it seems it works out of the box:
Hey @alikhtag, just to let you know, this is available now in the latest versions (actually for some time now).
Here are docs for how to use enums in paths, but the same applies to queries: https://fastapi.tiangolo.com/tutorial/path-params/#predefined-values
Here’s your same example: