question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client generation for Action with optional bool parameter

See original GitHub issue

Imagine 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
zuckerthobencommented, Nov 1, 2017

Looks good to me. Tested it with the ci build (https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/2795/artifacts).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found