Automatically detect optional @Query
See original GitHub issueAm I right in thinking that you could look for a ?
on the query function parameter to denote that it is optional, and pick this up to set the required
value on the swagger document?
It would be nicer than having to add decorators like @ApiImplicitQuery({name:'offset',required:false})
to the method I think. What do you reckon?
Thanks 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:29
- Comments:22 (5 by maintainers)
Top Results From Across the Web
Query Parameters - FastAPI
As query parameters are not a fixed part of a path, they can be optional and can have default values. In the example...
Read more >Optional query string parameters in ASP.NET Web API
If I set all of the parameters the method gets called; furthermore it starts with Get so it is automatically bound with the...
Read more >Using schema auto-detection | BigQuery - Google Cloud
Schema auto-detection enables BigQuery to infer the schema for CSV, JSON, or Sheets data. ... SSSSSS] (the fractional-second component is optional).
Read more >Retrofit — Optional Query Parameters - Future Studio
Depending on the API design, the sort parameter might be optional. In case you don't want to pass it with the request, just...
Read more >Testing Python Connexion Optional Query Parameter Names
It allows you to make the openAPI specification define input validation that is automatically enforced, maps API endpoints to a named function ...
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
Keep in mind that a param could also be optional if it has a default value rather than a
?
. For example:It would be ideal if swagger could detect the default value using reflection and document that the param is optional as well as the default values.
Also, note that in this example the param type is explicitly declared as
Number
, but this is also not reflected in the swagger docs if we omit the@ApiImplicitQuery({type: Number})
. In fact, the try it out form field will currently not accept a number without the type specified in theApiImplicitQuery
decorator.It would be ideal if all of these things could be inferred by reflection so that you would only need to use the
@ApiImplicitQuery
decorator to add thedescription
.Sure, good idea, but I would still rather have something where the API properties can be inferred by reflection rather than more decorators as it becomes much more verbose 👍