mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
[csharp] Make API response headers dictionary case insensitive (#2998)
* fix(response-headers): Making response headers case insensitive * fix(response-headers): Making response headers case insensitive * feat(csharp): Headers case insensitive * feat(csharp): Making API response's headers case-insensitive * feat(csharp): Indentation fix * feat(csharp): Indentation fix * feat(csharp): Adding generator's documentation
This commit is contained in:
parent
7756296c25
commit
40ec016c87
@ -28,3 +28,4 @@ sidebar_label: csharp
|
||||
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|
|
||||
|validatable|Generates self-validatable models.| |true|
|
||||
|useCompareNetObjects|Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive| |false|
|
||||
|
@ -232,6 +232,8 @@ public class CodegenConstants {
|
||||
public static final String PARCELIZE_MODELS = "parcelizeModels";
|
||||
public static final String PARCELIZE_MODELS_DESC = "toggle \"@Parcelize\" for generated models";
|
||||
|
||||
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS = "caseInsensitiveResponseHeaders";
|
||||
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS_DESC = "Make API response's headers case-insensitive";
|
||||
|
||||
// Not user-configurable. System provided for use in templates.
|
||||
|
||||
|
@ -73,6 +73,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// use KellermanSoftware.CompareNetObjects for deep recursive object comparision
|
||||
protected boolean useCompareNetObjects = Boolean.FALSE;
|
||||
|
||||
// To make API response's headers dictionary case insensitive
|
||||
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
|
||||
|
||||
public CSharpClientCodegen() {
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
@ -199,6 +202,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.USE_COMPARE_NET_OBJECTS_DESC,
|
||||
this.useCompareNetObjects);
|
||||
|
||||
addSwitch(CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS,
|
||||
CodegenConstants.CASE_INSENSITIVE_RESPONSE_HEADERS_DESC,
|
||||
this.caseInsensitiveResponseHeaders);
|
||||
|
||||
regexModifiers = new HashMap<Character, String>();
|
||||
regexModifiers.put('i', "IgnoreCase");
|
||||
regexModifiers.put('m', "Multiline");
|
||||
@ -802,6 +809,10 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
this.useCompareNetObjects = useCompareNetObjects;
|
||||
}
|
||||
|
||||
public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveResponseHeaders) {
|
||||
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
|
||||
}
|
||||
|
||||
public boolean isNonPublicApi() {
|
||||
return nonPublicApi;
|
||||
}
|
||||
|
@ -308,12 +308,12 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
|
||||
{{#returnType}}
|
||||
return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value)),
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
||||
({{{returnType}}}) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return new ApiResponse<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value)),
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
||||
null);
|
||||
{{/returnType}}
|
||||
}
|
||||
@ -444,12 +444,12 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
|
||||
{{#returnType}}
|
||||
return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value)),
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
||||
({{{returnType}}}) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return new ApiResponse<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value)),
|
||||
localVarResponse.Headers.ToDictionary(x => x.{{^netStandard}}Name{{/netStandard}}{{#netStandard}}Key{{/netStandard}}, x => string.Join(",", x.Value){{#caseInsensitiveResponseHeaders}}, StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}),
|
||||
null);
|
||||
{{/returnType}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user