diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index e95f9c71c4..be8b4b7478 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -128,6 +128,8 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiClient.cs")); supportingFiles.add(new SupportingFile("ApiException.mustache", sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiException.cs")); + supportingFiles.add(new SupportingFile("ApiResponse.mustache", + sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiResponse.cs")); supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll")); supportingFiles.add(new SupportingFile("RestSharp.dll", "bin", "RestSharp.dll")); supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat")); diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index bac6fd02a6..5dda78a41a 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -18,23 +18,23 @@ namespace {{packageName}}.Client /// public class ApiClient { - private readonly Dictionary _defaultHeaderMap = new Dictionary(); - /// /// Initializes a new instance of the class. /// /// The base path. public ApiClient(String basePath="{{basePath}}") { - BasePath = basePath; - RestClient = new RestClient(BasePath); + if (String.IsNullOrEmpty(basePath)) + throw new ArgumentException("basePath cannot be empty"); + + RestClient = new RestClient(basePath); } - + /// - /// Gets or sets the base path. + /// Gets or sets the default API client for making HTTP calls. /// - /// The base path - public string BasePath { get; set; } + /// The default API client. + public static ApiClient Default = new ApiClient(); /// /// Gets or sets the RestClient. @@ -42,38 +42,14 @@ namespace {{packageName}}.Client /// An instance of the RestClient public RestClient RestClient { get; set; } - /// - /// Gets the default header. - /// - public Dictionary DefaultHeader - { - get { return _defaultHeaderMap; } - } - - /// - /// Gets the status code of the previous request - /// - public int StatusCode { get; private set; } - - /// - /// Gets the response headers of the previous request - /// - public Dictionary ResponseHeaders { get; private set; } - // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = new RestRequest(path, method); - UpdateParamsForAuth(queryParams, headerParams, authSettings); - - // add default header, if any - foreach(var defaultHeader in _defaultHeaderMap) - request.AddHeader(defaultHeader.Key, defaultHeader.Value); - // add path parameter, if any foreach(var param in pathParams) request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); @@ -111,18 +87,15 @@ namespace {{packageName}}.Client /// Form parameters. /// File parameters. /// Path parameters. - /// Authentication settings. /// Object public Object CallApi( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = RestClient.Execute(request); - StatusCode = (int) response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object) response; } @@ -137,32 +110,18 @@ namespace {{packageName}}.Client /// Form parameters. /// File parameters. /// Path parameters. - /// Authentication settings. /// The Task instance. public async System.Threading.Tasks.Task CallApiAsync( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = await RestClient.ExecuteTaskAsync(request); - StatusCode = (int)response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object)response; } - /// - /// Add default header. - /// - /// Header field name. - /// Header field value. - /// - public void AddDefaultHeader(string key, string value) - { - _defaultHeaderMap.Add(key, value); - } - /// /// Escape string (url-encoded). /// @@ -286,68 +245,6 @@ namespace {{packageName}}.Client } } - /// - /// Get the API key with prefix. - /// - /// API key identifier (authentication scheme). - /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) - { - var apiKeyValue = ""; - Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); - var apiKeyPrefix = ""; - if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) - return apiKeyPrefix + " " + apiKeyValue; - else - return apiKeyValue; - } - - /// - /// Update parameters based on authentication. - /// - /// Query parameters. - /// Header parameters. - /// Authentication settings. - public void UpdateParamsForAuth(Dictionary queryParams, Dictionary headerParams, string[] authSettings) - { - if (authSettings == null || authSettings.Length == 0) - return; - - foreach (string auth in authSettings) - { - // determine which one to use - switch(auth) - { - {{#authMethods}} - case "{{name}}": - {{#isApiKey}}{{#isKeyInHeader}} - var apiKeyValue = GetApiKeyWithPrefix("{{keyParamName}}"); - if (!String.IsNullOrEmpty(apiKeyValue)) - { - headerParams["{{keyParamName}}"] = apiKeyValue; - }{{/isKeyInHeader}}{{#isKeyInQuery}} - var apiKeyValue = GetApiKeyWithPrefix("{{keyParamName}}"); - if (!String.IsNullOrEmpty(apiKeyValue)) - { - queryParams["{{keyParamName}}"] = apiKeyValue; - }{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} - if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) - { - headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password); - }{{/isBasic}}{{#isOAuth}} - if (!String.IsNullOrEmpty(Configuration.AccessToken)) - { - headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; - }{{/isOAuth}} - break; - {{/authMethods}} - default: - //show warning about security definition not found - break; - } - } - } - /// /// Select the Accept header's value from the given accepts array: /// if JSON exists in the given array, use it; diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache index 68e3a03276..09dbd0dce5 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache @@ -1,47 +1,50 @@ using System; -namespace {{packageName}}.Client { - /// - /// API Exception - /// - public class ApiException : Exception { - /// - /// Gets or sets the error code (HTTP status code) - /// - /// The error code (HTTP status code). - public int ErrorCode { get; set; } - - /// - /// Gets or sets the error content (body json object) - /// - /// The error content (Http response body). - public dynamic ErrorContent { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - public ApiException() {} - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - public ApiException(int errorCode, string message) : base(message) { - this.ErrorCode = errorCode; - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - /// Error content. - public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { - this.ErrorCode = errorCode; - this.ErrorContent = errorContent; - } - - } - +namespace {{packageName}}.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// Gets or sets the error code (HTTP status code) + /// + /// The error code (HTTP status code). + public int ErrorCode { get; set; } + + /// + /// Gets or sets the error content (body json object) + /// + /// The error content (Http response body). + public dynamic ErrorContent { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + public ApiException() {} + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + public ApiException(int errorCode, string message) : base(message) + { + this.ErrorCode = errorCode; + } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + /// Error content. + public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) + { + this.ErrorCode = errorCode; + this.ErrorContent = errorContent; + } + } + } diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiResponse.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiResponse.mustache new file mode 100644 index 0000000000..32816110a1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiResponse.mustache @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; + +namespace {{packageName}}.Client +{ + /// + /// API Response + /// + public class ApiResponse + { + /// + /// Gets or sets the status code (HTTP status code) + /// + /// The status code. + public int StatusCode { get; private set; } + + /// + /// Gets or sets the HTTP headers + /// + /// HTTP headers + public IDictionary Headers { get; private set; } + + /// + /// Gets or sets the data (parsed HTTP body) + /// + /// The data. + public T Data { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + /// Data (parsed HTTP body) + public ApiResponse(int statusCode, IDictionary headers, T data) + { + this.StatusCode= statusCode; + this.Headers = headers; + this.Data = data; + } + + } + +} diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index 79b20c6062..46dde35d8d 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -12,6 +12,17 @@ namespace {{packageName}}.Client /// public class Configuration { + /// + /// Initializes a new instance of the Configuration class. + /// + /// Api client. + public Configuration(ApiClient apiClient=null) + { + if (apiClient == null) + ApiClient = ApiClient.Default; + else + ApiClient = apiClient; + } /// /// Version of the package. @@ -19,41 +30,84 @@ namespace {{packageName}}.Client /// Version of the package. public const string Version = "{{packageVersion}}"; + /// + /// Gets or sets the default Configuration. + /// + /// Configuration. + public static Configuration Default = new Configuration(); + /// /// Gets or sets the default API client for making HTTP calls. /// /// The API client. - public static ApiClient DefaultApiClient = new ApiClient(); - + public ApiClient ApiClient; + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } + /// /// Gets or sets the username (HTTP basic authentication). /// /// The username. - public static String Username { get; set; } + public String Username { get; set; } /// /// Gets or sets the password (HTTP basic authentication). /// /// The password. - public static String Password { get; set; } + public String Password { get; set; } /// /// Gets or sets the access token for OAuth2 authentication. /// /// The access token. - public static String AccessToken { get; set; } + public String AccessToken { get; set; } /// /// Gets or sets the API key based on the authentication name. /// /// The API key. - public static Dictionary ApiKey = new Dictionary(); + public Dictionary ApiKey = new Dictionary(); /// /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. /// /// The prefix of the API key. - public static Dictionary ApiKeyPrefix = new Dictionary(); + public Dictionary ApiKeyPrefix = new Dictionary(); + + /// + /// Get the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. + public string GetApiKeyWithPrefix (string apiKeyIdentifier) + { + var apiKeyValue = ""; + ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); + var apiKeyPrefix = ""; + if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) + return apiKeyPrefix + " " + apiKeyValue; + else + return apiKeyValue; + } private static string _tempFolderPath = Path.GetTempPath(); diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 11d2ffe81b..51f8b3f939 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Linq; using RestSharp; using {{packageName}}.Client; {{#hasImport}}using {{packageName}}.Model; @@ -22,7 +23,7 @@ namespace {{packageName}}.Api /// {{notes}} /// {{#allParams}}/// {{description}} - {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} + {{/allParams}}/// {{#returnType}}{{returnType}}{{/returnType}} {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); /// @@ -32,8 +33,28 @@ namespace {{packageName}}.Api /// {{notes}} /// {{#allParams}}/// {{description}} - {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} + {{/allParams}}/// ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}} + ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + /// + /// {{summary}} + /// + /// + /// {{notes}} + /// + {{#allParams}}/// {{description}} + {{/allParams}}/// Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}} {{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + /// + /// {{summary}} + /// + /// + /// {{notes}} + /// + {{#allParams}}/// {{description}} + {{/allParams}}/// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} + System.Threading.Tasks.Task> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/operation}} } @@ -42,60 +63,94 @@ namespace {{packageName}}.Api /// public class {{classname}} : I{{classname}} { - /// - /// Initializes a new instance of the class. - /// - /// an instance of ApiClient (optional) - /// - public {{classname}}(ApiClient apiClient = null) - { - if (apiClient == null) // use the default one in Configuration - this.ApiClient = Configuration.DefaultApiClient; - else - this.ApiClient = apiClient; - } - /// /// Initializes a new instance of the class. /// /// public {{classname}}(String basePath) { - this.ApiClient = new ApiClient(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// - /// Sets the base path of the API client. + /// Initializes a new instance of the class + /// using Configuration object /// - /// The base path - /// The base path - public void SetBasePath(String basePath) + /// An instance of Configuration + /// + public {{classname}}(Configuration configuration = null) { - this.ApiClient.BasePath = basePath; + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; } - + /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.ApiClient.BasePath; + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing } /// - /// Gets or sets the API client. + /// Gets or sets the configuration object /// - /// An instance of the ApiClient - public ApiClient ApiClient {get; set;} - + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public Dictionary DefaultHeader() + { + return this.Configuration.DefaultHeader; + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + {{#operation}} /// /// {{summary}} {{notes}} /// {{#allParams}}/// {{description}} - {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} + {{/allParams}}/// {{#returnType}}{{returnType}}{{/returnType}} 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}}); + return response.Data;{{/returnType}}{{^returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}} + } + + /// + /// {{summary}} {{notes}} + /// + {{#allParams}}/// {{description}} + {{/allParams}}/// ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}} + public ApiResponse<{{#returnType}} {{{returnType}}} {{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set @@ -106,7 +161,7 @@ namespace {{packageName}}.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -115,44 +170,85 @@ namespace {{packageName}}.Api String[] http_header_accepts = new String[] { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - {{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // path parameter + {{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter {{/pathParams}} - {{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter + {{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter {{/queryParams}} - {{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter + {{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter {{/headerParams}} - {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", 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}} - {{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter + {{#bodyParam}}postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter {{/bodyParam}} - - // authentication setting, if any - String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; + + {{#authMethods}} + // authentication ({{name}}) required + {{#isApiKey}}{{#isKeyInHeader}} + var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["{{keyParamName}}"] = apiKeyValue; + }{{/isKeyInHeader}}{{#isKeyInQuery}} + var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + queryParams["{{keyParamName}}"] = apiKeyValue; + }{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} + // http basic authentication required + if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) + { + headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password); + }{{/isBasic}}{{#isOAuth}} + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + }{{/isOAuth}} + {{/authMethods}} // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage); - {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}return;{{/returnType}} + {{#returnType}}return new ApiResponse<{{{returnType}}}>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + ({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}})));{{/returnType}} + {{^returnType}}return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null);{{/returnType}} } /// /// {{summary}} {{notes}} /// {{#allParams}}/// {{description}} - {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} + {{/allParams}}/// Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}} {{#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}}); + return response.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}} + + } + + /// + /// {{summary}} {{notes}} + /// + {{#allParams}}/// {{description}} + {{/allParams}}/// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} + public async System.Threading.Tasks.Task> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}"); @@ -171,34 +267,65 @@ namespace {{packageName}}.Api String[] http_header_accepts = new String[] { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - {{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // path parameter + {{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // path parameter {{/pathParams}} - {{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter + {{#queryParams}}if ({{paramName}} != null) queryParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // query parameter {{/queryParams}} - {{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter + {{#headerParams}}if ({{paramName}} != null) headerParams.Add("{{baseName}}", Configuration.ApiClient.ParameterToString({{paramName}})); // header parameter {{/headerParams}} - {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", 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}} - {{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter + {{#bodyParam}}postBody = Configuration.ApiClient.Serialize({{paramName}}); // http body (model) parameter {{/bodyParam}} - - // authentication setting, if any - String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content); - {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}} - return;{{/returnType}} + {{#authMethods}} + // authentication ({{name}}) required + {{#isApiKey}}{{#isKeyInHeader}} + var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["{{keyParamName}}"] = apiKeyValue; + }{{/isKeyInHeader}}{{#isKeyInQuery}} + var apiKeyValue = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + queryParams["{{keyParamName}}"] = apiKeyValue; + }{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} + // http basic authentication required + if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) + { + headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password); + }{{/isBasic}}{{#isOAuth}} + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + }{{/isOAuth}} + {{/authMethods}} + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage); + + {{#returnType}}return new ApiResponse<{{{returnType}}}>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + ({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}})));{{/returnType}} + {{^returnType}}return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null);{{/returnType}} } {{/operation}} } diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index 7ab48dc56e..7b7f1a6aea 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -83,7 +83,7 @@ namespace {{packageName}}.Model this.{{name}} == other.{{name}} || this.{{name}} != null && this.{{name}}.SequenceEqual(other.{{name}}) - ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}; + ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}}; } /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 8344304ee7..ba58eeac9e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Linq; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; @@ -31,8 +32,28 @@ namespace IO.Swagger.Api /// /// /// Pet object that needs to be added to the store - /// + /// ApiResponse of Object(void) + ApiResponse UpdatePetWithHttpInfo (Pet body = null); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Task of void System.Threading.Tasks.Task UpdatePetAsync (Pet body = null); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdatePetAsyncWithHttpInfo (Pet body = null); /// /// Add a new pet to the store @@ -51,8 +72,28 @@ namespace IO.Swagger.Api /// /// /// Pet object that needs to be added to the store - /// + /// ApiResponse of Object(void) + ApiResponse AddPetWithHttpInfo (Pet body = null); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Task of void System.Threading.Tasks.Task AddPetAsync (Pet body = null); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Task of ApiResponse + System.Threading.Tasks.Task> AddPetAsyncWithHttpInfo (Pet body = null); /// /// Finds Pets by status @@ -61,7 +102,7 @@ namespace IO.Swagger.Api /// Multiple status values can be provided with comma seperated strings /// /// Status values that need to be considered for filter - /// + /// List<Pet> List FindPetsByStatus (List status = null); /// @@ -71,8 +112,28 @@ namespace IO.Swagger.Api /// Multiple status values can be provided with comma seperated strings /// /// Status values that need to be considered for filter - /// + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByStatusWithHttpInfo (List status = null); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// Task of List<Pet> System.Threading.Tasks.Task> FindPetsByStatusAsync (List status = null); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// Task of ApiResponse (List<Pet>) + System.Threading.Tasks.Task>> FindPetsByStatusAsyncWithHttpInfo (List status = null); /// /// Finds Pets by tags @@ -81,7 +142,7 @@ namespace IO.Swagger.Api /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// /// Tags to filter by - /// + /// List<Pet> List FindPetsByTags (List tags = null); /// @@ -91,8 +152,28 @@ namespace IO.Swagger.Api /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// /// Tags to filter by - /// + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByTagsWithHttpInfo (List tags = null); + + /// + /// Finds Pets by tags + /// + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Task of List<Pet> System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags = null); + + /// + /// Finds Pets by tags + /// + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Task of ApiResponse (List<Pet>) + System.Threading.Tasks.Task>> FindPetsByTagsAsyncWithHttpInfo (List tags = null); /// /// Find pet by ID @@ -111,8 +192,28 @@ namespace IO.Swagger.Api /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// /// ID of pet that needs to be fetched - /// Pet + /// ApiResponse of Pet + ApiResponse GetPetByIdWithHttpInfo (long? petId); + + /// + /// Find pet by ID + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of Pet System.Threading.Tasks.Task GetPetByIdAsync (long? petId); + + /// + /// Find pet by ID + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (Pet) + System.Threading.Tasks.Task> GetPetByIdAsyncWithHttpInfo (long? petId); /// /// Updates a pet in the store with form data @@ -135,8 +236,32 @@ namespace IO.Swagger.Api /// ID of pet that needs to be updated /// Updated name of the pet /// Updated status of the pet - /// + /// ApiResponse of Object(void) + ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string name = null, string status = null); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Task of void System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdatePetWithFormAsyncWithHttpInfo (string petId, string name = null, string status = null); /// /// Deletes a pet @@ -157,8 +282,30 @@ namespace IO.Swagger.Api /// /// Pet id to delete /// - /// + /// ApiResponse of Object(void) + ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// + /// Task of void System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// + /// Task of ApiResponse + System.Threading.Tasks.Task> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null); /// /// uploads an image @@ -181,8 +328,32 @@ namespace IO.Swagger.Api /// ID of pet to update /// Additional data to pass to server /// file to upload - /// + /// ApiResponse of Object(void) + ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// Task of void System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// Task of ApiResponse + System.Threading.Tasks.Task> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); } @@ -191,60 +362,93 @@ namespace IO.Swagger.Api /// public class PetApi : IPetApi { - /// - /// Initializes a new instance of the class. - /// - /// an instance of ApiClient (optional) - /// - public PetApi(ApiClient apiClient = null) - { - if (apiClient == null) // use the default one in Configuration - this.ApiClient = Configuration.DefaultApiClient; - else - this.ApiClient = apiClient; - } - /// /// Initializes a new instance of the class. /// /// public PetApi(String basePath) { - this.ApiClient = new ApiClient(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// - /// Sets the base path of the API client. + /// Initializes a new instance of the class + /// using Configuration object /// - /// The base path - /// The base path - public void SetBasePath(String basePath) + /// An instance of Configuration + /// + public PetApi(Configuration configuration = null) { - this.ApiClient.BasePath = basePath; + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; } - + /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.ApiClient.BasePath; + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing } /// - /// Gets or sets the API client. + /// Gets or sets the configuration object /// - /// An instance of the ApiClient - public ApiClient ApiClient {get; set;} - + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public Dictionary DefaultHeader() + { + return this.Configuration.DefaultHeader; + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + /// /// Update an existing pet /// /// Pet object that needs to be added to the store - /// + /// public void UpdatePet (Pet body = null) + { + UpdatePetWithHttpInfo(body); + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + public ApiResponse UpdatePetWithHttpInfo (Pet body = null) { @@ -252,7 +456,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -261,9 +465,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -272,29 +476,52 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdatePet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Update an existing pet /// /// Pet object that needs to be added to the store - /// + /// Task of void public async System.Threading.Tasks.Task UpdatePetAsync (Pet body = null) + { + await UpdatePetAsyncWithHttpInfo(body); + + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// Task of ApiResponse + public async System.Threading.Tasks.Task> UpdatePetAsyncWithHttpInfo (Pet body = null) { @@ -311,9 +538,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -322,27 +549,51 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); - return; + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdatePet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Add a new pet to the store /// /// Pet object that needs to be added to the store - /// + /// public void AddPet (Pet body = null) + { + AddPetWithHttpInfo(body); + } + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + public ApiResponse AddPetWithHttpInfo (Pet body = null) { @@ -350,7 +601,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -359,9 +610,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -370,29 +621,52 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling AddPet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Add a new pet to the store /// /// Pet object that needs to be added to the store - /// + /// Task of void public async System.Threading.Tasks.Task AddPetAsync (Pet body = null) + { + await AddPetAsyncWithHttpInfo(body); + + } + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// Task of ApiResponse + public async System.Threading.Tasks.Task> AddPetAsyncWithHttpInfo (Pet body = null) { @@ -409,9 +683,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -420,27 +694,52 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); - return; + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling AddPet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Finds Pets by status Multiple status values can be provided with comma seperated strings /// /// Status values that need to be considered for filter - /// + /// List<Pet> public List FindPetsByStatus (List status = null) + { + ApiResponse> response = FindPetsByStatusWithHttpInfo(status); + return response.Data; + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// ApiResponse of List<Pet> + public ApiResponse< List > FindPetsByStatusWithHttpInfo (List status = null) { @@ -448,7 +747,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -457,40 +756,64 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (status != null) queryParams.Add("status", ApiClient.ParameterToString(status)); // query parameter + if (status != null) queryParams.Add("status", Configuration.ApiClient.ParameterToString(status)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage); - return (List) ApiClient.Deserialize(response, typeof(List)); + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(response, typeof(List))); + } /// /// Finds Pets by status Multiple status values can be provided with comma seperated strings /// /// Status values that need to be considered for filter - /// + /// Task of List<Pet> public async System.Threading.Tasks.Task> FindPetsByStatusAsync (List status = null) + { + ApiResponse> response = await FindPetsByStatusAsyncWithHttpInfo(status); + return response.Data; + + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// Task of ApiResponse (List<Pet>) + public async System.Threading.Tasks.Task>> FindPetsByStatusAsyncWithHttpInfo (List status = null) { @@ -507,37 +830,63 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (status != null) queryParams.Add("status", ApiClient.ParameterToString(status)); // query parameter + if (status != null) queryParams.Add("status", Configuration.ApiClient.ParameterToString(status)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); - return (List) ApiClient.Deserialize(response, typeof(List)); + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(response, typeof(List))); + } /// /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// /// Tags to filter by - /// + /// List<Pet> public List FindPetsByTags (List tags = null) + { + ApiResponse> response = FindPetsByTagsWithHttpInfo(tags); + return response.Data; + } + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// ApiResponse of List<Pet> + public ApiResponse< List > FindPetsByTagsWithHttpInfo (List tags = null) { @@ -545,7 +894,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -554,40 +903,64 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (tags != null) queryParams.Add("tags", ApiClient.ParameterToString(tags)); // query parameter + if (tags != null) queryParams.Add("tags", Configuration.ApiClient.ParameterToString(tags)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage); - return (List) ApiClient.Deserialize(response, typeof(List)); + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(response, typeof(List))); + } /// /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// /// Tags to filter by - /// + /// Task of List<Pet> public async System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags = null) + { + ApiResponse> response = await FindPetsByTagsAsyncWithHttpInfo(tags); + return response.Data; + + } + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Task of ApiResponse (List<Pet>) + public async System.Threading.Tasks.Task>> FindPetsByTagsAsyncWithHttpInfo (List tags = null) { @@ -604,37 +977,63 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (tags != null) queryParams.Add("tags", ApiClient.ParameterToString(tags)); // query parameter + if (tags != null) queryParams.Add("tags", Configuration.ApiClient.ParameterToString(tags)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); - return (List) ApiClient.Deserialize(response, typeof(List)); + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (List) Configuration.ApiClient.Deserialize(response, typeof(List))); + } /// /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// /// ID of pet that needs to be fetched - /// Pet + /// Pet public Pet GetPetById (long? petId) + { + ApiResponse response = GetPetByIdWithHttpInfo(petId); + return response.Data; + } + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of Pet + public ApiResponse< Pet > GetPetByIdWithHttpInfo (long? petId) { // verify the required parameter 'petId' is set @@ -645,7 +1044,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -654,40 +1053,64 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { "api_key" }; + + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetPetById: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage); - return (Pet) ApiClient.Deserialize(response, typeof(Pet)); + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet))); + } /// /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// /// ID of pet that needs to be fetched - /// Pet + /// Task of Pet public async System.Threading.Tasks.Task GetPetByIdAsync (long? petId) + { + ApiResponse response = await GetPetByIdAsyncWithHttpInfo(petId); + return response.Data; + + } + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (Pet) + public async System.Threading.Tasks.Task> GetPetByIdAsyncWithHttpInfo (long? petId) { // verify the required parameter 'petId' is set if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById"); @@ -706,29 +1129,44 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { "api_key" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); - return (Pet) ApiClient.Deserialize(response, typeof(Pet)); + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetPetById: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet))); + } /// @@ -737,8 +1175,20 @@ namespace IO.Swagger.Api /// ID of pet that needs to be updated /// Updated name of the pet /// Updated status of the pet - /// + /// public void UpdatePetWithForm (string petId, string name = null, string status = null) + { + UpdatePetWithFormWithHttpInfo(petId, name, status); + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// ApiResponse of Object(void) + public ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string name = null, string status = null) { // verify the required parameter 'petId' is set @@ -749,7 +1199,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -758,34 +1208,46 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (name != null) formParams.Add("name", ApiClient.ParameterToString(name)); // form parameter - if (status != null) formParams.Add("status", ApiClient.ParameterToString(status)); // form parameter + if (name != null) formParams.Add("name", Configuration.ApiClient.ParameterToString(name)); // form parameter + if (status != null) formParams.Add("status", Configuration.ApiClient.ParameterToString(status)); // form parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -794,8 +1256,21 @@ namespace IO.Swagger.Api /// ID of pet that needs to be updated /// Updated name of the pet /// Updated status of the pet - /// + /// Task of void public async System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null) + { + await UpdatePetWithFormAsyncWithHttpInfo(petId, name, status); + + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Task of ApiResponse + public async System.Threading.Tasks.Task> UpdatePetWithFormAsyncWithHttpInfo (string petId, string name = null, string status = null) { // verify the required parameter 'petId' is set if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm"); @@ -814,32 +1289,46 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (name != null) formParams.Add("name", ApiClient.ParameterToString(name)); // form parameter - if (status != null) formParams.Add("status", ApiClient.ParameterToString(status)); // form parameter + if (name != null) formParams.Add("name", Configuration.ApiClient.ParameterToString(name)); // form parameter + if (status != null) formParams.Add("status", Configuration.ApiClient.ParameterToString(status)); // form parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); - return; + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -847,8 +1336,19 @@ namespace IO.Swagger.Api /// /// Pet id to delete /// - /// + /// public void DeletePet (long? petId, string apiKey = null) + { + DeletePetWithHttpInfo(petId, apiKey); + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// ApiResponse of Object(void) + public ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null) { // verify the required parameter 'petId' is set @@ -859,7 +1359,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -868,33 +1368,45 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (apiKey != null) headerParams.Add("api_key", ApiClient.ParameterToString(apiKey)); // header parameter + if (apiKey != null) headerParams.Add("api_key", Configuration.ApiClient.ParameterToString(apiKey)); // header parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeletePet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -902,8 +1414,20 @@ namespace IO.Swagger.Api /// /// Pet id to delete /// - /// + /// Task of void public async System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null) + { + await DeletePetAsyncWithHttpInfo(petId, apiKey); + + } + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// + /// Task of ApiResponse + public async System.Threading.Tasks.Task> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null) { // verify the required parameter 'petId' is set if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet"); @@ -922,31 +1446,45 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (apiKey != null) headerParams.Add("api_key", ApiClient.ParameterToString(apiKey)); // header parameter + if (apiKey != null) headerParams.Add("api_key", Configuration.ApiClient.ParameterToString(apiKey)); // header parameter - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); - return; + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeletePet: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -955,8 +1493,20 @@ namespace IO.Swagger.Api /// ID of pet to update /// Additional data to pass to server /// file to upload - /// + /// public void UploadFile (long? petId, string additionalMetadata = null, Stream file = null) + { + UploadFileWithHttpInfo(petId, additionalMetadata, file); + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// ApiResponse of Object(void) + public ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null) { // verify the required parameter 'petId' is set @@ -967,7 +1517,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -976,34 +1526,46 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (additionalMetadata != null) formParams.Add("additionalMetadata", ApiClient.ParameterToString(additionalMetadata)); // form parameter - if (file != null) fileParams.Add("file", ApiClient.ParameterToFile("file", file)); + if (additionalMetadata != null) formParams.Add("additionalMetadata", Configuration.ApiClient.ParameterToString(additionalMetadata)); // form parameter + if (file != null) fileParams.Add("file", Configuration.ApiClient.ParameterToFile("file", file)); - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + + + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UploadFile: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -1012,8 +1574,21 @@ namespace IO.Swagger.Api /// ID of pet to update /// Additional data to pass to server /// file to upload - /// + /// Task of void public async System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null) + { + await UploadFileAsyncWithHttpInfo(petId, additionalMetadata, file); + + } + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// Task of ApiResponse + public async System.Threading.Tasks.Task> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null) { // verify the required parameter 'petId' is set if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile"); @@ -1032,32 +1607,46 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter + if (petId != null) pathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter - if (additionalMetadata != null) formParams.Add("additionalMetadata", ApiClient.ParameterToString(additionalMetadata)); // form parameter - if (file != null) fileParams.Add("file", ApiClient.ParameterToFile("file", file)); + if (additionalMetadata != null) formParams.Add("additionalMetadata", Configuration.ApiClient.ParameterToString(additionalMetadata)); // form parameter + if (file != null) fileParams.Add("file", Configuration.ApiClient.ParameterToFile("file", file)); - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); - return; + // authentication (petstore_auth) required + + // oauth required + if (!String.IsNullOrEmpty(Configuration.AccessToken)) + { + headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UploadFile: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index 952987dfad..a9e9d6e9b7 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Linq; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; @@ -20,7 +21,7 @@ namespace IO.Swagger.Api /// /// Returns a map of status codes to quantities /// - /// + /// Dictionary<string, int?> Dictionary GetInventory (); /// @@ -29,8 +30,26 @@ namespace IO.Swagger.Api /// /// Returns a map of status codes to quantities /// - /// + /// ApiResponse of Dictionary<string, int?> + ApiResponse> GetInventoryWithHttpInfo (); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Task of Dictionary<string, int?> System.Threading.Tasks.Task> GetInventoryAsync (); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Task of ApiResponse (Dictionary<string, int?>) + System.Threading.Tasks.Task>> GetInventoryAsyncWithHttpInfo (); /// /// Place an order for a pet @@ -49,8 +68,28 @@ namespace IO.Swagger.Api /// /// /// order placed for purchasing the pet - /// Order + /// ApiResponse of Order + ApiResponse PlaceOrderWithHttpInfo (Order body = null); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + /// Task of Order System.Threading.Tasks.Task PlaceOrderAsync (Order body = null); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + /// Task of ApiResponse (Order) + System.Threading.Tasks.Task> PlaceOrderAsyncWithHttpInfo (Order body = null); /// /// Find purchase order by ID @@ -69,8 +108,28 @@ namespace IO.Swagger.Api /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// ID of pet that needs to be fetched - /// Order + /// ApiResponse of Order + ApiResponse GetOrderByIdWithHttpInfo (string orderId); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Task of Order System.Threading.Tasks.Task GetOrderByIdAsync (string orderId); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (Order) + System.Threading.Tasks.Task> GetOrderByIdAsyncWithHttpInfo (string orderId); /// /// Delete purchase order by ID @@ -89,8 +148,28 @@ namespace IO.Swagger.Api /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// /// ID of the order that needs to be deleted - /// + /// ApiResponse of Object(void) + ApiResponse DeleteOrderWithHttpInfo (string orderId); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// Task of void System.Threading.Tasks.Task DeleteOrderAsync (string orderId); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// Task of ApiResponse + System.Threading.Tasks.Task> DeleteOrderAsyncWithHttpInfo (string orderId); } @@ -99,59 +178,92 @@ namespace IO.Swagger.Api /// public class StoreApi : IStoreApi { - /// - /// Initializes a new instance of the class. - /// - /// an instance of ApiClient (optional) - /// - public StoreApi(ApiClient apiClient = null) - { - if (apiClient == null) // use the default one in Configuration - this.ApiClient = Configuration.DefaultApiClient; - else - this.ApiClient = apiClient; - } - /// /// Initializes a new instance of the class. /// /// public StoreApi(String basePath) { - this.ApiClient = new ApiClient(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// - /// Sets the base path of the API client. + /// Initializes a new instance of the class + /// using Configuration object /// - /// The base path - /// The base path - public void SetBasePath(String basePath) + /// An instance of Configuration + /// + public StoreApi(Configuration configuration = null) { - this.ApiClient.BasePath = basePath; + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; } - + /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.ApiClient.BasePath; + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing } /// - /// Gets or sets the API client. + /// Gets or sets the configuration object /// - /// An instance of the ApiClient - public ApiClient ApiClient {get; set;} - + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public Dictionary DefaultHeader() + { + return this.Configuration.DefaultHeader; + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// - /// + /// Dictionary<string, int?> public Dictionary GetInventory () + { + ApiResponse> response = GetInventoryWithHttpInfo(); + return response.Data; + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// ApiResponse of Dictionary<string, int?> + public ApiResponse< Dictionary > GetInventoryWithHttpInfo () { @@ -159,7 +271,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -168,9 +280,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -180,26 +292,49 @@ namespace IO.Swagger.Api - - // authentication setting, if any - String[] authSettings = new String[] { "api_key" }; + + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetInventory: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage); - return (Dictionary) ApiClient.Deserialize(response, typeof(Dictionary)); + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Dictionary) Configuration.ApiClient.Deserialize(response, typeof(Dictionary))); + } /// /// Returns pet inventories by status Returns a map of status codes to quantities /// - /// + /// Task of Dictionary<string, int?> public async System.Threading.Tasks.Task> GetInventoryAsync () + { + ApiResponse> response = await GetInventoryAsyncWithHttpInfo(); + return response.Data; + + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Task of ApiResponse (Dictionary<string, int?>) + public async System.Threading.Tasks.Task>> GetInventoryAsyncWithHttpInfo () { @@ -216,9 +351,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -228,24 +363,50 @@ namespace IO.Swagger.Api - - // authentication setting, if any - String[] authSettings = new String[] { "api_key" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); - return (Dictionary) ApiClient.Deserialize(response, typeof(Dictionary)); + + // authentication (api_key) required + + var apiKeyValue = Configuration.GetApiKeyWithPrefix("api_key"); + if (!String.IsNullOrEmpty(apiKeyValue)) + { + headerParams["api_key"] = apiKeyValue; + } + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetInventory: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse>(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Dictionary) Configuration.ApiClient.Deserialize(response, typeof(Dictionary))); + } /// /// Place an order for a pet /// /// order placed for purchasing the pet - /// Order + /// Order public Order PlaceOrder (Order body = null) + { + ApiResponse response = PlaceOrderWithHttpInfo(body); + return response.Data; + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// ApiResponse of Order + public ApiResponse< Order > PlaceOrderWithHttpInfo (Order body = null) { @@ -253,7 +414,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -262,9 +423,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -273,29 +434,45 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + - // authentication setting, if any - String[] authSettings = new String[] { }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling PlaceOrder: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage); - return (Order) ApiClient.Deserialize(response, typeof(Order)); + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); + } /// /// Place an order for a pet /// /// order placed for purchasing the pet - /// Order + /// Task of Order public async System.Threading.Tasks.Task PlaceOrderAsync (Order body = null) + { + ApiResponse response = await PlaceOrderAsyncWithHttpInfo(body); + return response.Data; + + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Task of ApiResponse (Order) + public async System.Threading.Tasks.Task> PlaceOrderAsyncWithHttpInfo (Order body = null) { @@ -312,9 +489,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -323,26 +500,44 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); - return (Order) ApiClient.Deserialize(response, typeof(Order)); + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling PlaceOrder: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); + } /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// ID of pet that needs to be fetched - /// Order + /// Order public Order GetOrderById (string orderId) + { + ApiResponse response = GetOrderByIdWithHttpInfo(orderId); + return response.Data; + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of Order + public ApiResponse< Order > GetOrderByIdWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set @@ -353,7 +548,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -362,40 +557,56 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter + if (orderId != null) pathParams.Add("orderId", Configuration.ApiClient.ParameterToString(orderId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetOrderById: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage); - return (Order) ApiClient.Deserialize(response, typeof(Order)); + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); + } /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// ID of pet that needs to be fetched - /// Order + /// Task of Order public async System.Threading.Tasks.Task GetOrderByIdAsync (string orderId) + { + ApiResponse response = await GetOrderByIdAsyncWithHttpInfo(orderId); + return response.Data; + + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Task of ApiResponse (Order) + public async System.Threading.Tasks.Task> GetOrderByIdAsyncWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById"); @@ -414,37 +625,54 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter + if (orderId != null) pathParams.Add("orderId", Configuration.ApiClient.ParameterToString(orderId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); - return (Order) ApiClient.Deserialize(response, typeof(Order)); + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetOrderById: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); + } /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// /// ID of the order that needs to be deleted - /// + /// public void DeleteOrder (string orderId) + { + DeleteOrderWithHttpInfo(orderId); + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// ApiResponse of Object(void) + public ApiResponse DeleteOrderWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set @@ -455,7 +683,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -464,40 +692,55 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter + if (orderId != null) pathParams.Add("orderId", Configuration.ApiClient.ParameterToString(orderId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeleteOrder: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// /// ID of the order that needs to be deleted - /// + /// Task of void public async System.Threading.Tasks.Task DeleteOrderAsync (string orderId) + { + await DeleteOrderAsyncWithHttpInfo(orderId); + + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// Task of ApiResponse + public async System.Threading.Tasks.Task> DeleteOrderAsyncWithHttpInfo (string orderId) { // verify the required parameter 'orderId' is set if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder"); @@ -516,30 +759,36 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter + if (orderId != null) pathParams.Add("orderId", Configuration.ApiClient.ParameterToString(orderId)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeleteOrder: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index 3890e98b17..5502fe15da 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Linq; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; @@ -31,8 +32,28 @@ namespace IO.Swagger.Api /// This can only be done by the logged in user. /// /// Created user object - /// + /// ApiResponse of Object(void) + ApiResponse CreateUserWithHttpInfo (User body = null); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// Task of void System.Threading.Tasks.Task CreateUserAsync (User body = null); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUserAsyncWithHttpInfo (User body = null); /// /// Creates list of users with given input array @@ -51,8 +72,28 @@ namespace IO.Swagger.Api /// /// /// List of user object - /// + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Task of void System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUsersWithArrayInputAsyncWithHttpInfo (List body = null); /// /// Creates list of users with given input array @@ -71,8 +112,28 @@ namespace IO.Swagger.Api /// /// /// List of user object - /// + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithListInputWithHttpInfo (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Task of void System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Task of ApiResponse + System.Threading.Tasks.Task> CreateUsersWithListInputAsyncWithHttpInfo (List body = null); /// /// Logs user into the system @@ -93,8 +154,30 @@ namespace IO.Swagger.Api /// /// The user name for login /// The password for login in clear text - /// string + /// ApiResponse of string + ApiResponse LoginUserWithHttpInfo (string username = null, string password = null); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// Task of string System.Threading.Tasks.Task LoginUserAsync (string username = null, string password = null); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// Task of ApiResponse (string) + System.Threading.Tasks.Task> LoginUserAsyncWithHttpInfo (string username = null, string password = null); /// /// Logs out current logged in user session @@ -111,8 +194,26 @@ namespace IO.Swagger.Api /// /// /// - /// + /// ApiResponse of Object(void) + ApiResponse LogoutUserWithHttpInfo (); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Task of void System.Threading.Tasks.Task LogoutUserAsync (); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Task of ApiResponse + System.Threading.Tasks.Task> LogoutUserAsyncWithHttpInfo (); /// /// Get user by user name @@ -131,8 +232,28 @@ namespace IO.Swagger.Api /// /// /// The name that needs to be fetched. Use user1 for testing. - /// User + /// ApiResponse of User + ApiResponse GetUserByNameWithHttpInfo (string username); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Task of User System.Threading.Tasks.Task GetUserByNameAsync (string username); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Task of ApiResponse (User) + System.Threading.Tasks.Task> GetUserByNameAsyncWithHttpInfo (string username); /// /// Updated user @@ -153,8 +274,30 @@ namespace IO.Swagger.Api /// /// name that need to be deleted /// Updated user object - /// + /// ApiResponse of Object(void) + ApiResponse UpdateUserWithHttpInfo (string username, User body = null); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// Task of void System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// Task of ApiResponse + System.Threading.Tasks.Task> UpdateUserAsyncWithHttpInfo (string username, User body = null); /// /// Delete user @@ -173,8 +316,28 @@ namespace IO.Swagger.Api /// This can only be done by the logged in user. /// /// The name that needs to be deleted - /// + /// ApiResponse of Object(void) + ApiResponse DeleteUserWithHttpInfo (string username); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Task of void System.Threading.Tasks.Task DeleteUserAsync (string username); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Task of ApiResponse + System.Threading.Tasks.Task> DeleteUserAsyncWithHttpInfo (string username); } @@ -183,60 +346,93 @@ namespace IO.Swagger.Api /// public class UserApi : IUserApi { - /// - /// Initializes a new instance of the class. - /// - /// an instance of ApiClient (optional) - /// - public UserApi(ApiClient apiClient = null) - { - if (apiClient == null) // use the default one in Configuration - this.ApiClient = Configuration.DefaultApiClient; - else - this.ApiClient = apiClient; - } - /// /// Initializes a new instance of the class. /// /// public UserApi(String basePath) { - this.ApiClient = new ApiClient(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// - /// Sets the base path of the API client. + /// Initializes a new instance of the class + /// using Configuration object /// - /// The base path - /// The base path - public void SetBasePath(String basePath) + /// An instance of Configuration + /// + public UserApi(Configuration configuration = null) { - this.ApiClient.BasePath = basePath; + if (configuration == null) // use the default one in Configuration + this.Configuration = Configuration.Default; + else + this.Configuration = configuration; } - + /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.ApiClient.BasePath; + return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); + } + + /// + /// Sets the base path of the API client. + /// + /// The base path + [Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")] + public void SetBasePath(String basePath) + { + // do nothing } /// - /// Gets or sets the API client. + /// Gets or sets the configuration object /// - /// An instance of the ApiClient - public ApiClient ApiClient {get; set;} - + /// An instance of the Configuration + public Configuration Configuration {get; set;} + + /// + /// Gets the default header. + /// + /// Dictionary of HTTP header + [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] + public Dictionary DefaultHeader() + { + return this.Configuration.DefaultHeader; + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + [Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] + public void AddDefaultHeader(string key, string value) + { + this.Configuration.AddDefaultHeader(key, value); + } + /// /// Create user This can only be done by the logged in user. /// /// Created user object - /// + /// public void CreateUser (User body = null) + { + CreateUserWithHttpInfo(body); + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// ApiResponse of Object(void) + public ApiResponse CreateUserWithHttpInfo (User body = null) { @@ -244,7 +440,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -253,9 +449,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -264,29 +460,44 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + - // authentication setting, if any - String[] authSettings = new String[] { }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Create user This can only be done by the logged in user. /// /// Created user object - /// + /// Task of void public async System.Threading.Tasks.Task CreateUserAsync (User body = null) + { + await CreateUserAsyncWithHttpInfo(body); + + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// Task of ApiResponse + public async System.Threading.Tasks.Task> CreateUserAsyncWithHttpInfo (User body = null) { @@ -303,9 +514,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -314,27 +525,43 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Creates list of users with given input array /// /// List of user object - /// + /// public void CreateUsersWithArrayInput (List body = null) + { + CreateUsersWithArrayInputWithHttpInfo(body); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// ApiResponse of Object(void) + public ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body = null) { @@ -342,7 +569,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -351,9 +578,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -362,29 +589,44 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + - // authentication setting, if any - String[] authSettings = new String[] { }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Creates list of users with given input array /// /// List of user object - /// + /// Task of void public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body = null) + { + await CreateUsersWithArrayInputAsyncWithHttpInfo(body); + + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Task of ApiResponse + public async System.Threading.Tasks.Task> CreateUsersWithArrayInputAsyncWithHttpInfo (List body = null) { @@ -401,9 +643,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -412,27 +654,43 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Creates list of users with given input array /// /// List of user object - /// + /// public void CreateUsersWithListInput (List body = null) + { + CreateUsersWithListInputWithHttpInfo(body); + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// ApiResponse of Object(void) + public ApiResponse CreateUsersWithListInputWithHttpInfo (List body = null) { @@ -440,7 +698,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -449,9 +707,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -460,29 +718,44 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + - // authentication setting, if any - String[] authSettings = new String[] { }; - // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Creates list of users with given input array /// /// List of user object - /// + /// Task of void public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body = null) + { + await CreateUsersWithListInputAsyncWithHttpInfo(body); + + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Task of ApiResponse + public async System.Threading.Tasks.Task> CreateUsersWithListInputAsyncWithHttpInfo (List body = null) { @@ -499,9 +772,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -510,19 +783,25 @@ namespace IO.Swagger.Api - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -530,8 +809,20 @@ namespace IO.Swagger.Api /// /// The user name for login /// The password for login in clear text - /// string + /// string public string LoginUser (string username = null, string password = null) + { + ApiResponse response = LoginUserWithHttpInfo(username, password); + return response.Data; + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// ApiResponse of string + public ApiResponse< string > LoginUserWithHttpInfo (string username = null, string password = null) { @@ -539,7 +830,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -548,33 +839,37 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) queryParams.Add("username", ApiClient.ParameterToString(username)); // query parameter - if (password != null) queryParams.Add("password", ApiClient.ParameterToString(password)); // query parameter + if (username != null) queryParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // query parameter + if (password != null) queryParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling LoginUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage); - return (string) ApiClient.Deserialize(response, typeof(string)); + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (string) Configuration.ApiClient.Deserialize(response, typeof(string))); + } /// @@ -582,8 +877,21 @@ namespace IO.Swagger.Api /// /// The user name for login /// The password for login in clear text - /// string + /// Task of string public async System.Threading.Tasks.Task LoginUserAsync (string username = null, string password = null) + { + ApiResponse response = await LoginUserAsyncWithHttpInfo(username, password); + return response.Data; + + } + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// Task of ApiResponse (string) + public async System.Threading.Tasks.Task> LoginUserAsyncWithHttpInfo (string username = null, string password = null) { @@ -600,37 +908,53 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) queryParams.Add("username", ApiClient.ParameterToString(username)); // query parameter - if (password != null) queryParams.Add("password", ApiClient.ParameterToString(password)); // query parameter + if (username != null) queryParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // query parameter + if (password != null) queryParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // query parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); - return (string) ApiClient.Deserialize(response, typeof(string)); + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling LoginUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (string) Configuration.ApiClient.Deserialize(response, typeof(string))); + } /// /// Logs out current logged in user session /// - /// + /// public void LogoutUser () + { + LogoutUserWithHttpInfo(); + } + + /// + /// Logs out current logged in user session + /// + /// ApiResponse of Object(void) + public ApiResponse LogoutUserWithHttpInfo () { @@ -638,7 +962,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -647,9 +971,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -659,26 +983,40 @@ namespace IO.Swagger.Api - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling LogoutUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Logs out current logged in user session /// - /// + /// Task of void public async System.Threading.Tasks.Task LogoutUserAsync () + { + await LogoutUserAsyncWithHttpInfo(); + + } + + /// + /// Logs out current logged in user session + /// + /// Task of ApiResponse + public async System.Threading.Tasks.Task> LogoutUserAsyncWithHttpInfo () { @@ -695,9 +1033,9 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json @@ -707,25 +1045,42 @@ namespace IO.Swagger.Api - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling LogoutUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Get user by user name /// /// The name that needs to be fetched. Use user1 for testing. - /// User + /// User public User GetUserByName (string username) + { + ApiResponse response = GetUserByNameWithHttpInfo(username); + return response.Data; + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// ApiResponse of User + public ApiResponse< User > GetUserByNameWithHttpInfo (string username) { // verify the required parameter 'username' is set @@ -736,7 +1091,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -745,40 +1100,56 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetUserByName: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage); - return (User) ApiClient.Deserialize(response, typeof(User)); + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (User) Configuration.ApiClient.Deserialize(response, typeof(User))); + } /// /// Get user by user name /// /// The name that needs to be fetched. Use user1 for testing. - /// User + /// Task of User public async System.Threading.Tasks.Task GetUserByNameAsync (string username) + { + ApiResponse response = await GetUserByNameAsyncWithHttpInfo(username); + return response.Data; + + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Task of ApiResponse (User) + public async System.Threading.Tasks.Task> GetUserByNameAsyncWithHttpInfo (string username) { // verify the required parameter 'username' is set if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName"); @@ -797,29 +1168,36 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); - return (User) ApiClient.Deserialize(response, typeof(User)); + + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling GetUserByName: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage); + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + (User) Configuration.ApiClient.Deserialize(response, typeof(User))); + } /// @@ -827,8 +1205,19 @@ namespace IO.Swagger.Api /// /// name that need to be deleted /// Updated user object - /// + /// public void UpdateUser (string username, User body = null) + { + UpdateUserWithHttpInfo(username, body); + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// ApiResponse of Object(void) + public ApiResponse UpdateUserWithHttpInfo (string username, User body = null) { // verify the required parameter 'username' is set @@ -839,7 +1228,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -848,33 +1237,37 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + + - - // authentication setting, if any - String[] authSettings = new String[] { }; // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdateUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// @@ -882,8 +1275,20 @@ namespace IO.Swagger.Api /// /// name that need to be deleted /// Updated user object - /// + /// Task of void public async System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null) + { + await UpdateUserAsyncWithHttpInfo(username, body); + + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// Task of ApiResponse + public async System.Threading.Tasks.Task> UpdateUserAsyncWithHttpInfo (string username, User body = null) { // verify the required parameter 'username' is set if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser"); @@ -902,39 +1307,55 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - postBody = ApiClient.Serialize(body); // http body (model) parameter + postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling UpdateUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Delete user This can only be done by the logged in user. /// /// The name that needs to be deleted - /// + /// public void DeleteUser (string username) + { + DeleteUserWithHttpInfo(username); + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// ApiResponse of Object(void) + public ApiResponse DeleteUserWithHttpInfo (string username) { // verify the required parameter 'username' is set @@ -945,7 +1366,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -954,40 +1375,55 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; + + // make the HTTP request - IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); - else if (((int)response.StatusCode) == 0) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage); + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeleteUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage); - return; + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } /// /// Delete user This can only be done by the logged in user. /// /// The name that needs to be deleted - /// + /// Task of void public async System.Threading.Tasks.Task DeleteUserAsync (string username) + { + await DeleteUserAsyncWithHttpInfo(username); + + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Task of ApiResponse + public async System.Threading.Tasks.Task> DeleteUserAsyncWithHttpInfo (string username) { // verify the required parameter 'username' is set if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser"); @@ -1006,30 +1442,36 @@ namespace IO.Swagger.Api String[] http_header_accepts = new String[] { "application/json", "application/xml" }; - String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts); + String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts); if (http_header_accept != null) - headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts)); + headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts)); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); - if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter + if (username != null) pathParams.Add("username", Configuration.ApiClient.ParameterToString(username)); // path parameter - - // authentication setting, if any - String[] authSettings = new String[] { }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - if (((int)response.StatusCode) >= 400) - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); - return; + + // make the HTTP request + IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams); + + int statusCode = (int) response.StatusCode; + + if (statusCode >= 400) + throw new ApiException (statusCode, "Error calling DeleteUser: " + response.Content, response.Content); + else if (statusCode == 0) + throw new ApiException (statusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage); + + + return new ApiResponse(statusCode, + response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), + null); } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index a4f9276c88..07b31cbf81 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -18,23 +18,23 @@ namespace IO.Swagger.Client /// public class ApiClient { - private readonly Dictionary _defaultHeaderMap = new Dictionary(); - /// /// Initializes a new instance of the class. /// /// The base path. public ApiClient(String basePath="http://petstore.swagger.io/v2") { - BasePath = basePath; - RestClient = new RestClient(BasePath); + if (String.IsNullOrEmpty(basePath)) + throw new ArgumentException("basePath cannot be empty"); + + RestClient = new RestClient(basePath); } - + /// - /// Gets or sets the base path. + /// Gets or sets the default API client for making HTTP calls. /// - /// The base path - public string BasePath { get; set; } + /// The default API client. + public static ApiClient Default = new ApiClient(); /// /// Gets or sets the RestClient. @@ -42,38 +42,14 @@ namespace IO.Swagger.Client /// An instance of the RestClient public RestClient RestClient { get; set; } - /// - /// Gets the default header. - /// - public Dictionary DefaultHeader - { - get { return _defaultHeaderMap; } - } - - /// - /// Gets the status code of the previous request - /// - public int StatusCode { get; private set; } - - /// - /// Gets the response headers of the previous request - /// - public Dictionary ResponseHeaders { get; private set; } - // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = new RestRequest(path, method); - UpdateParamsForAuth(queryParams, headerParams, authSettings); - - // add default header, if any - foreach(var defaultHeader in _defaultHeaderMap) - request.AddHeader(defaultHeader.Key, defaultHeader.Value); - // add path parameter, if any foreach(var param in pathParams) request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); @@ -111,18 +87,15 @@ namespace IO.Swagger.Client /// Form parameters. /// File parameters. /// Path parameters. - /// Authentication settings. /// Object public Object CallApi( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = RestClient.Execute(request); - StatusCode = (int) response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object) response; } @@ -137,32 +110,18 @@ namespace IO.Swagger.Client /// Form parameters. /// File parameters. /// Path parameters. - /// Authentication settings. /// The Task instance. public async System.Threading.Tasks.Task CallApiAsync( String path, RestSharp.Method method, Dictionary queryParams, String postBody, Dictionary headerParams, Dictionary formParams, - Dictionary fileParams, Dictionary pathParams, String[] authSettings) + Dictionary fileParams, Dictionary pathParams) { var request = PrepareRequest( - path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); + path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = await RestClient.ExecuteTaskAsync(request); - StatusCode = (int)response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object)response; } - /// - /// Add default header. - /// - /// Header field name. - /// Header field value. - /// - public void AddDefaultHeader(string key, string value) - { - _defaultHeaderMap.Add(key, value); - } - /// /// Escape string (url-encoded). /// @@ -286,63 +245,6 @@ namespace IO.Swagger.Client } } - /// - /// Get the API key with prefix. - /// - /// API key identifier (authentication scheme). - /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) - { - var apiKeyValue = ""; - Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); - var apiKeyPrefix = ""; - if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) - return apiKeyPrefix + " " + apiKeyValue; - else - return apiKeyValue; - } - - /// - /// Update parameters based on authentication. - /// - /// Query parameters. - /// Header parameters. - /// Authentication settings. - public void UpdateParamsForAuth(Dictionary queryParams, Dictionary headerParams, string[] authSettings) - { - if (authSettings == null || authSettings.Length == 0) - return; - - foreach (string auth in authSettings) - { - // determine which one to use - switch(auth) - { - - case "api_key": - - var apiKeyValue = GetApiKeyWithPrefix("api_key"); - if (!String.IsNullOrEmpty(apiKeyValue)) - { - headerParams["api_key"] = apiKeyValue; - } - break; - - case "petstore_auth": - - if (!String.IsNullOrEmpty(Configuration.AccessToken)) - { - headerParams["Authorization"] = "Bearer " + Configuration.AccessToken; - } - break; - - default: - //show warning about security definition not found - break; - } - } - } - /// /// Select the Accept header's value from the given accepts array: /// if JSON exists in the given array, use it; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs index addfc83971..2410626602 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiException.cs @@ -1,47 +1,50 @@ using System; -namespace IO.Swagger.Client { - /// - /// API Exception - /// - public class ApiException : Exception { - /// - /// Gets or sets the error code (HTTP status code) - /// - /// The error code (HTTP status code). - public int ErrorCode { get; set; } - - /// - /// Gets or sets the error content (body json object) - /// - /// The error content (Http response body). - public dynamic ErrorContent { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - public ApiException() {} - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - public ApiException(int errorCode, string message) : base(message) { - this.ErrorCode = errorCode; - } - - /// - /// Initializes a new instance of the class. - /// - /// HTTP status code. - /// Error message. - /// Error content. - public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { - this.ErrorCode = errorCode; - this.ErrorContent = errorContent; - } - - } - +namespace IO.Swagger.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// Gets or sets the error code (HTTP status code) + /// + /// The error code (HTTP status code). + public int ErrorCode { get; set; } + + /// + /// Gets or sets the error content (body json object) + /// + /// The error content (Http response body). + public dynamic ErrorContent { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + public ApiException() {} + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + public ApiException(int errorCode, string message) : base(message) + { + this.ErrorCode = errorCode; + } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + /// Error content. + public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) + { + this.ErrorCode = errorCode; + this.ErrorContent = errorContent; + } + } + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiResponse.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiResponse.cs new file mode 100644 index 0000000000..1573571165 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; + +namespace IO.Swagger.Client +{ + /// + /// API Response + /// + public class ApiResponse + { + /// + /// Gets or sets the status code (HTTP status code) + /// + /// The status code. + public int StatusCode { get; private set; } + + /// + /// Gets or sets the HTTP headers + /// + /// HTTP headers + public IDictionary Headers { get; private set; } + + /// + /// Gets or sets the data (parsed HTTP body) + /// + /// The data. + public T Data { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// HTTP status code. + /// Error message. + /// Data (parsed HTTP body) + public ApiResponse(int statusCode, IDictionary headers, T data) + { + this.StatusCode= statusCode; + this.Headers = headers; + this.Data = data; + } + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs index 4168d69a2e..151e4e4224 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs @@ -12,6 +12,17 @@ namespace IO.Swagger.Client /// public class Configuration { + /// + /// Initializes a new instance of the Configuration class. + /// + /// Api client. + public Configuration(ApiClient apiClient=null) + { + if (apiClient == null) + ApiClient = ApiClient.Default; + else + ApiClient = apiClient; + } /// /// Version of the package. @@ -19,41 +30,84 @@ namespace IO.Swagger.Client /// Version of the package. public const string Version = "1.0.0"; + /// + /// Gets or sets the default Configuration. + /// + /// Configuration. + public static Configuration Default = new Configuration(); + /// /// Gets or sets the default API client for making HTTP calls. /// /// The API client. - public static ApiClient DefaultApiClient = new ApiClient(); - + public ApiClient ApiClient; + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } + /// /// Gets or sets the username (HTTP basic authentication). /// /// The username. - public static String Username { get; set; } + public String Username { get; set; } /// /// Gets or sets the password (HTTP basic authentication). /// /// The password. - public static String Password { get; set; } + public String Password { get; set; } /// /// Gets or sets the access token for OAuth2 authentication. /// /// The access token. - public static String AccessToken { get; set; } + public String AccessToken { get; set; } /// /// Gets or sets the API key based on the authentication name. /// /// The API key. - public static Dictionary ApiKey = new Dictionary(); + public Dictionary ApiKey = new Dictionary(); /// /// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name. /// /// The prefix of the API key. - public static Dictionary ApiKeyPrefix = new Dictionary(); + public Dictionary ApiKeyPrefix = new Dictionary(); + + /// + /// Get the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. + public string GetApiKeyWithPrefix (string apiKeyIdentifier) + { + var apiKeyValue = ""; + ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); + var apiKeyPrefix = ""; + if (ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) + return apiKeyPrefix + " " + apiKeyValue; + else + return apiKeyValue; + } private static string _tempFolderPath = Path.GetTempPath(); diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index 00467e845e..c1dc6a31e1 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -56,6 +56,8 @@ + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index cd6170dd2e..da9e64e0c9 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,8 +2,29 @@ - + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs index 42cea3120f..ff81f6b7c7 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs @@ -20,7 +20,6 @@ namespace SwaggerClient.TestApiClient List numList = new List(new int[] {1, 37}); Assert.AreEqual("1,37", api.ParameterToString (numList)); } - } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs new file mode 100644 index 0000000000..c508917e7d --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs @@ -0,0 +1,79 @@ +using NUnit.Framework; +using System; +using System.Collections.Generic; +using IO.Swagger.Client; +using IO.Swagger.Api; +using IO.Swagger.Model; + +namespace SwaggerClient.TestConfiguration +{ + public class TestConfiguration + { + [Test ()] + public void TestAuthentication () + { + Configuration c = new Configuration (); + c.Username = "test_username"; + c.Password = "test_password"; + + c.ApiKey ["api_key_identifier"] = "1233456778889900"; + c.ApiKeyPrefix ["api_key_identifier"] = "PREFIX"; + Assert.AreEqual (c.GetApiKeyWithPrefix("api_key_identifier"), "PREFIX 1233456778889900"); + + } + + [Test ()] + public void TestBasePath () + { + PetApi p = new PetApi ("http://new-basepath.com"); + Assert.AreEqual (p.Configuration.ApiClient.RestClient.BaseUrl, "http://new-basepath.com"); + // Given that PetApi is initailized with a base path, a new configuration (with a new ApiClient) + // is created by default + Assert.AreNotSame (p.Configuration, Configuration.Default); + } + + [Test ()] + public void TestDefautlConfiguration () + { + PetApi p1 = new PetApi (); + PetApi p2 = new PetApi (); + Assert.AreSame (p1.Configuration, p2.Configuration); + // same as the default + Assert.AreSame (p1.Configuration, Configuration.Default); + + Configuration c = new Configuration (); + Assert.AreNotSame (c, p1.Configuration); + + PetApi p3 = new PetApi (c); + // same as c + Assert.AreSame (p3.Configuration, c); + // not same as default + Assert.AreNotSame (p3.Configuration, p1.Configuration); + + } + + [Test ()] + public void TestUsage () + { + // basic use case using default base URL + PetApi p1 = new PetApi (); + Assert.AreSame (p1.Configuration, Configuration.Default, "PetApi should use default configuration"); + + // using a different base URL + PetApi p2 = new PetApi ("http://new-base-url.com/"); + Assert.AreEqual (p2.Configuration.ApiClient.RestClient.BaseUrl.ToString(), "http://new-base-url.com/"); + + // using a different configuration + Configuration c1 = new Configuration (); + PetApi p3 = new PetApi (c1); + Assert.AreSame (p3.Configuration, c1); + + // using a different base URL via a new ApiClient + ApiClient a1 = new ApiClient ("http://new-api-client.com"); + Configuration c2 = new Configuration (a1); + PetApi p4 = new PetApi (c2); + Assert.AreSame (p4.Configuration.ApiClient, a1); + } + + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index e9169da983..55d081f9bb 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -76,6 +76,38 @@ namespace SwaggerClient.TestPet } + /// + /// Test GetPetByIdAsyncWithHttpInfo + /// + [Test ()] + public void TestGetPetByIdAsyncWithHttpInfo () + { + PetApi petApi = new PetApi (); + var task = petApi.GetPetByIdAsyncWithHttpInfo (petId); + + Assert.AreEqual (200, task.Result.StatusCode); + Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type")); + Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json"); + + Pet response = task.Result.Data; + Assert.IsInstanceOf (response, "Response is a Pet"); + + Assert.AreEqual ("Csharp test", response.Name); + Assert.AreEqual ("available", response.Status); + + Assert.IsInstanceOf> (response.Tags, "Response.Tags is a Array"); + Assert.AreEqual (petId, response.Tags [0].Id); + Assert.AreEqual ("sample tag name1", response.Tags [0].Name); + + Assert.IsInstanceOf> (response.PhotoUrls, "Response.PhotoUrls is a Array"); + Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]); + + Assert.IsInstanceOf (response.Category, "Response.Category is a Category"); + Assert.AreEqual (56, response.Category.Id); + Assert.AreEqual ("sample category name2", response.Category.Name); + + } + /// /// Test GetPetById /// @@ -229,6 +261,32 @@ namespace SwaggerClient.TestPet } + /// + /// Test status code + /// + [Test ()] + public void TestStatusCodeAndHeader () + { + PetApi petApi = new PetApi (); + var response = petApi.GetPetByIdWithHttpInfo (petId); + Assert.AreEqual (response.StatusCode, 200); + Assert.IsTrue (response.Headers.ContainsKey("Content-Type")); + Assert.AreEqual (response.Headers["Content-Type"], "application/json"); + } + + /// + /// Test default header (should be deprecated + /// + [Test ()] + public void TestDefaultHeader () + { + PetApi petApi = new PetApi (); + // there should be a warning for using AddDefaultHeader (deprecated) below + petApi.AddDefaultHeader ("header_key", "header_value"); + // the following should be used instead as suggested in the doc + petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2"); + + } } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index 3e3230fe96..eb5aee1798 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index fba3366dbb..073b96f23b 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt index 67be9ad1f1..3e55ab9096 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt +++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt @@ -1,16 +1,8 @@ -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs -/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index 3e3230fe96..eb5aee1798 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index fba3366dbb..073b96f23b 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ