Unable to setting query parameters to be required
See original GitHub issueI’m trying to set query parameter on a HttpGet to be required but am unable to do so. Even integers will not be required by default when the swagger.json is created.
[HttpGet]
[Produces("application/json", Type = typeof(IEnumerable<string>))]
[SwaggerOperation(operationId: "ListStuff")]
[ProducesResponseType(typeof(string), (int)HttpStatusCode.BadRequest)]
public IActionResult ListStuff(int id, [Required]string auditId)
{
...
}
In the above scenario, both id and auditId will be flagged as not required:
"parameters": [{
"name": "id",
"in": "query",
"required": false,
"type": "integer"
},
{
"name": "auditId",
"in": "query",
"required": false,
"type": "string"
}]
Not sure if this is a bug (swear I read somewhere that required is the default), or if I’m doing something wrong?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
What's the problem with required query parameters?
When reviewing API designs, I often encounter operations such as GET /resources?queryParameter=value where the query parameter is required.
Read more >Unable to set query parameters manually for a rest api ...
The problem is that r.URL.Query() parses the url, creates the map of parameters and returns it. This is done with every .Query() call....
Read more >unable to pass query string parameter id from test class
Hi SFDC Coder, First you need to create a pagereference, then set the parameters and then you set the currentpage: PageReference pRef =...
Read more >APIM returning 404 when mandatory query parameter is ...
I have an APIM instance with an OpenAPI spec imported. One of the endpoints has a mandatory query parameter, with application-level ...
Read more >Error "Invalid value for query parameter" and failed to send ...
Learn how to send a proper request with array query parameters with APIKit when invalid query parameter error occurs.
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 Free
Top 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
Same here. [Required] on primitive parameter not show up. [Required] on object parameter works fine.
+1 I got something like
And I got something like