Skip to content

How to doc a path with only optional queries? #8153

Answered by tiangolo
yurzo asked this question in Questions
Discussion options

You must be logged in to vote

HI @tiangolo: Thanks for your quick response and fantastic work on fastapi BTW!

I'm glad you're liking it!

Is there a way this would be possible?

Not really, that is not supported by OpenAPI, so, wouldn't show up in Swagger UI.

One alternative would be to have some predefined query parameters, and have their name dynamically created, using Query(None, alias=some_variable_with_the_query_param_name). But having an arbitrary amount of query parameters that are not defined in the OpenAPI is not supported by OpenAPI.

Still, you could do it, as you found out, but it wouldn't be "documentable".

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by svlandeg
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
Converted from issue

This discussion was converted from issue #336 on February 28, 2023 12:21.