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

@@ -274,15 +274,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// authentication (api_key) required
var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key");
@@ -304,7 +309,9 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ 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
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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
{
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
{
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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;

View File

@@ -443,15 +443,21 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ 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
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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ 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
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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ 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
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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
{
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
{
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ 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
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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
{
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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 @@ namespace IO.Swagger.Api
var headerParams = new Dictionary<String, String>();
var formParams = new Dictionary<String, String>();
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
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 @@ namespace IO.Swagger.Api
// 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;

View File

@@ -77,9 +77,10 @@ namespace IO.Swagger.Client
// Creates and sets up a RestRequest prior to a call.
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, FileParameter> fileParams, Dictionary<String, String> pathParams)
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType)
{
var request = new RestRequest(path, method);
@@ -103,8 +104,17 @@ namespace IO.Swagger.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 IO.Swagger.Client
/// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content Type of the request</param>
/// <returns>Object</returns>
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, FileParameter> fileParams, Dictionary<String, String> pathParams)
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> 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 IO.Swagger.Client
/// <param name="formParams">Form parameters.</param>
/// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content type.</param>
/// <returns>The Task instance.</returns>
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, FileParameter> fileParams, Dictionary<String, String> pathParams)
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> 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 IO.Swagger.Client
{
return content;
}
else if (type == typeof(byte[])) // return byte array
{
return data;
}
if (type == typeof(Stream))
{
@@ -276,11 +297,11 @@ namespace IO.Swagger.Client
}
/// <summary>
/// Serialize an object into JSON string.
/// Serialize an input (model) into JSON string
/// </summary>
/// <param name="obj">Object.</param>
/// <returns>JSON string.</returns>
public string Serialize(object obj)
public String Serialize(object obj)
{
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>
/// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it;

View File

@@ -3,6 +3,10 @@
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<Files>
<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>
<Pads>
<Pad Id="MonoDevelop.NUnit.TestPad">
@@ -18,4 +22,4 @@
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>
</Properties>

View File

@@ -14,6 +14,26 @@ namespace SwaggerClientTest.TestApiClient
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 ()]
public void TestParameterToString ()
{

View File

@@ -15,7 +15,10 @@ namespace SwaggerClientTest.TestPet
{
public long petId = 11088;
[SetUp] public void Init()
/// <summary>
/// Create a Pet object
/// </summary>
private Pet createPet()
{
// create pet
Pet p = new Pet();
@@ -36,6 +39,24 @@ namespace SwaggerClientTest.TestPet
p.Category = category;
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
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
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>
/// Test UpdatePetWithForm
/// </summary>