swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[csharp] fix: ApiResponse Header values

Open faryu opened this issue 8 years ago • 2 comments

The Header values within the ApiResponse class where all "System.String[]". (The string, not a real string array) With this fix it has the correct header values.

Also added an option to the petstore example in order to use the correct csproj format for the netstandard project generation.

faryu avatar Oct 28 '17 17:10 faryu

Now it doesn't break the build of any netframework project.

I digged a bit deeper to locate the cause of the bug and found, that the different RestSharp versions where the cause. RestSharp.portable has a list of values, whereas RestSharp has a combined string.

Now I moved the RestSharp version dependent code into the ApiResponse class.

netstandard / netcore libraries have IDictionary<string, string[]> Headers whereas netframework has IDictionary<string, string> Headers.

In order to normalize the ApiResponse class either the combined value needs to be splitt or the list of values be combined. I don't know all possible ways of combining http header values (which delimiters are allowed, how are single values escaped if they contain the delimiter, etc.), which makes converting them from one format to another complicated for myself, so I just keep the values as they are.

faryu avatar Oct 29 '17 10:10 faryu

@faryu Thanks, now that you say the issue that is correctly what I remembered. I couldn't remember the details, just that there is a wonky difference between the two. Ideally, I'd like to invest some time into removing RestSharp, but I haven't had much OSS contribution time for a few months.

The point about the constructor was regarding existing code which may be using the ApiClient directly. I'm ok with your change, since it will affect less consumers. And if it has a negative impact on more than anticipated, we can add the additional constructor. The reason I don't consider it a huge deal is because consumers could just as well modify the csharp templates and add the constructor.

@wing328 thoughts on that?

jimschubert avatar Oct 29 '17 13:10 jimschubert