diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 8966e19b9ce..23c266e618f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -92,6 +92,7 @@ public CSharpClientCodegen() { typeMapping = new HashMap(); typeMapping.put("string", "string"); + typeMapping.put("binary", "byte[]"); typeMapping.put("boolean", "bool?"); typeMapping.put("integer", "int?"); typeMapping.put("float", "float?"); diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index fab938460fc..8a22c2f23f9 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -77,9 +77,10 @@ namespace {{packageName}}.Client // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = new RestRequest(path, method); @@ -103,8 +104,17 @@ namespace {{packageName}}.Client foreach(var param in fileParams) request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); - if (postBody != null) // http body (model) parameter - request.AddParameter("application/json", postBody, ParameterType.RequestBody); + if (postBody != null) // http body (model or byte[]) parameter + { + if (postBody.GetType() == typeof(String)) + { + request.AddParameter("application/json", postBody, ParameterType.RequestBody); + } + else if (postBody.GetType() == typeof(byte[])) + { + request.AddParameter(contentType, postBody, ParameterType.RequestBody); + } + } return request; } @@ -120,14 +130,18 @@ namespace {{packageName}}.Client /// Form parameters. /// File parameters. /// Path parameters. + /// Content Type of the request /// Object public Object CallApi( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + path, method, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, contentType); + var response = RestClient.Execute(request); return (Object) response; } @@ -143,14 +157,17 @@ namespace {{packageName}}.Client /// Form parameters. /// File parameters. /// Path parameters. + /// Content type. /// The Task instance. public async System.Threading.Tasks.Task CallApiAsync( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + path, method, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, contentType); var response = await RestClient.ExecuteTaskAsync(request); return (Object)response; } @@ -230,6 +247,10 @@ namespace {{packageName}}.Client { return content; } + else if (type == typeof(byte[])) // return byte array + { + return data; + } if (type == typeof(Stream)) { @@ -276,11 +297,11 @@ namespace {{packageName}}.Client } /// - /// Serialize an object into JSON string. + /// Serialize an input (model) into JSON string /// /// Object. /// JSON string. - public string Serialize(object obj) + public String Serialize(object obj) { try { @@ -292,6 +313,24 @@ namespace {{packageName}}.Client } } + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public String SelectHeaderContentType(String[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + if (contentTypes.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + /// /// Select the Accept header's value from the given accepts array: /// if JSON exists in the given array, use it; diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 51f8b3f9394..28919d6be49 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -154,7 +154,8 @@ namespace {{packageName}}.Api { {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}"); + if ({{paramName}} == null) + throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}"); {{/required}}{{/allParams}} var path_ = "{{path}}"; @@ -164,15 +165,21 @@ namespace {{packageName}}.Api var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -185,11 +192,16 @@ namespace {{packageName}}.Api {{/headerParams}} {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}} {{/formParams}} - {{#bodyParam}}postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter - {{/bodyParam}} + {{#bodyParam}}if ({{paramName}}.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter + } + else + { + postBody = {{paramName}}; // byte array + }{{/bodyParam}} - {{#authMethods}} - // authentication ({{name}}) required + {{#authMethods}}// authentication ({{name}}) required {{#isApiKey}}{{#isKeyInHeader}} var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); if (!String.IsNullOrEmpty(apiKeyValue)) @@ -214,7 +226,9 @@ namespace {{packageName}}.Api {{/authMethods}} // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -261,15 +275,21 @@ namespace {{packageName}}.Api var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -311,7 +331,9 @@ namespace {{packageName}}.Api {{/authMethods}} // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index 66762d74b2b..703b920db21 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -19,6 +19,49 @@ "http" ], "paths": { + "/pet?testing_byte_array=true": { + "post": { + "tags": [ + "pet" + ], + "summary": "Fake endpoint to test byte array in body parameter for adding a new pet to the store", + "description": "", + "operationId": "addPetUsingByteArray", + "consumes": [ + "application/json", + "application/xml" + ], + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet object in the form of byte array", + "required": false, + "schema": { + "type": "string", + "format": "binary" + } + } + ], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, "/pet": { "post": { "tags": [ @@ -206,6 +249,56 @@ ] } }, + "/pet/{petId}?testing_byte_array=true": { + "get": { + "tags": [ + "pet" + ], + "summary": "Fake endpoint to test byte array return by 'Find pet by ID'", + "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "operationId": "getPetByIdWithByteArray", + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "404": { + "description": "Pet not found" + }, + "200": { + "description": "successful operation", + "schema": { + "type": "string", + "format": "binary" + } + }, + "400": { + "description": "Invalid ID supplied" + } + }, + "security": [ + { + "api_key": [] + }, + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, "/pet/{petId}": { "get": { "tags": [ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index ba58eeac9e0..892412e5b3e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -355,6 +355,86 @@ public interface IPetApi /// Task of ApiResponse System.Threading.Tasks.Task> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// byte[] + byte[] GetPetByIdWithByteArray (long? petId); + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of byte[] + ApiResponse GetPetByIdWithByteArrayWithHttpInfo (long? petId); + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of byte[] + System.Threading.Tasks.Task GetPetByIdWithByteArrayAsync (long? petId); + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (byte[]) + System.Threading.Tasks.Task> GetPetByIdWithByteArrayAsyncWithHttpInfo (long? petId); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// + void AddPetUsingByteArray (byte[] body = null); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// ApiResponse of Object(void) + ApiResponse AddPetUsingByteArrayWithHttpInfo (byte[] body = null); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// Task of void + System.Threading.Tasks.Task AddPetUsingByteArrayAsync (byte[] body = null); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// Task of ApiResponse + System.Threading.Tasks.Task> AddPetUsingByteArrayAsyncWithHttpInfo (byte[] body = null); + } /// @@ -459,15 +539,21 @@ public ApiResponse UpdatePetWithHttpInfo (Pet body = null) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -476,10 +562,15 @@ public ApiResponse UpdatePetWithHttpInfo (Pet body = null) - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } - // authentication (petstore_auth) required // oauth required @@ -490,7 +581,9 @@ public ApiResponse UpdatePetWithHttpInfo (Pet body = null) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -532,15 +625,21 @@ public async System.Threading.Tasks.Task> UpdatePetAsyncWith var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -563,7 +662,9 @@ public async System.Threading.Tasks.Task> UpdatePetAsyncWith // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -604,15 +705,21 @@ public ApiResponse AddPetWithHttpInfo (Pet body = null) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -621,10 +728,15 @@ public ApiResponse AddPetWithHttpInfo (Pet body = null) - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } - // authentication (petstore_auth) required // oauth required @@ -635,7 +747,9 @@ public ApiResponse AddPetWithHttpInfo (Pet body = null) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -677,15 +791,21 @@ public async System.Threading.Tasks.Task> AddPetAsyncWithHtt var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -708,7 +828,9 @@ public async System.Threading.Tasks.Task> AddPetAsyncWithHtt // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -750,15 +872,21 @@ public ApiResponse< List > FindPetsByStatusWithHttpInfo (List statu var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -770,7 +898,6 @@ public ApiResponse< List > FindPetsByStatusWithHttpInfo (List statu - // authentication (petstore_auth) required // oauth required @@ -781,7 +908,9 @@ public ApiResponse< List > FindPetsByStatusWithHttpInfo (List statu // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -824,15 +953,21 @@ public async System.Threading.Tasks.Task>> FindPetsByStatu var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -855,7 +990,9 @@ public async System.Threading.Tasks.Task>> FindPetsByStatu // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -897,15 +1034,21 @@ public ApiResponse< List > FindPetsByTagsWithHttpInfo (List tags = var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -917,7 +1060,6 @@ public ApiResponse< List > FindPetsByTagsWithHttpInfo (List tags = - // authentication (petstore_auth) required // oauth required @@ -928,7 +1070,9 @@ public ApiResponse< List > FindPetsByTagsWithHttpInfo (List tags = // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -971,15 +1115,21 @@ public async System.Threading.Tasks.Task>> FindPetsByTagsA var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1002,7 +1152,9 @@ public async System.Threading.Tasks.Task>> FindPetsByTagsA // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1037,7 +1189,8 @@ public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) { // verify the required parameter 'petId' is set - if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById"); + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetById"); var path_ = "/pet/{petId}"; @@ -1047,15 +1200,21 @@ public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1067,7 +1226,6 @@ public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) - // authentication (api_key) required var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); @@ -1078,7 +1236,9 @@ public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1123,15 +1283,21 @@ public async System.Threading.Tasks.Task> GetPetByIdAsyncWithHt var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1154,7 +1320,9 @@ public async System.Threading.Tasks.Task> GetPetByIdAsyncWithHt // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1192,7 +1360,8 @@ public ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string n { // verify the required parameter 'petId' is set - if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm"); + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm"); var path_ = "/pet/{petId}"; @@ -1202,15 +1371,21 @@ public ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string n var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/x-www-form-urlencoded" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1224,7 +1399,6 @@ public ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string n - // authentication (petstore_auth) required // oauth required @@ -1235,7 +1409,9 @@ public ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string n // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1283,15 +1459,21 @@ public async System.Threading.Tasks.Task> UpdatePetWithFormA var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/x-www-form-urlencoded" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1316,7 +1498,9 @@ public async System.Threading.Tasks.Task> UpdatePetWithFormA // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1352,7 +1536,8 @@ public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = n { // verify the required parameter 'petId' is set - if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet"); + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->DeletePet"); var path_ = "/pet/{petId}"; @@ -1362,15 +1547,21 @@ public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = n var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1383,7 +1574,6 @@ public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = n - // authentication (petstore_auth) required // oauth required @@ -1394,7 +1584,9 @@ public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = n // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1440,15 +1632,21 @@ public async System.Threading.Tasks.Task> DeletePetAsyncWith var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1472,7 +1670,9 @@ public async System.Threading.Tasks.Task> DeletePetAsyncWith // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1510,7 +1710,8 @@ public ApiResponse UploadFileWithHttpInfo (long? petId, string additiona { // verify the required parameter 'petId' is set - if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile"); + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->UploadFile"); var path_ = "/pet/{petId}/uploadImage"; @@ -1520,15 +1721,21 @@ public ApiResponse UploadFileWithHttpInfo (long? petId, string additiona var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "multipart/form-data" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1542,7 +1749,6 @@ public ApiResponse UploadFileWithHttpInfo (long? petId, string additiona - // authentication (petstore_auth) required // oauth required @@ -1553,7 +1759,9 @@ public ApiResponse UploadFileWithHttpInfo (long? petId, string additiona // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1601,15 +1809,21 @@ public async System.Threading.Tasks.Task> UploadFileAsyncWit var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "multipart/form-data" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1634,7 +1848,9 @@ public async System.Threading.Tasks.Task> UploadFileAsyncWit // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1649,6 +1865,340 @@ public async System.Threading.Tasks.Task> UploadFileAsyncWit null); } + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// byte[] + public byte[] GetPetByIdWithByteArray (long? petId) + { + ApiResponse response = GetPetByIdWithByteArrayWithHttpInfo(petId); + return response.Data; + } + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of byte[] + public ApiResponse< byte[] > GetPetByIdWithByteArrayWithHttpInfo (long? petId) + { + + // verify the required parameter 'petId' is set + if (petId == null) + throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetByIdWithByteArray"); + + + var path_ = "/pet/{petId}?testing_byte_array=true"; + + var pathParams = new Dictionary(); + var queryParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); + + // to determine the Accept header + String[] httpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + pathParams.Add("format", "json"); + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + + + + + + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (byte[]) Configuration.ApiClient.Deserialize(response, typeof(byte[]))); + + } + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of byte[] + public async System.Threading.Tasks.Task GetPetByIdWithByteArrayAsync (long? petId) + { + ApiResponse response = await GetPetByIdWithByteArrayAsyncWithHttpInfo(petId); + return response.Data; + + } + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (byte[]) + public async System.Threading.Tasks.Task> GetPetByIdWithByteArrayAsyncWithHttpInfo (long? petId) + { + // verify the required parameter 'petId' is set + if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetByIdWithByteArray"); + + + var path_ = "/pet/{petId}?testing_byte_array=true"; + + var pathParams = new Dictionary(); + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); + + // to determine the Accept header + String[] httpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + pathParams.Add("format", "json"); + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter + + + + + + + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetPetByIdWithByteArray: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (byte[]) Configuration.ApiClient.Deserialize(response, typeof(byte[]))); + + } + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// Pet object in the form of byte array + /// + public void AddPetUsingByteArray (byte[] body = null) + { + AddPetUsingByteArrayWithHttpInfo(body); + } + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// Pet object in the form of byte array + /// ApiResponse of Object(void) + public ApiResponse AddPetUsingByteArrayWithHttpInfo (byte[] body = null) + { + + + var path_ = "/pet?testing_byte_array=true"; + + var pathParams = new Dictionary(); + var queryParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); + + // to determine the Accept header + String[] httpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + pathParams.Add("format", "json"); + + + + + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling AddPetUsingByteArray: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling AddPetUsingByteArray: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// Pet object in the form of byte array + /// Task of void + public async System.Threading.Tasks.Task AddPetUsingByteArrayAsync (byte[] body = null) + { + await AddPetUsingByteArrayAsyncWithHttpInfo(body); + + } + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// Pet object in the form of byte array + /// Task of ApiResponse + public async System.Threading.Tasks.Task> AddPetUsingByteArrayAsyncWithHttpInfo (byte[] body = null) + { + + + var path_ = "/pet?testing_byte_array=true"; + + var pathParams = new Dictionary(); + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + "application/json", "application/xml" + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); + + // to determine the Accept header + String[] httpHeaderAccepts = new String[] { + "application/json", "application/xml" + }; + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); + + // set "format" to json by default + // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json + pathParams.Add("format", "json"); + + + + + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling AddPetUsingByteArray: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling AddPetUsingByteArray: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); + } + } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index a9e9d6e9b74..a92876f1a53 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -274,15 +274,21 @@ public void AddDefaultHeader(string key, string value) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -293,7 +299,6 @@ public void AddDefaultHeader(string key, string value) - // authentication (api_key) required var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); @@ -304,7 +309,9 @@ public void AddDefaultHeader(string key, string value) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -345,15 +352,21 @@ public void AddDefaultHeader(string key, string value) var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -375,7 +388,9 @@ public void AddDefaultHeader(string key, string value) // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -417,15 +432,21 @@ public ApiResponse< Order > PlaceOrderWithHttpInfo (Order body = null) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -434,13 +455,21 @@ public ApiResponse< Order > PlaceOrderWithHttpInfo (Order body = null) - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -483,15 +512,21 @@ public async System.Threading.Tasks.Task> PlaceOrderAsyncWith var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -506,7 +541,9 @@ public async System.Threading.Tasks.Task> PlaceOrderAsyncWith // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -541,7 +578,8 @@ public ApiResponse< Order > GetOrderByIdWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set - if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById"); + if (orderId == null) + throw new ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->GetOrderById"); var path_ = "/store/order/{orderId}"; @@ -551,15 +589,21 @@ public ApiResponse< Order > GetOrderByIdWithHttpInfo (string orderId) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -574,7 +618,9 @@ public ApiResponse< Order > GetOrderByIdWithHttpInfo (string orderId) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -619,15 +665,21 @@ public async System.Threading.Tasks.Task> GetOrderByIdAsyncWi var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -642,7 +694,9 @@ public async System.Threading.Tasks.Task> GetOrderByIdAsyncWi // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -676,7 +730,8 @@ public ApiResponse DeleteOrderWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set - if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder"); + if (orderId == null) + throw new ApiException(400, "Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"); var path_ = "/store/order/{orderId}"; @@ -686,15 +741,21 @@ public ApiResponse DeleteOrderWithHttpInfo (string orderId) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -709,7 +770,9 @@ public ApiResponse DeleteOrderWithHttpInfo (string orderId) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -753,15 +816,21 @@ public async System.Threading.Tasks.Task> DeleteOrderAsyncWi var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -776,7 +845,9 @@ public async System.Threading.Tasks.Task> DeleteOrderAsyncWi // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index 5502fe15da1..0b9e633c5f3 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -443,15 +443,21 @@ public ApiResponse CreateUserWithHttpInfo (User body = null) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -460,13 +466,21 @@ public ApiResponse CreateUserWithHttpInfo (User body = null) - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -508,15 +522,21 @@ public async System.Threading.Tasks.Task> CreateUserAsyncWit var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -531,7 +551,9 @@ public async System.Threading.Tasks.Task> CreateUserAsyncWit // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -572,15 +594,21 @@ public ApiResponse CreateUsersWithArrayInputWithHttpInfo (List bod var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -589,13 +617,21 @@ public ApiResponse CreateUsersWithArrayInputWithHttpInfo (List bod - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -637,15 +673,21 @@ public async System.Threading.Tasks.Task> CreateUsersWithArr var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -660,7 +702,9 @@ public async System.Threading.Tasks.Task> CreateUsersWithArr // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -701,15 +745,21 @@ public ApiResponse CreateUsersWithListInputWithHttpInfo (List body var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -718,13 +768,21 @@ public ApiResponse CreateUsersWithListInputWithHttpInfo (List body - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -766,15 +824,21 @@ public async System.Threading.Tasks.Task> CreateUsersWithLis var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -789,7 +853,9 @@ public async System.Threading.Tasks.Task> CreateUsersWithLis // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.POST, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -833,15 +899,21 @@ public ApiResponse< string > LoginUserWithHttpInfo (string username = null, stri var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -857,7 +929,9 @@ public ApiResponse< string > LoginUserWithHttpInfo (string username = null, stri // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -902,15 +976,21 @@ public async System.Threading.Tasks.Task> LoginUserAsyncWith var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -926,7 +1006,9 @@ public async System.Threading.Tasks.Task> LoginUserAsyncWith // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -965,15 +1047,21 @@ public ApiResponse LogoutUserWithHttpInfo () var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -987,7 +1075,9 @@ public ApiResponse LogoutUserWithHttpInfo () // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1027,15 +1117,21 @@ public async System.Threading.Tasks.Task> LogoutUserAsyncWit var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1049,7 +1145,9 @@ public async System.Threading.Tasks.Task> LogoutUserAsyncWit // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1084,7 +1182,8 @@ public ApiResponse< User > GetUserByNameWithHttpInfo (string username) { // verify the required parameter 'username' is set - if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName"); + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->GetUserByName"); var path_ = "/user/{username}"; @@ -1094,15 +1193,21 @@ public ApiResponse< User > GetUserByNameWithHttpInfo (string username) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1117,7 +1222,9 @@ public ApiResponse< User > GetUserByNameWithHttpInfo (string username) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1162,15 +1269,21 @@ public async System.Threading.Tasks.Task> GetUserByNameAsyncWi var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1185,7 +1298,9 @@ public async System.Threading.Tasks.Task> GetUserByNameAsyncWi // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.GET, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1221,7 +1336,8 @@ public ApiResponse UpdateUserWithHttpInfo (string username, User body = { // verify the required parameter 'username' is set - if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser"); + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->UpdateUser"); var path_ = "/user/{username}"; @@ -1231,15 +1347,21 @@ public ApiResponse UpdateUserWithHttpInfo (string username, User body = var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1249,13 +1371,21 @@ public ApiResponse UpdateUserWithHttpInfo (string username, User body = - postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - + if (body.GetType() != typeof(byte[])) + { + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + postBody = body; // byte array + } // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1301,15 +1431,21 @@ public async System.Threading.Tasks.Task> UpdateUserAsyncWit var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1325,7 +1461,9 @@ public async System.Threading.Tasks.Task> UpdateUserAsyncWit // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1359,7 +1497,8 @@ public ApiResponse DeleteUserWithHttpInfo (string username) { // verify the required parameter 'username' is set - if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser"); + if (username == null) + throw new ApiException(400, "Missing required parameter 'username' when calling UserApi->DeleteUser"); var path_ = "/user/{username}"; @@ -1369,15 +1508,21 @@ public ApiResponse DeleteUserWithHttpInfo (string username) var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1392,7 +1537,9 @@ public ApiResponse DeleteUserWithHttpInfo (string username) // make the HTTP request - IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; @@ -1436,15 +1583,21 @@ public async System.Threading.Tasks.Task> DeleteUserAsyncWit var headerParams = new Dictionary(); var formParams = new Dictionary(); var fileParams = new Dictionary(); - String postBody = null; + Object postBody = null; + + // to determine the Content-Type header + String[] httpContentTypes = new String[] { + + }; + String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header - String[] http_header_accepts = new String[] { + String[] httpHeaderAccepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); - if (http_header_accept != null) - headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); + String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAccept != null) + headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -1459,7 +1612,9 @@ public async System.Threading.Tasks.Task> DeleteUserAsyncWit // make the HTTP request - IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, + Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, httpContentType); int statusCode = (int) response.StatusCode; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index ee2e1b8b8f0..ab115aba980 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -77,9 +77,10 @@ public ApiClient(String basePath = "http://petstore.swagger.io/v2") // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = new RestRequest(path, method); @@ -103,8 +104,17 @@ private RestRequest PrepareRequest( foreach(var param in fileParams) request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); - if (postBody != null) // http body (model) parameter - request.AddParameter("application/json", postBody, ParameterType.RequestBody); + if (postBody != null) // http body (model or byte[]) parameter + { + if (postBody.GetType() == typeof(String)) + { + request.AddParameter("application/json", postBody, ParameterType.RequestBody); + } + else if (postBody.GetType() == typeof(byte[])) + { + request.AddParameter(contentType, postBody, ParameterType.RequestBody); + } + } return request; } @@ -120,14 +130,18 @@ private RestRequest PrepareRequest( /// Form parameters. /// File parameters. /// Path parameters. + /// Content Type of the request /// Object public Object CallApi( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + path, method, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, contentType); + var response = RestClient.Execute(request); return (Object) response; } @@ -143,14 +157,17 @@ public Object CallApi( /// Form parameters. /// File parameters. /// Path parameters. + /// Content type. /// The Task instance. public async System.Threading.Tasks.Task CallApiAsync( - String path, RestSharp.Method method, Dictionary queryParams, String postBody, + String path, RestSharp.Method method, Dictionary queryParams, Object postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams) + Dictionary fileParams, Dictionary pathParams, + String contentType) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + path, method, queryParams, postBody, headerParams, formParams, fileParams, + pathParams, contentType); var response = await RestClient.ExecuteTaskAsync(request); return (Object)response; } @@ -230,6 +247,10 @@ public object Deserialize(IRestResponse response, Type type) { return content; } + else if (type == typeof(byte[])) // return byte array + { + return data; + } if (type == typeof(Stream)) { @@ -276,11 +297,11 @@ public object Deserialize(IRestResponse response, Type type) } /// - /// Serialize an object into JSON string. + /// Serialize an input (model) into JSON string /// /// Object. /// JSON string. - public string Serialize(object obj) + public String Serialize(object obj) { try { @@ -292,6 +313,24 @@ public string Serialize(object obj) } } + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public String SelectHeaderContentType(String[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + if (contentTypes.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + /// /// Select the Accept header's value from the given accepts array: /// if JSON exists in the given array, use it; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index afe62f18b31..34b1a516f28 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -3,6 +3,10 @@ + + + + @@ -18,4 +22,4 @@ - \ No newline at end of file + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs index 0fc92c7266e..6eb32a38442 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs @@ -14,6 +14,26 @@ public void TearDown() Configuration.Default.DateTimeFormat = "o"; } + /// + /// Test SelectHeaderContentType + /// + [Test ()] + public void TestSelectHeaderContentType () + { + ApiClient api = new ApiClient (); + String[] contentTypes = new String[] { "application/json", "application/xml" }; + Assert.AreEqual("application/json", api.SelectHeaderContentType (contentTypes)); + + contentTypes = new String[] { "application/xml" }; + Assert.AreEqual("application/xml", api.SelectHeaderContentType (contentTypes)); + + contentTypes = new String[] {}; + Assert.IsNull(api.SelectHeaderContentType (contentTypes)); + } + + /// + /// Test ParameterToString + /// [Test ()] public void TestParameterToString () { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index fbbf4494951..001b052bf76 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -15,7 +15,10 @@ public class TestPet { public long petId = 11088; - [SetUp] public void Init() + /// + /// Create a Pet object + /// + private Pet createPet() { // create pet Pet p = new Pet(); @@ -36,6 +39,24 @@ [SetUp] public void Init() p.Category = category; p.PhotoUrls = photoUrls; + return p; + } + + /// + /// Convert string to byte array + /// + private byte[] GetBytes(string str) + { + byte[] bytes = new byte[str.Length * sizeof(char)]; + System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); + return bytes; + } + + [SetUp] public void Init() + { + // create pet + Pet p = createPet(); + // add pet before testing PetApi petApi = new PetApi("http://petstore.swagger.io/v2/"); petApi.AddPet (p); @@ -137,6 +158,35 @@ public void TestGetPetById () } + /// + /// Test GetPetByIdWithByteArray + /// + [Test ()] + public void TestGetPetByIdWithByteArray () + { + // set timeout to 10 seconds + Configuration c1 = new Configuration (timeout: 10000); + + PetApi petApi = new PetApi (c1); + byte[] response = petApi.GetPetByIdWithByteArray (petId); + Assert.IsInstanceOf (response, "Response is byte array"); + } + + /// + /// Test AddPetUsingByteArray + /// + [Test ()] + public void TestAddPetUsingByteArray () + { + // set timeout to 10 seconds + Configuration c1 = new Configuration (timeout: 10000); + + PetApi petApi = new PetApi (c1); + Pet p = createPet (); + byte[] petByteArray = GetBytes ((string)petApi.Configuration.ApiClient.Serialize (p)); + petApi.AddPetUsingByteArray (petByteArray); + } + /// /// Test UpdatePetWithForm /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb deleted file mode 100644 index d4c01b5c42a..00000000000 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and /dev/null differ