-
Notifications
You must be signed in to change notification settings - Fork 6k
Open
Description
When returning the ApiResponse, the method ToDictionary is used to construct a response object from a raw API response. The method ToDictionary will expect only unique keys, but this is not always the case. For example, headers could repeat which would cause the code to end in an exception.
Here is an example from the generated code:
return new ApiResponse<KeycloakTokenResponse>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
(KeycloakTokenResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(KeycloakTokenResponse)));
nResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(KeycloakTokenResponse)));
and here is the modification I had to make:
return new ApiResponse<KeycloakTokenResponse>(localVarStatusCode,
localVarResponse.Headers.GroupBy(x => x.Name)
.ToDictionary(g => g.Key, g => g.Select(x => x.Value).ToString()),
(KeycloakTokenResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(KeycloakTokenResponse)));
This workaround means that duplicates are allowed in the response headers. I believe this should be part of the generated code, but I am asking for any contrasting opinion.
GutOFF and colby2
Metadata
Metadata
Assignees
Labels
No labels