Client generation for Action with optional bool parameter
See original GitHub issueImagine this sample action:
public async Task<IActionResult> Get([FromQuery]string order = null, [FromQuery]bool IsOrder = true)
The NSwag generated client method looks like this (with generateOptionalParameters):
public async Task<Object> GetAsync(string order = null, bool? IsOrder)
{
if (isOrder == null)
throw new ArgumentNullException("IsOrder");
...
}
This looks weird to me. Why is the generated parameter not like the one from the action? Is this a limitation of reflection? This way I have to specify a value for an otherwise optional parameter. And as a consumer I dont even know what the default value for the bool is here, if I dont bother.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Specify optional parameter names even though not required?
Using optional parameters is a sign that the method is doing more that one thing. Boolean parameters are also a sign of this....
Read more >Nullable bool or bool with default value in action?
MVC Action with Optional Parameters -- which is better? 1 · Nullable or default value? 1 · Which way would you suggest to...
Read more >Using OpenApiReference To Generate Open API Client ...
I this post I show how you can customise the code generated by the OpenApiReference tooling from Visual Studio's Connected Services using ...
Read more >Parameter binding in Minimal API applications
Parameter binding is the process of converting request data into strongly typed parameters that are expressed by route handlers.
Read more >Actions
In ROS 2, action clients will be the sole entities responsible for generating the goal ID. This way clients always know the goal...
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
What do you think?
https://github.com/RSuter/NSwag/commit/202c1b8dd1acc63ca945508fb7d27868838f9c17
Looks good to me. Tested it with the ci build (https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/2795/artifacts).