NSwag studio generates wrong HTTP Headers for IEnumerable collections

Created on 9 Jun 2017  路  13Comments  路  Source: RicoSuter/NSwag

Hi Team.

I have Web API with action which have Http Header parameters with IEnumerable types, like:
public IActionResult Get([FromHeader]List<string> idList)

When I generate client, using NSwag studio (based on Swagger Json specification)
it creates API methods with folowing code line:

request_.Headers.TryAddWithoutValidation("idList", idList != null ? idList.ToString() : null);

Nswag supose that i passing string which is wrong.

Could someone suggest me how to fix it.
(Probably, I'm doing something wrong with Nswag config)

Thanks a lot in advance.

Most helpful comment

You build something life-saving with NSwag? :-)

All 13 comments

This is currently not supported...
What would be the expected output?

Thanks a lot for the quick answer.
Expected output should be:
request_.Headers.Add("idList", idList);

Is it also ok to use

request_.Headers.TryAddWithoutValidation("idList", idList);

?

Yeah, this one should be ok.
Thanks.

Sorry I have one more (probably stupid :) ) question:
Should I expect this fixed in next version(s) of Nswag studio ?

Thanks.

Yes, v11... released next week.
Until then you can use the latest CI builds:

https://ci.appveyor.com/project/rsuter/nswag-25x6o/build/artifacts

Clear and Thank you so much !
You save my life :)

You build something life-saving with NSwag? :-)

Yeah, almost :) (only my life and my colleagues :)) ) And not only life but time also !!!
We are building some complex, AR product (Unfortunately, I can't say now what exatly the name of product / company etc. (( )

Cheers !!

Sounds interesting :-). Then I wish you success with your project!

Thanks man ;)

p.s
Totaly forgot that we have web site :)
https://www.re-flekt.com/

Just FYI: v11 is released, v11.1 incoming ;-)

Thanks a lot for the update. ;-)

Was this page helpful?
0 / 5 - 0 ratings