Skip to content

Commit dbd8909

Browse files
committed
add accept header select to async method
1 parent 6ed7663 commit dbd8909

File tree

1 file changed

+11
-1
lines changed
  • modules/swagger-codegen/src/main/resources/csharp

1 file changed

+11
-1
lines changed

modules/swagger-codegen/src/main/resources/csharp/api.mustache

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,17 @@ namespace {{packageName}}.Api
166166
var formParams = new Dictionary<String, String>();
167167
var fileParams = new Dictionary<String, FileParameter>();
168168
String postBody = null;
169-
169+
170+
// to determine the Accept header
171+
String[] http_header_accepts = new String[] {
172+
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
173+
};
174+
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
175+
if (http_header_accept != null)
176+
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
177+
178+
// set "format" to json by default
179+
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
170180
pathParams.Add("format", "json");
171181
{{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // path parameter
172182
{{/pathParams}}

0 commit comments

Comments
 (0)