Nswag: Pass complex types as HTTPGET parameters

Created on 19 Jul 2018  路  2Comments  路  Source: RicoSuter/NSwag

Hi!
I麓d like to pass a custom Filter-object to my controller method GET(Filter filter).
I have learned that setting the annotation
[HttpGet("{filter:Filter}")]
public async IActionResult Get(Filter filter)
{...}
creates a client that expects a Filter-object correctly (instead of each filter-property).
But in server I get a System.InvalidOperationException
see:
https://stackoverflow.com/questions/51423435/asp-net-core-webapi-httpget-passing-complex-type

What am I missing here?

question

Most helpful comment

You麓re right! Your answer led me to the solution.
In my case I had to add the [FromRoute]-Attribute
to the controller method argument. Runs perfectly!

Thank you!

All 2 comments

Swagger cannot describe complex parameters for GET (this is an ASP.NET (Core) model binder feature) and thus you'll end up with lot's of normal query parameters...

You麓re right! Your answer led me to the solution.
In my case I had to add the [FromRoute]-Attribute
to the controller method argument. Runs perfectly!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings