forked from loafle/openapi-generator-original
better local variable naming for C#
This commit is contained in:
parent
d619b5e02e
commit
b077ff18a2
@ -47,9 +47,11 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
|||||||
setReservedWordsLowerCase(
|
setReservedWordsLowerCase(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
// local variable names in API methods (endpoints)
|
// local variable names in API methods (endpoints)
|
||||||
"path_", "pathParams", "queryParams", "headerParams", "formParams", "fileParams",
|
"localVarPath", "localVarPathParams", "localVarQueryParams", "localVarHeaderParams",
|
||||||
"postBody", "http_header_accepts", "http_header_accept", "apiKeyValue", "response",
|
"localVarFormParams", "localVarFileParams", "localVarStatusCode", "localVarResponse",
|
||||||
"statusCode",
|
"localVarPostBody", "localVarHttpHeaderAccepts", "localVarHttpHeaderAccept",
|
||||||
|
"localVarHttpContentTypes", "localVarHttpContentType",
|
||||||
|
"localVarStatusCode",
|
||||||
// C# reserved words
|
// C# reserved words
|
||||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked",
|
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked",
|
||||||
"class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else",
|
"class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else",
|
||||||
|
@ -154,8 +154,8 @@ namespace {{packageName}}.Api
|
|||||||
{{/allParams}}/// <returns>{{#returnType}}{{returnType}}{{/returnType}}</returns>
|
{{/allParams}}/// <returns>{{#returnType}}{{returnType}}{{/returnType}}</returns>
|
||||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
{
|
{
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> response = {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
return response.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
return localVarResponse.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -172,88 +172,88 @@ namespace {{packageName}}.Api
|
|||||||
throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}");
|
||||||
{{/required}}{{/allParams}}
|
{{/required}}{{/allParams}}
|
||||||
|
|
||||||
var path_ = "{{path}}";
|
var localVarPath = "{{path}}";
|
||||||
|
|
||||||
var pathParams = new Dictionary<String, String>();
|
var localVarPathParams = new Dictionary<String, String>();
|
||||||
var queryParams = new Dictionary<String, String>();
|
var localVarQueryParams = new Dictionary<String, String>();
|
||||||
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||||
var formParams = new Dictionary<String, String>();
|
var localVarFormParams = new Dictionary<String, String>();
|
||||||
var fileParams = new Dictionary<String, FileParameter>();
|
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||||
Object postBody = null;
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
String[] httpContentTypes = new String[] {
|
String[] localVarHttpContentTypes = new String[] {
|
||||||
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||||
};
|
};
|
||||||
String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);
|
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
||||||
|
|
||||||
// to determine the Accept header
|
// to determine the Accept header
|
||||||
String[] httpHeaderAccepts = new String[] {
|
String[] localVarHttpHeaderAccepts = new String[] {
|
||||||
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||||
};
|
};
|
||||||
String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
|
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||||
if (httpHeaderAccept != null)
|
if (localVarHttpHeaderAccept != null)
|
||||||
headerParams.Add("Accept", httpHeaderAccept);
|
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
||||||
|
|
||||||
// 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
|
||||||
pathParams.Add("format", "json");
|
localVarPathParams.Add("format", "json");
|
||||||
{{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
{{#pathParams}}if ({{paramName}} != null) localVarPathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter
|
{{#queryParams}}if ({{paramName}} != null) localVarQueryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
{{#headerParams}}if ({{paramName}} != null) localVarHeaderParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
||||||
{{/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}}localVarFileParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{#bodyParam}}if ({{paramName}}.GetType() != typeof(byte[]))
|
{{#bodyParam}}if ({{paramName}}.GetType() != typeof(byte[]))
|
||||||
{
|
{
|
||||||
postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
localVarPostBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
postBody = {{paramName}}; // byte array
|
localVarPostBody = {{paramName}}; // byte array
|
||||||
}{{/bodyParam}}
|
}{{/bodyParam}}
|
||||||
|
|
||||||
{{#authMethods}}// authentication ({{name}}) required
|
{{#authMethods}}// authentication ({{name}}) required
|
||||||
{{#isApiKey}}{{#isKeyInHeader}}
|
{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
headerParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarHeaderParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
||||||
}{{/isKeyInHeader}}{{#isKeyInQuery}}
|
}{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
queryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
||||||
}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
||||||
// http basic authentication required
|
// http basic authentication required
|
||||||
if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
|
if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
|
||||||
{
|
{
|
||||||
headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
localVarHeaderParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
||||||
}{{/isBasic}}{{#isOAuth}}
|
}{{/isBasic}}{{#isOAuth}}
|
||||||
// oauth required
|
// oauth required
|
||||||
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
{
|
{
|
||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
}{{/isOAuth}}
|
}{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams,
|
Method.{{httpMethod}}, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
pathParams, httpContentType);
|
localVarPathParams, localVarHttpContentType);
|
||||||
|
|
||||||
int statusCode = (int) response.StatusCode;
|
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
||||||
|
|
||||||
if (statusCode >= 400)
|
if (localVarStatusCode >= 400)
|
||||||
throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
|
throw new ApiException (localVarStatusCode, "Error calling {{operationId}}: " + localVarResponse.Content, localVarResponse.Content);
|
||||||
else if (statusCode == 0)
|
else if (localVarStatusCode == 0)
|
||||||
throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException (localVarStatusCode, "Error calling {{operationId}}: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
|
||||||
|
|
||||||
{{#returnType}}return new ApiResponse<{{{returnType}}}>(statusCode,
|
{{#returnType}}return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
||||||
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));{{/returnType}}
|
({{{returnType}}}) Configuration.ApiClient.Deserialize(localVarResponse, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));{{/returnType}}
|
||||||
{{^returnType}}return new ApiResponse<Object>(statusCode,
|
{{^returnType}}return new ApiResponse<Object>(localVarStatusCode,
|
||||||
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);{{/returnType}}
|
null);{{/returnType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,8 +266,8 @@ namespace {{packageName}}.Api
|
|||||||
{{/allParams}}/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
{{/allParams}}/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
{
|
{
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> response = await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
return response.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,83 +283,89 @@ namespace {{packageName}}.Api
|
|||||||
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 {{operationId}}");
|
||||||
{{/required}}{{/allParams}}
|
{{/required}}{{/allParams}}
|
||||||
|
|
||||||
var path_ = "{{path}}";
|
var localVarPath = "{{path}}";
|
||||||
|
|
||||||
var pathParams = new Dictionary<String, String>();
|
var localVarPathParams = new Dictionary<String, String>();
|
||||||
var queryParams = new Dictionary<String, String>();
|
var localVarQueryParams = new Dictionary<String, String>();
|
||||||
var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||||
var formParams = new Dictionary<String, String>();
|
var localVarFormParams = new Dictionary<String, String>();
|
||||||
var fileParams = new Dictionary<String, FileParameter>();
|
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||||
Object postBody = null;
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
String[] httpContentTypes = new String[] {
|
String[] localVarHttpContentTypes = new String[] {
|
||||||
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||||
};
|
};
|
||||||
String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);
|
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
||||||
|
|
||||||
// to determine the Accept header
|
// to determine the Accept header
|
||||||
String[] httpHeaderAccepts = new String[] {
|
String[] localVarHttpHeaderAccepts = new String[] {
|
||||||
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||||
};
|
};
|
||||||
String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
|
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||||
if (httpHeaderAccept != null)
|
if (localVarHttpHeaderAccept != null)
|
||||||
headerParams.Add("Accept", httpHeaderAccept);
|
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
||||||
|
|
||||||
// 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
|
||||||
pathParams.Add("format", "json");
|
localVarPathParams.Add("format", "json");
|
||||||
{{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
{{#pathParams}}if ({{paramName}} != null) localVarPathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter
|
{{#queryParams}}if ({{paramName}} != null) localVarQueryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
{{#headerParams}}if ({{paramName}} != null) localVarHeaderParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter
|
||||||
{{/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}}localVarFileParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.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}}
|
{
|
||||||
|
localVarPostBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
localVarPostBody = {{paramName}}; // byte array
|
||||||
|
}{{/bodyParam}}
|
||||||
|
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
// authentication ({{name}}) required
|
// authentication ({{name}}) required
|
||||||
{{#isApiKey}}{{#isKeyInHeader}}
|
{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
headerParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarHeaderParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
||||||
}{{/isKeyInHeader}}{{#isKeyInQuery}}
|
}{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
queryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
||||||
}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
||||||
// http basic authentication required
|
// http basic authentication required
|
||||||
if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
|
if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
|
||||||
{
|
{
|
||||||
headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
localVarHeaderParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
||||||
}{{/isBasic}}{{#isOAuth}}
|
}{{/isBasic}}{{#isOAuth}}
|
||||||
// oauth required
|
// oauth required
|
||||||
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
{
|
{
|
||||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
}{{/isOAuth}}
|
}{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_,
|
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
||||||
Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams,
|
Method.{{httpMethod}}, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
pathParams, httpContentType);
|
localVarPathParams, localVarHttpContentType);
|
||||||
|
|
||||||
int statusCode = (int) response.StatusCode;
|
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
||||||
|
|
||||||
if (statusCode >= 400)
|
if (localVarStatusCode >= 400)
|
||||||
throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
|
throw new ApiException (localVarStatusCode, "Error calling {{operationId}}: " + localVarResponse.Content, localVarResponse.Content);
|
||||||
else if (statusCode == 0)
|
else if (localVarStatusCode == 0)
|
||||||
throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException (localVarStatusCode, "Error calling {{operationId}}: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
|
||||||
|
|
||||||
{{#returnType}}return new ApiResponse<{{{returnType}}}>(statusCode,
|
{{#returnType}}return new ApiResponse<{{{returnType}}}>(localVarStatusCode,
|
||||||
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));{{/returnType}}
|
({{{returnType}}}) Configuration.ApiClient.Deserialize(localVarResponse, typeof({{#returnContainer}}{{{returnContainer}}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}})));{{/returnType}}
|
||||||
{{^returnType}}return new ApiResponse<Object>(statusCode,
|
{{^returnType}}return new ApiResponse<Object>(localVarStatusCode,
|
||||||
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);{{/returnType}}
|
null);{{/returnType}}
|
||||||
}{{/supportsAsync}}
|
}{{/supportsAsync}}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -46,6 +46,19 @@ namespace IO.Swagger.Test
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test FindOrdersByStatus
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void FindOrdersByStatusTest()
|
||||||
|
{
|
||||||
|
// TODO: add unit test for the method 'FindOrdersByStatus'
|
||||||
|
string status = null; // TODO: replace null with proper value
|
||||||
|
|
||||||
|
var response = instance.FindOrdersByStatus(status);
|
||||||
|
Assert.IsInstanceOf<List<Order>> (response, "response is List<Order>");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test GetInventory
|
/// Test GetInventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user