add binary support to C# client

This commit is contained in:
wing328 2016-01-11 00:39:22 +08:00
parent ce82aa41fc
commit e0f43c1c58
12 changed files with 1363 additions and 319 deletions

View File

@ -92,6 +92,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping = new HashMap<String, String>(); typeMapping = new HashMap<String, String>();
typeMapping.put("string", "string"); typeMapping.put("string", "string");
typeMapping.put("binary", "byte[]");
typeMapping.put("boolean", "bool?"); typeMapping.put("boolean", "bool?");
typeMapping.put("integer", "int?"); typeMapping.put("integer", "int?");
typeMapping.put("float", "float?"); typeMapping.put("float", "float?");

View File

@ -77,9 +77,10 @@ namespace {{packageName}}.Client
// Creates and sets up a RestRequest prior to a call. // Creates and sets up a RestRequest prior to a call.
private RestRequest PrepareRequest( private RestRequest PrepareRequest(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = new RestRequest(path, method); var request = new RestRequest(path, method);
@ -103,8 +104,17 @@ namespace {{packageName}}.Client
foreach(var param in fileParams) foreach(var param in fileParams)
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
if (postBody != null) // http body (model) parameter if (postBody != null) // http body (model or byte[]) parameter
request.AddParameter("application/json", postBody, ParameterType.RequestBody); {
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; return request;
} }
@ -120,14 +130,18 @@ namespace {{packageName}}.Client
/// <param name="formParams">Form parameters.</param> /// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param> /// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param> /// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content Type of the request</param>
/// <returns>Object</returns> /// <returns>Object</returns>
public Object CallApi( public Object CallApi(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = PrepareRequest( 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); var response = RestClient.Execute(request);
return (Object) response; return (Object) response;
} }
@ -143,14 +157,17 @@ namespace {{packageName}}.Client
/// <param name="formParams">Form parameters.</param> /// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param> /// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param> /// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content type.</param>
/// <returns>The Task instance.</returns> /// <returns>The Task instance.</returns>
public async System.Threading.Tasks.Task<Object> CallApiAsync( public async System.Threading.Tasks.Task<Object> CallApiAsync(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = PrepareRequest( 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); var response = await RestClient.ExecuteTaskAsync(request);
return (Object)response; return (Object)response;
} }
@ -230,6 +247,10 @@ namespace {{packageName}}.Client
{ {
return content; return content;
} }
else if (type == typeof(byte[])) // return byte array
{
return data;
}
if (type == typeof(Stream)) if (type == typeof(Stream))
{ {
@ -276,11 +297,11 @@ namespace {{packageName}}.Client
} }
/// <summary> /// <summary>
/// Serialize an object into JSON string. /// Serialize an input (model) into JSON string
/// </summary> /// </summary>
/// <param name="obj">Object.</param> /// <param name="obj">Object.</param>
/// <returns>JSON string.</returns> /// <returns>JSON string.</returns>
public string Serialize(object obj) public String Serialize(object obj)
{ {
try try
{ {
@ -292,6 +313,24 @@ namespace {{packageName}}.Client
} }
} }
/// <summary>
/// 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'
/// </summary>
/// <param name="contentTypes">The Content-Type array to select from.</param>
/// <returns>The Content-Type header to use.</returns>
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'
}
/// <summary> /// <summary>
/// Select the Accept header's value from the given accepts array: /// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it; /// if JSON exists in the given array, use it;

View File

@ -154,7 +154,8 @@ namespace {{packageName}}.Api
{ {
{{#allParams}}{{#required}} {{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set // 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}} {{/required}}{{/allParams}}
var path_ = "{{path}}"; var path_ = "{{path}}";
@ -164,15 +165,21 @@ namespace {{packageName}}.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -185,11 +192,16 @@ namespace {{packageName}}.Api
{{/headerParams}} {{/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}}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}} {{/formParams}}
{{#bodyParam}}postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter {{#bodyParam}}if ({{paramName}}.GetType() != typeof(byte[]))
{{/bodyParam}} {
postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
}
else
{
postBody = {{paramName}}; // byte array
}{{/bodyParam}}
{{#authMethods}} {{#authMethods}}// authentication ({{name}}) required
// authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}} {{#isApiKey}}{{#isKeyInHeader}}
var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
if (!String.IsNullOrEmpty(apiKeyValue)) if (!String.IsNullOrEmpty(apiKeyValue))
@ -214,7 +226,9 @@ namespace {{packageName}}.Api
{{/authMethods}} {{/authMethods}}
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -261,15 +275,21 @@ namespace {{packageName}}.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -311,7 +331,9 @@ namespace {{packageName}}.Api
{{/authMethods}} {{/authMethods}}
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;

View File

@ -19,6 +19,49 @@
"http" "http"
], ],
"paths": { "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": { "/pet": {
"post": { "post": {
"tags": [ "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}": { "/pet/{petId}": {
"get": { "get": {
"tags": [ "tags": [

View File

@ -274,15 +274,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -293,7 +299,6 @@ namespace IO.Swagger.Api
// authentication (api_key) required // authentication (api_key) required
var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key");
@ -304,7 +309,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -345,15 +352,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -375,7 +388,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -417,15 +432,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -434,13 +455,21 @@ namespace IO.Swagger.Api
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 // 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; int statusCode = (int) response.StatusCode;
@ -483,15 +512,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -506,7 +541,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -541,7 +578,8 @@ namespace IO.Swagger.Api
{ {
// verify the required parameter 'orderId' is set // 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}"; var path_ = "/store/order/{orderId}";
@ -551,15 +589,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -574,7 +618,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -619,15 +665,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -642,7 +694,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -676,7 +730,8 @@ namespace IO.Swagger.Api
{ {
// verify the required parameter 'orderId' is set // 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}"; var path_ = "/store/order/{orderId}";
@ -686,15 +741,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -709,7 +770,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -753,15 +816,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -776,7 +845,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;

View File

@ -443,15 +443,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -460,13 +466,21 @@ namespace IO.Swagger.Api
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 // 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; int statusCode = (int) response.StatusCode;
@ -508,15 +522,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -531,7 +551,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -572,15 +594,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -589,13 +617,21 @@ namespace IO.Swagger.Api
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 // 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; int statusCode = (int) response.StatusCode;
@ -637,15 +673,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -660,7 +702,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -701,15 +745,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -718,13 +768,21 @@ namespace IO.Swagger.Api
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 // 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; int statusCode = (int) response.StatusCode;
@ -766,15 +824,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -789,7 +853,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -833,15 +899,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -857,7 +929,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -902,15 +976,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -926,7 +1006,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -965,15 +1047,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -987,7 +1075,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1027,15 +1117,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1049,7 +1145,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1084,7 +1182,8 @@ namespace IO.Swagger.Api
{ {
// verify the required parameter 'username' is set // 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}"; var path_ = "/user/{username}";
@ -1094,15 +1193,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1117,7 +1222,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1162,15 +1269,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1185,7 +1298,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1221,7 +1336,8 @@ namespace IO.Swagger.Api
{ {
// verify the required parameter 'username' is set // 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}"; var path_ = "/user/{username}";
@ -1231,15 +1347,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1249,13 +1371,21 @@ namespace IO.Swagger.Api
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 // 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; int statusCode = (int) response.StatusCode;
@ -1301,15 +1431,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1325,7 +1461,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1359,7 +1497,8 @@ namespace IO.Swagger.Api
{ {
// verify the required parameter 'username' is set // 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}"; var path_ = "/user/{username}";
@ -1369,15 +1508,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader); var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1392,7 +1537,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;
@ -1436,15 +1583,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>(); var fileParams = new Dictionary<String, FileParameter>();
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 // to determine the Accept header
String[] http_header_accepts = new String[] { String[] httpHeaderAccepts = new String[] {
"application/json", "application/xml" "application/json", "application/xml"
}; };
String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
if (http_header_accept != null) if (httpHeaderAccept != null)
headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); headerParams.Add("Accept", httpHeaderAccept);
// set "format" to json by default // set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
@ -1459,7 +1612,9 @@ namespace IO.Swagger.Api
// make the HTTP request // 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; int statusCode = (int) response.StatusCode;

View File

@ -77,9 +77,10 @@ namespace IO.Swagger.Client
// Creates and sets up a RestRequest prior to a call. // Creates and sets up a RestRequest prior to a call.
private RestRequest PrepareRequest( private RestRequest PrepareRequest(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = new RestRequest(path, method); var request = new RestRequest(path, method);
@ -103,8 +104,17 @@ namespace IO.Swagger.Client
foreach(var param in fileParams) foreach(var param in fileParams)
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType); request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
if (postBody != null) // http body (model) parameter if (postBody != null) // http body (model or byte[]) parameter
request.AddParameter("application/json", postBody, ParameterType.RequestBody); {
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; return request;
} }
@ -120,14 +130,18 @@ namespace IO.Swagger.Client
/// <param name="formParams">Form parameters.</param> /// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param> /// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param> /// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content Type of the request</param>
/// <returns>Object</returns> /// <returns>Object</returns>
public Object CallApi( public Object CallApi(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = PrepareRequest( 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); var response = RestClient.Execute(request);
return (Object) response; return (Object) response;
} }
@ -143,14 +157,17 @@ namespace IO.Swagger.Client
/// <param name="formParams">Form parameters.</param> /// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param> /// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param> /// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content type.</param>
/// <returns>The Task instance.</returns> /// <returns>The Task instance.</returns>
public async System.Threading.Tasks.Task<Object> CallApiAsync( public async System.Threading.Tasks.Task<Object> CallApiAsync(
String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, String path, RestSharp.Method method, Dictionary<String, String> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams) Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{ {
var request = PrepareRequest( 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); var response = await RestClient.ExecuteTaskAsync(request);
return (Object)response; return (Object)response;
} }
@ -230,6 +247,10 @@ namespace IO.Swagger.Client
{ {
return content; return content;
} }
else if (type == typeof(byte[])) // return byte array
{
return data;
}
if (type == typeof(Stream)) if (type == typeof(Stream))
{ {
@ -276,11 +297,11 @@ namespace IO.Swagger.Client
} }
/// <summary> /// <summary>
/// Serialize an object into JSON string. /// Serialize an input (model) into JSON string
/// </summary> /// </summary>
/// <param name="obj">Object.</param> /// <param name="obj">Object.</param>
/// <returns>JSON string.</returns> /// <returns>JSON string.</returns>
public string Serialize(object obj) public String Serialize(object obj)
{ {
try try
{ {
@ -292,6 +313,24 @@ namespace IO.Swagger.Client
} }
} }
/// <summary>
/// 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'
/// </summary>
/// <param name="contentTypes">The Content-Type array to select from.</param>
/// <returns>The Content-Type header to use.</returns>
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'
}
/// <summary> /// <summary>
/// Select the Accept header's value from the given accepts array: /// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it; /// if JSON exists in the given array, use it;

View File

@ -3,6 +3,10 @@
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<Files> <Files>
<File FileName="TestPet.cs" Line="182" Column="4" /> <File FileName="TestPet.cs" Line="182" Column="4" />
<File FileName="TestConfiguration.cs" Line="17" Column="7" />
<File FileName="TestPet.cs" Line="288" Column="11" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs" Line="1" Column="1" />
</Files> </Files>
<Pads> <Pads>
<Pad Id="MonoDevelop.NUnit.TestPad"> <Pad Id="MonoDevelop.NUnit.TestPad">
@ -18,4 +22,4 @@
<BreakpointStore /> <BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints> </MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches /> <MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties> </Properties>

View File

@ -14,6 +14,26 @@ namespace SwaggerClientTest.TestApiClient
Configuration.Default.DateTimeFormat = "o"; Configuration.Default.DateTimeFormat = "o";
} }
/// <summary>
/// Test SelectHeaderContentType
/// </summary>
[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));
}
/// <summary>
/// Test ParameterToString
/// </summary>
[Test ()] [Test ()]
public void TestParameterToString () public void TestParameterToString ()
{ {

View File

@ -15,7 +15,10 @@ namespace SwaggerClientTest.TestPet
{ {
public long petId = 11088; public long petId = 11088;
[SetUp] public void Init() /// <summary>
/// Create a Pet object
/// </summary>
private Pet createPet()
{ {
// create pet // create pet
Pet p = new Pet(); Pet p = new Pet();
@ -36,6 +39,24 @@ namespace SwaggerClientTest.TestPet
p.Category = category; p.Category = category;
p.PhotoUrls = photoUrls; p.PhotoUrls = photoUrls;
return p;
}
/// <summary>
/// Convert string to byte array
/// </summary>
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 // add pet before testing
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/"); PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
petApi.AddPet (p); petApi.AddPet (p);
@ -137,6 +158,35 @@ namespace SwaggerClientTest.TestPet
} }
/// <summary>
/// Test GetPetByIdWithByteArray
/// </summary>
[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<byte[]> (response, "Response is byte array");
}
/// <summary>
/// Test AddPetUsingByteArray
/// </summary>
[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);
}
/// <summary> /// <summary>
/// Test UpdatePetWithForm /// Test UpdatePetWithForm
/// </summary> /// </summary>