From 680078dc585c0a6a1e667bc8a96c0903a6b48910 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 9 Jun 2015 13:52:01 +0800 Subject: [PATCH] fix csharp refer to apiinvoker --- bin/all-petstore.sh | 1 + .../src/main/resources/csharp/api.mustache | 2 +- .../src/main/csharp/io/swagger/Api/PetApi.cs | 1738 +++++++---------- .../main/csharp/io/swagger/Api/StoreApi.cs | 878 ++++----- .../src/main/csharp/io/swagger/Api/UserApi.cs | 1702 +++++++--------- .../main/csharp/io/swagger/Model/Category.cs | 96 +- .../src/main/csharp/io/swagger/Model/Order.cs | 152 +- .../src/main/csharp/io/swagger/Model/Pet.cs | 152 +- .../src/main/csharp/io/swagger/Model/Tag.cs | 96 +- .../src/main/csharp/io/swagger/Model/User.cs | 180 +- .../csharp/io/swagger/client/ApiClient.cs | 454 ++--- .../csharp/io/swagger/client/ApiException.cs | 81 +- .../csharp/io/swagger/client/Configuration.cs | 75 +- .../python/SwaggerPetstore-python/README.md | 6 +- .../SwaggerPetstore/api_client.py | 466 ++--- .../SwaggerPetstore/apis/pet_api.py | 202 +- .../SwaggerPetstore/apis/store_api.py | 114 +- .../SwaggerPetstore/apis/user_api.py | 186 +- .../SwaggerPetstore/configuration.py | 38 +- .../SwaggerPetstore/models/category.py | 54 +- .../SwaggerPetstore/models/order.py | 86 +- .../SwaggerPetstore/models/pet.py | 86 +- .../SwaggerPetstore/models/tag.py | 54 +- .../SwaggerPetstore/models/user.py | 102 +- .../SwaggerPetstore/rest.py | 380 ++-- .../python/SwaggerPetstore-python/setup.py | 22 +- .../petstore/ruby/lib/swagger_client.rb | 24 +- .../ruby/lib/swagger_client/api/pet_api.rb | 633 +++--- .../ruby/lib/swagger_client/api/store_api.rb | 295 ++- .../ruby/lib/swagger_client/api/user_api.rb | 609 +++--- .../lib/swagger_client/models/base_object.rb | 148 +- .../lib/swagger_client/models/category.rb | 69 +- .../ruby/lib/swagger_client/models/order.rb | 119 +- .../ruby/lib/swagger_client/models/pet.rb | 127 +- .../ruby/lib/swagger_client/models/tag.rb | 69 +- .../ruby/lib/swagger_client/models/user.rb | 147 +- .../ruby/lib/swagger_client/monkey.rb | 158 +- .../ruby/lib/swagger_client/swagger.rb | 132 +- .../swagger_client/swagger/configuration.rb | 48 +- .../lib/swagger_client/swagger/request.rb | 465 ++--- .../lib/swagger_client/swagger/response.rb | 112 +- .../lib/swagger_client/swagger/version.rb | 6 +- .../petstore/ruby/swagger_client.gemspec | 46 +- 43 files changed, 4951 insertions(+), 5659 deletions(-) diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index 72797973a3..8937200c77 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -25,6 +25,7 @@ cd $APP_DIR ./bin/jaxrs-petstore-server.sh ./bin/java-petstore.sh ./bin/qt5-petstore.sh +./bin/perl-petstore.sh ./bin/php-petstore.sh ./bin/python-petstore.sh ./bin/retrofit-petstore.sh diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 117446441f..e22d5517ab 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -164,7 +164,7 @@ namespace {{package}} { if (((int)response.StatusCode) >= 400) { throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content); } - {{#returnType}}return ({{{returnType}}}) ApiInvoker.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}} + {{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}} return;{{/returnType}} } {{/operation}} diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs index 4d99ab9e53..5fdb38f2da 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs @@ -6,1035 +6,803 @@ using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + - public interface IPetApi { + public interface IPetApi { - /// - - /// Update an existing pet - /// - - /// - Pet object that needs to be added to the store - /// - - void UpdatePet (Pet Body); + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + void UpdatePet (Pet Body); - /// - - /// Update an existing pet - /// - - /// - Pet object that needs to be added to the store - /// - - Task UpdatePetAsync (Pet Body); + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + Task UpdatePetAsync (Pet Body); - /// - - /// Add a new pet to the store - /// - - /// - Pet object that needs to be added to the store - /// - - void AddPet (Pet Body); + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + void AddPet (Pet Body); - /// - - /// Add a new pet to the store - /// - - /// - Pet object that needs to be added to the store - /// - - Task AddPetAsync (Pet Body); + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + Task AddPetAsync (Pet Body); - /// - - /// Finds Pets by status Multiple status values can be provided with comma seperated strings - /// - - /// - Status values that need to be considered for filter - /// - List - List FindPetsByStatus (List Status); + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + List FindPetsByStatus (List Status); - /// - - /// Finds Pets by status Multiple status values can be provided with comma seperated strings - /// - - /// - Status values that need to be considered for filter - /// - List - Task> FindPetsByStatusAsync (List Status); + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + Task> FindPetsByStatusAsync (List Status); - /// - - /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - /// - - /// - Tags to filter by - /// - List - List FindPetsByTags (List Tags); + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List + List FindPetsByTags (List Tags); - /// - - /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - /// - - /// - Tags to filter by - /// - List - Task> FindPetsByTagsAsync (List Tags); + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List + Task> FindPetsByTagsAsync (List Tags); - /// - - /// 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 GetPetById (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 + /// Pet + Pet GetPetById (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 - /// - Pet - 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 + /// Pet + Task GetPetByIdAsync (long? PetId); - /// - - /// 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 - /// - - void UpdatePetWithForm (string PetId, string Name, string 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 + /// + void UpdatePetWithForm (string PetId, string Name, string 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 UpdatePetWithFormAsync (string PetId, string Name, string 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 UpdatePetWithFormAsync (string PetId, string Name, string Status); - /// - - /// Deletes a pet - /// - - /// - /// - Pet id to delete - /// - - void DeletePet (string ApiKey, long? PetId); + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + void DeletePet (string ApiKey, long? PetId); - /// - - /// Deletes a pet - /// - - /// - /// - Pet id to delete - /// - - Task DeletePetAsync (string ApiKey, long? PetId); + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + Task DeletePetAsync (string ApiKey, long? PetId); - /// - - /// uploads an image - /// - - /// - ID of pet to update/// - Additional data to pass to server/// - file to upload - /// - - void UploadFile (long? PetId, string AdditionalMetadata, string File); + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + void UploadFile (long? PetId, string AdditionalMetadata, string File); - /// - - /// uploads an image - /// - - /// - ID of pet to update/// - Additional data to pass to server/// - file to upload - /// - - Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File); + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File); - } + } - /// - - /// Represents a collection of functions to interact with the API endpoints - /// - - public class PetApi : IPetApi { + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class PetApi : IPetApi { - /// - - /// Initializes a new instance of the - - class. - /// - - /// - an instance of ApiClient (optional) - /// - + /// + /// 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.apiClient; - } else { - this.apiClient = apiClient; - } + if (apiClient == null) { // use the default one in Configuration + this.apiClient = Configuration.apiClient; + } else { + this.apiClient = apiClient; + } } - /// - - /// Initializes a new instance of the - - class. - /// - - /// - + /// + /// Initializes a new instance of the class. + /// + /// public PetApi(String basePath) { - this.apiClient = new ApiClient(basePath); + this.apiClient = new ApiClient(basePath); } - /// - - /// Sets the base path of the API client. - /// - - /// - The base path + /// + /// Sets the base path of the API client. + /// + /// The base path public void SetBasePath(String basePath) { - this.apiClient.basePath = basePath; + this.apiClient.basePath = basePath; } - /// - - /// Gets the base path of the API client. - /// - - /// - The base path + /// + /// Gets the base path of the API client. + /// + /// The base path public String GetBasePath(String basePath) { - return this.apiClient.basePath; + return this.apiClient.basePath; } - /// - - /// Gets or sets the API client. - /// - - /// - The API client + /// + /// Gets or sets the API client. + /// + /// The API client public ApiClient apiClient {get; set;} - /// - - /// Update an existing pet - /// - - /// - Pet object that needs to be added to the store - /// - - public void UpdatePet (Pet Body) { + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + public void UpdatePet (Pet Body) { - + - var path = "/pet"; - path = path.Replace("{format}", "json"); - + var path = "/pet"; + path = path.Replace("{format}", "json"); + - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; + // 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, authSettings); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + if (((int)response.StatusCode) >= 400) { throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Update an existing pet - /// - - /// - Pet object that needs to be added to the store - /// - - public async Task UpdatePetAsync (Pet Body) { - - - - var path = "/pet"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Add a new pet to the store - /// - - /// - Pet object that needs to be added to the store - /// - - public void AddPet (Pet Body) { - - - - var path = "/pet"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Add a new pet to the store - /// - - /// - Pet object that needs to be added to the store - /// - - public async Task AddPetAsync (Pet Body) { - - - - var path = "/pet"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Finds Pets by status Multiple status values can be provided with comma seperated strings - /// - - /// - Status values that need to be considered for filter - /// - List - public List FindPetsByStatus (List Status) { - - - - var path = "/pet/findByStatus"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter - - - - - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); - } - return (List) apiClient.Deserialize(response.Content, 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 - /// - List - public async Task> FindPetsByStatusAsync (List Status) { - - - - var path = "/pet/findByStatus"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Status != null) queryParams.Add("status", 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); - } - return (List) ApiInvoker.Deserialize(response.Content, 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 - public List FindPetsByTags (List Tags) { - - - - var path = "/pet/findByTags"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter - - - - - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); - } - return (List) apiClient.Deserialize(response.Content, 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 - public async Task> FindPetsByTagsAsync (List Tags) { - - - - var path = "/pet/findByTags"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Tags != null) queryParams.Add("tags", 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); - } - return (List) ApiInvoker.Deserialize(response.Content, 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 - public Pet GetPetById (long? PetId) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // authentication setting, if any - String[] authSettings = new String[] { "api_key", "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); - } - return (Pet) apiClient.Deserialize(response.Content, 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 - public async Task GetPetByIdAsync (long? PetId) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // authentication setting, if any - String[] authSettings = new String[] { "api_key", "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); - } - return (Pet) ApiInvoker.Deserialize(response.Content, typeof(Pet)); - } - - /// - - /// 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 - /// - - public void UpdatePetWithForm (string PetId, string Name, string Status) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter - if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); - } - - return; - } - - /// - - /// 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 - /// - - public async Task UpdatePetWithFormAsync (string PetId, string Name, string Status) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter - if (Status != null) formParams.Add("status", 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Deletes a pet - /// - - /// - /// - Pet id to delete - /// - - public void DeletePet (string ApiKey, long? PetId) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter - - - - - // authentication setting, if any - String[] authSettings = new String[] { "petstore_auth" }; - - // make the HTTP request - IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Deletes a pet - /// - - /// - /// - Pet id to delete - /// - - public async Task DeletePetAsync (string ApiKey, long? PetId) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); - - - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - if (ApiKey != null) headerParams.Add("api_key", 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); - } - - return; - } - - /// - - /// uploads an image - /// - - /// - ID of pet to update/// - Additional data to pass to server/// - file to upload - /// - - public void UploadFile (long? PetId, string AdditionalMetadata, string File) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); - - - var path = "/pet/{petId}/uploadImage"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter - if (File != null) fileParams.Add("file", File); - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); - } - - return; - } - - /// - - /// uploads an image - /// - - /// - ID of pet to update/// - Additional data to pass to server/// - file to upload - /// - - public async Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File) { - - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); - - - var path = "/pet/{petId}/uploadImage"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter - if (File != null) fileParams.Add("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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); - } - - return; - } - + } + + return; } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + public async Task UpdatePetAsync (Pet Body) { + + + + var path = "/pet"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + public void AddPet (Pet Body) { + + + + var path = "/pet"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + public async Task AddPetAsync (Pet Body) { + + + + var path = "/pet"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + public List FindPetsByStatus (List Status) { + + + + var path = "/pet/findByStatus"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); + } + return (List) apiClient.Deserialize(response.Content, 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 + /// List + public async Task> FindPetsByStatusAsync (List Status) { + + + + var path = "/pet/findByStatus"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Status != null) queryParams.Add("status", 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); + } + return (List) apiClient.Deserialize(response.Content, 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 + public List FindPetsByTags (List Tags) { + + + + var path = "/pet/findByTags"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); + } + return (List) apiClient.Deserialize(response.Content, 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 + public async Task> FindPetsByTagsAsync (List Tags) { + + + + var path = "/pet/findByTags"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Tags != null) queryParams.Add("tags", 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); + } + return (List) apiClient.Deserialize(response.Content, 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 + public Pet GetPetById (long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "api_key", "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); + } + return (Pet) apiClient.Deserialize(response.Content, 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 + public async Task GetPetByIdAsync (long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "api_key", "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); + } + return (Pet) apiClient.Deserialize(response.Content, typeof(Pet)); + } + + /// + /// 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 + /// + public void UpdatePetWithForm (string PetId, string Name, string Status) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter + if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); + } + + return; + } + + /// + /// 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 + /// + public async Task UpdatePetWithFormAsync (string PetId, string Name, string Status) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter + if (Status != null) formParams.Add("status", 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); + } + + return; + } + + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + public void DeletePet (string ApiKey, long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + public async Task DeletePetAsync (string ApiKey, long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + if (ApiKey != null) headerParams.Add("api_key", 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); + } + + return; + } + + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + public void UploadFile (long? PetId, string AdditionalMetadata, string File) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); + + + var path = "/pet/{petId}/uploadImage"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter + if (File != null) fileParams.Add("file", File); + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); + } + + return; + } + + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + public async Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); + + + var path = "/pet/{petId}/uploadImage"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter + if (File != null) fileParams.Add("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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); + } + + return; + } + + } + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs index f77decdf5f..739c9d30be 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs @@ -6,535 +6,423 @@ using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + - public interface IStoreApi { + public interface IStoreApi { - /// - - /// Returns pet inventories by status Returns a map of status codes to quantities - /// - - - /// - Dictionary - Dictionary GetInventory (); - - /// - - /// Returns pet inventories by status Returns a map of status codes to quantities - /// - - - /// - Dictionary - Task> GetInventoryAsync (); + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// - /// - - /// Place an order for a pet - /// - - /// - order placed for purchasing the pet - /// - Order - Order PlaceOrder (Order Body); + /// Dictionary + Dictionary GetInventory (); - /// - - /// Place an order for a pet - /// - - /// - order placed for purchasing the pet - /// - Order - Task PlaceOrderAsync (Order Body); + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// - /// - - /// 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 GetOrderById (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 - /// - Order - Task GetOrderByIdAsync (string OrderId); + /// Dictionary + Task> GetInventoryAsync (); - /// - - /// 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 - /// - - void DeleteOrder (string OrderId); + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + Order PlaceOrder (Order Body); - /// - - /// 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 DeleteOrderAsync (string OrderId); + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + Task PlaceOrderAsync (Order Body); - } + /// + /// 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 GetOrderById (string OrderId); - /// - - /// Represents a collection of functions to interact with the API endpoints - /// - - public class StoreApi : IStoreApi { + /// + /// 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 GetOrderByIdAsync (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 + /// + void DeleteOrder (string OrderId); - /// - - /// Initializes a new instance of the - - class. - /// - - /// - an instance of ApiClient (optional) - /// - + /// + /// 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 DeleteOrderAsync (string OrderId); + + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + 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.apiClient; - } else { - this.apiClient = apiClient; - } + if (apiClient == null) { // use the default one in Configuration + this.apiClient = Configuration.apiClient; + } else { + this.apiClient = apiClient; + } } - /// - - /// Initializes a new instance of the - - class. - /// - - /// - + /// + /// Initializes a new instance of the class. + /// + /// public StoreApi(String basePath) { - this.apiClient = new ApiClient(basePath); + this.apiClient = new ApiClient(basePath); } - /// - - /// Sets the base path of the API client. - /// - - /// - The base path + /// + /// Sets the base path of the API client. + /// + /// The base path public void SetBasePath(String basePath) { - this.apiClient.basePath = basePath; + this.apiClient.basePath = basePath; } - /// - - /// Gets the base path of the API client. - /// - - /// - The base path + /// + /// Gets the base path of the API client. + /// + /// The base path public String GetBasePath(String basePath) { - return this.apiClient.basePath; + return this.apiClient.basePath; } - /// - - /// Gets or sets the API client. - /// - - /// - The API client + /// + /// Gets or sets the API client. + /// + /// The API client public ApiClient apiClient {get; set;} - /// - - /// Returns pet inventories by status Returns a map of status codes to quantities - /// - - - /// - Dictionary - public Dictionary GetInventory () { + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// Dictionary + public Dictionary GetInventory () { - + - var path = "/store/inventory"; - path = path.Replace("{format}", "json"); - + var path = "/store/inventory"; + path = path.Replace("{format}", "json"); + - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; - - - - + + + + - // authentication setting, if any - String[] authSettings = new String[] { "api_key" }; + // authentication setting, if any + String[] authSettings = new String[] { "api_key" }; - // make the HTTP request - IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + if (((int)response.StatusCode) >= 400) { throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); - } - return (Dictionary) apiClient.Deserialize(response.Content, typeof(Dictionary)); - } - - /// - - /// Returns pet inventories by status Returns a map of status codes to quantities - /// - - - /// - Dictionary - public async Task> GetInventoryAsync () { - - - - var path = "/store/inventory"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); - } - return (Dictionary) ApiInvoker.Deserialize(response.Content, typeof(Dictionary)); - } - - /// - - /// Place an order for a pet - /// - - /// - order placed for purchasing the pet - /// - Order - public Order PlaceOrder (Order Body) { - - - - var path = "/store/order"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); - } - return (Order) apiClient.Deserialize(response.Content, typeof(Order)); - } - - /// - - /// Place an order for a pet - /// - - /// - order placed for purchasing the pet - /// - Order - public async Task PlaceOrderAsync (Order Body) { - - - - var path = "/store/order"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); - } - return (Order) ApiInvoker.Deserialize(response.Content, 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 - public Order GetOrderById (string OrderId) { - - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); - - - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); - } - return (Order) apiClient.Deserialize(response.Content, 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 - public async Task GetOrderByIdAsync (string OrderId) { - - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); - - - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); - } - return (Order) ApiInvoker.Deserialize(response.Content, 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) { - - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); - - - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); - } - - return; - } - - /// - - /// 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 async Task DeleteOrderAsync (string OrderId) { - - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); - - - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); - } - - return; - } - + } + return (Dictionary) apiClient.Deserialize(response.Content, typeof(Dictionary)); } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// Dictionary + public async Task> GetInventoryAsync () { + + + + var path = "/store/inventory"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); + } + return (Dictionary) apiClient.Deserialize(response.Content, typeof(Dictionary)); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + public Order PlaceOrder (Order Body) { + + + + var path = "/store/order"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); + } + return (Order) apiClient.Deserialize(response.Content, typeof(Order)); + } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + public async Task PlaceOrderAsync (Order Body) { + + + + var path = "/store/order"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); + } + return (Order) apiClient.Deserialize(response.Content, 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 + public Order GetOrderById (string OrderId) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); + } + return (Order) apiClient.Deserialize(response.Content, 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 + public async Task GetOrderByIdAsync (string OrderId) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); + } + return (Order) apiClient.Deserialize(response.Content, 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) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); + } + + return; + } + + /// + /// 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 async Task DeleteOrderAsync (string OrderId) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); + } + + return; + } + + } + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs index 608ac49ab0..ffee3f5fdd 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs @@ -6,1007 +6,791 @@ using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + - public interface IUserApi { + public interface IUserApi { - /// - - /// Create user This can only be done by the logged in user. - /// - - /// - Created user object - /// - - void CreateUser (User Body); + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + void CreateUser (User Body); - /// - - /// Create user This can only be done by the logged in user. - /// - - /// - Created user object - /// - - Task CreateUserAsync (User Body); + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + Task CreateUserAsync (User Body); - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - void CreateUsersWithArrayInput (List Body); + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + void CreateUsersWithArrayInput (List Body); - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - Task CreateUsersWithArrayInputAsync (List Body); + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + Task CreateUsersWithArrayInputAsync (List Body); - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - void CreateUsersWithListInput (List Body); + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + void CreateUsersWithListInput (List Body); - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - Task CreateUsersWithListInputAsync (List Body); + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + Task CreateUsersWithListInputAsync (List Body); - /// - - /// Logs user into the system - /// - - /// - The user name for login/// - The password for login in clear text - /// - string - string LoginUser (string Username, string Password); + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + string LoginUser (string Username, string Password); - /// - - /// Logs user into the system - /// - - /// - The user name for login/// - The password for login in clear text - /// - string - Task LoginUserAsync (string Username, string Password); + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + Task LoginUserAsync (string Username, string Password); - /// - - /// Logs out current logged in user session - /// - - - /// - - void LogoutUser (); - - /// - - /// Logs out current logged in user session - /// - - - /// - - Task LogoutUserAsync (); + /// + /// Logs out current logged in user session + /// - /// - - /// Get user by user name - /// - - /// - The name that needs to be fetched. Use user1 for testing. - /// - User - User GetUserByName (string Username); + /// + void LogoutUser (); - /// - - /// Get user by user name - /// - - /// - The name that needs to be fetched. Use user1 for testing. - /// - User - Task GetUserByNameAsync (string Username); + /// + /// Logs out current logged in user session + /// - /// - - /// Updated user This can only be done by the logged in user. - /// - - /// - name that need to be deleted/// - Updated user object - /// - - void UpdateUser (string Username, User Body); - - /// - - /// Updated user This can only be done by the logged in user. - /// - - /// - name that need to be deleted/// - Updated user object - /// - - Task UpdateUserAsync (string Username, User Body); + /// + Task LogoutUserAsync (); - /// - - /// Delete user This can only be done by the logged in user. - /// - - /// - The name that needs to be deleted - /// - - void DeleteUser (string Username); + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + User GetUserByName (string Username); - /// - - /// Delete user This can only be done by the logged in user. - /// - - /// - The name that needs to be deleted - /// - - Task DeleteUserAsync (string Username); + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + Task GetUserByNameAsync (string Username); - } + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + void UpdateUser (string Username, User Body); - /// - - /// Represents a collection of functions to interact with the API endpoints - /// - - public class UserApi : IUserApi { + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + Task UpdateUserAsync (string Username, User Body); + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + void DeleteUser (string Username); - /// - - /// Initializes a new instance of the - - class. - /// - - /// - an instance of ApiClient (optional) - /// - + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + Task DeleteUserAsync (string Username); + + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + 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.apiClient; - } else { - this.apiClient = apiClient; - } + if (apiClient == null) { // use the default one in Configuration + this.apiClient = Configuration.apiClient; + } else { + this.apiClient = apiClient; + } } - /// - - /// Initializes a new instance of the - - class. - /// - - /// - + /// + /// Initializes a new instance of the class. + /// + /// public UserApi(String basePath) { - this.apiClient = new ApiClient(basePath); + this.apiClient = new ApiClient(basePath); } - /// - - /// Sets the base path of the API client. - /// - - /// - The base path + /// + /// Sets the base path of the API client. + /// + /// The base path public void SetBasePath(String basePath) { - this.apiClient.basePath = basePath; + this.apiClient.basePath = basePath; } - /// - - /// Gets the base path of the API client. - /// - - /// - The base path + /// + /// Gets the base path of the API client. + /// + /// The base path public String GetBasePath(String basePath) { - return this.apiClient.basePath; + return this.apiClient.basePath; } - /// - - /// Gets or sets the API client. - /// - - /// - The API client + /// + /// Gets or sets the API client. + /// + /// The API client public ApiClient apiClient {get; set;} - /// - - /// Create user This can only be done by the logged in user. - /// - - /// - Created user object - /// - - public void CreateUser (User Body) { + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + public void CreateUser (User Body) { - + - var path = "/user"; - path = path.Replace("{format}", "json"); - + var path = "/user"; + path = path.Replace("{format}", "json"); + - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // authentication setting, if any - String[] authSettings = new String[] { }; + // 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, authSettings); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + if (((int)response.StatusCode) >= 400) { throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Create user This can only be done by the logged in user. - /// - - /// - Created user object - /// - - public async Task CreateUserAsync (User Body) { - - - - var path = "/user"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - public void CreateUsersWithArrayInput (List Body) { - - - - var path = "/user/createWithArray"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - public async Task CreateUsersWithArrayInputAsync (List Body) { - - - - var path = "/user/createWithArray"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - public void CreateUsersWithListInput (List Body) { - - - - var path = "/user/createWithList"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Creates list of users with given input array - /// - - /// - List of user object - /// - - public async Task CreateUsersWithListInputAsync (List Body) { - - - - var path = "/user/createWithList"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Logs user into the system - /// - - /// - The user name for login/// - The password for login in clear text - /// - string - public string LoginUser (string Username, string Password) { - - - - var path = "/user/login"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter - if (Password != null) queryParams.Add("password", 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); - } - return (string) apiClient.Deserialize(response.Content, typeof(string)); - } - - /// - - /// Logs user into the system - /// - - /// - The user name for login/// - The password for login in clear text - /// - string - public async Task LoginUserAsync (string Username, string Password) { - - - - var path = "/user/login"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter - if (Password != null) queryParams.Add("password", 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); - } - return (string) ApiInvoker.Deserialize(response.Content, typeof(string)); - } - - /// - - /// Logs out current logged in user session - /// - - - /// - - public void LogoutUser () { - - - - var path = "/user/logout"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Logs out current logged in user session - /// - - - /// - - public async Task LogoutUserAsync () { - - - - var path = "/user/logout"; - path = path.Replace("{format}", "json"); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Get user by user name - /// - - /// - The name that needs to be fetched. Use user1 for testing. - /// - User - public User GetUserByName (string Username) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); - } - return (User) apiClient.Deserialize(response.Content, typeof(User)); - } - - /// - - /// Get user by user name - /// - - /// - The name that needs to be fetched. Use user1 for testing. - /// - User - public async Task GetUserByNameAsync (string Username) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); - } - return (User) ApiInvoker.Deserialize(response.Content, typeof(User)); - } - - /// - - /// Updated user This can only be done by the logged in user. - /// - - /// - name that need to be deleted/// - Updated user object - /// - - public void UpdateUser (string Username, User Body) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Updated user This can only be done by the logged in user. - /// - - /// - name that need to be deleted/// - Updated user object - /// - - public async Task UpdateUserAsync (string Username, User Body) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - postBody = 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Delete user This can only be done by the logged in user. - /// - - /// - The name that needs to be deleted - /// - - public void DeleteUser (string Username) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); - } - - return; - } - - /// - - /// Delete user This can only be done by the logged in user. - /// - - /// - The name that needs to be deleted - /// - - public async Task DeleteUserAsync (string Username) { - - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); - - - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - - - var queryParams = new Dictionary - (); - var headerParams = new Dictionary - (); - var formParams = new Dictionary - (); - var fileParams = new Dictionary - (); - String postBody = null; - - - - - - - // 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, authSettings); - if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); - } - - return; - } - + } + + return; } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + public async Task CreateUserAsync (User Body) { + + + + var path = "/user"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public void CreateUsersWithArrayInput (List Body) { + + + + var path = "/user/createWithArray"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public async Task CreateUsersWithArrayInputAsync (List Body) { + + + + var path = "/user/createWithArray"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public void CreateUsersWithListInput (List Body) { + + + + var path = "/user/createWithList"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public async Task CreateUsersWithListInputAsync (List Body) { + + + + var path = "/user/createWithList"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + public string LoginUser (string Username, string Password) { + + + + var path = "/user/login"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter + if (Password != null) queryParams.Add("password", 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); + } + return (string) apiClient.Deserialize(response.Content, typeof(string)); + } + + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + public async Task LoginUserAsync (string Username, string Password) { + + + + var path = "/user/login"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter + if (Password != null) queryParams.Add("password", 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); + } + return (string) apiClient.Deserialize(response.Content, typeof(string)); + } + + /// + /// Logs out current logged in user session + /// + + /// + public void LogoutUser () { + + + + var path = "/user/logout"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Logs out current logged in user session + /// + + /// + public async Task LogoutUserAsync () { + + + + var path = "/user/logout"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + public User GetUserByName (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); + } + return (User) apiClient.Deserialize(response.Content, typeof(User)); + } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + public async Task GetUserByNameAsync (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); + } + return (User) apiClient.Deserialize(response.Content, typeof(User)); + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + public void UpdateUser (string Username, User Body) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + public async Task UpdateUserAsync (string Username, User Body) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + public void DeleteUser (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + public async Task DeleteUserAsync (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // 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, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); + } + + return; + } + + } + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs index df423c7ac4..74121762af 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs @@ -5,58 +5,50 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +namespace IO.Swagger.Model { + + /// + /// + /// + [DataContract] + public class Category { - namespace IO.Swagger.Model { - - /// - - /// - /// - - [DataContract] - public class Category { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } - - - - /// - - /// Get the string presentation of the object - /// - - /// - String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Category {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - - /// Get the JSON string presentation of the object - /// - - /// - JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - } + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Category {\n"); + + sb.Append(" Id: ").Append(Id).Append("\n"); + + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} + + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs index 71c11fe7d6..7451619050 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs @@ -5,86 +5,78 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +namespace IO.Swagger.Model { + + /// + /// + /// + [DataContract] + public class Order { - namespace IO.Swagger.Model { - - /// - - /// - /// - - [DataContract] - public class Order { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - - [DataMember(Name="petId", EmitDefaultValue=false)] - public long? PetId { get; set; } - - - - [DataMember(Name="quantity", EmitDefaultValue=false)] - public int? Quantity { get; set; } - - - - [DataMember(Name="shipDate", EmitDefaultValue=false)] - public DateTime? ShipDate { get; set; } - - - /* Order Status */ - [DataMember(Name="status", EmitDefaultValue=false)] - public string Status { get; set; } - - - - [DataMember(Name="complete", EmitDefaultValue=false)] - public bool? Complete { get; set; } - - - - /// - - /// Get the string presentation of the object - /// - - /// - String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Order {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" PetId: ").Append(PetId).Append("\n"); - - sb.Append(" Quantity: ").Append(Quantity).Append("\n"); - - sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); - - sb.Append(" Status: ").Append(Status).Append("\n"); - - sb.Append(" Complete: ").Append(Complete).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - - /// Get the JSON string presentation of the object - /// - - /// - JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - } + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + + [DataMember(Name="petId", EmitDefaultValue=false)] + public long? PetId { get; set; } + + + + [DataMember(Name="quantity", EmitDefaultValue=false)] + public int? Quantity { get; set; } + + + + [DataMember(Name="shipDate", EmitDefaultValue=false)] + public DateTime? ShipDate { get; set; } + + + /* Order Status */ + [DataMember(Name="status", EmitDefaultValue=false)] + public string Status { get; set; } + + + + [DataMember(Name="complete", EmitDefaultValue=false)] + public bool? Complete { get; set; } + + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Order {\n"); + + sb.Append(" Id: ").Append(Id).Append("\n"); + + sb.Append(" PetId: ").Append(PetId).Append("\n"); + + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + + sb.Append(" Status: ").Append(Status).Append("\n"); + + sb.Append(" Complete: ").Append(Complete).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} + + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs index 28285ece28..0bfba35b1e 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs @@ -5,86 +5,78 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +namespace IO.Swagger.Model { + + /// + /// + /// + [DataContract] + public class Pet { - namespace IO.Swagger.Model { - - /// - - /// - /// - - [DataContract] - public class Pet { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - - [DataMember(Name="category", EmitDefaultValue=false)] - public Category Category { get; set; } - - - - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } - - - - [DataMember(Name="photoUrls", EmitDefaultValue=false)] - public List PhotoUrls { get; set; } - - - - [DataMember(Name="tags", EmitDefaultValue=false)] - public List Tags { get; set; } - - - /* pet status in the store */ - [DataMember(Name="status", EmitDefaultValue=false)] - public string Status { get; set; } - - - - /// - - /// Get the string presentation of the object - /// - - /// - String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Pet {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Category: ").Append(Category).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); - - sb.Append(" Tags: ").Append(Tags).Append("\n"); - - sb.Append(" Status: ").Append(Status).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - - /// Get the JSON string presentation of the object - /// - - /// - JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - } + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + + + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + + + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + + + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { get; set; } + + + /* pet status in the store */ + [DataMember(Name="status", EmitDefaultValue=false)] + public string Status { get; set; } + + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Pet {\n"); + + sb.Append(" Id: ").Append(Id).Append("\n"); + + sb.Append(" Category: ").Append(Category).Append("\n"); + + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + + sb.Append(" Tags: ").Append(Tags).Append("\n"); + + sb.Append(" Status: ").Append(Status).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} + + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs index c802c95946..53901491a4 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs @@ -5,58 +5,50 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +namespace IO.Swagger.Model { + + /// + /// + /// + [DataContract] + public class Tag { - namespace IO.Swagger.Model { - - /// - - /// - /// - - [DataContract] - public class Tag { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } - - - - /// - - /// Get the string presentation of the object - /// - - /// - String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Tag {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - - /// Get the JSON string presentation of the object - /// - - /// - JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - } + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Tag {\n"); + + sb.Append(" Id: ").Append(Id).Append("\n"); + + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} + + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs index b8aa21481b..e58d0296a0 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs @@ -5,100 +5,92 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +namespace IO.Swagger.Model { + + /// + /// + /// + [DataContract] + public class User { - namespace IO.Swagger.Model { - - /// - - /// - /// - - [DataContract] - public class User { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - - [DataMember(Name="username", EmitDefaultValue=false)] - public string Username { get; set; } - - - - [DataMember(Name="firstName", EmitDefaultValue=false)] - public string FirstName { get; set; } - - - - [DataMember(Name="lastName", EmitDefaultValue=false)] - public string LastName { get; set; } - - - - [DataMember(Name="email", EmitDefaultValue=false)] - public string Email { get; set; } - - - - [DataMember(Name="password", EmitDefaultValue=false)] - public string Password { get; set; } - - - - [DataMember(Name="phone", EmitDefaultValue=false)] - public string Phone { get; set; } - - - /* User Status */ - [DataMember(Name="userStatus", EmitDefaultValue=false)] - public int? UserStatus { get; set; } - - - - /// - - /// Get the string presentation of the object - /// - - /// - String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class User {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Username: ").Append(Username).Append("\n"); - - sb.Append(" FirstName: ").Append(FirstName).Append("\n"); - - sb.Append(" LastName: ").Append(LastName).Append("\n"); - - sb.Append(" Email: ").Append(Email).Append("\n"); - - sb.Append(" Password: ").Append(Password).Append("\n"); - - sb.Append(" Phone: ").Append(Phone).Append("\n"); - - sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - - /// Get the JSON string presentation of the object - /// - - /// - JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - } + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + + + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + + + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + + + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + + + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + + + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + + + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + + /* User Status */ + [DataMember(Name="userStatus", EmitDefaultValue=false)] + public int? UserStatus { get; set; } + + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class User {\n"); + + sb.Append(" Id: ").Append(Id).Append("\n"); + + sb.Append(" Username: ").Append(Username).Append("\n"); + + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + + sb.Append(" LastName: ").Append(LastName).Append("\n"); + + sb.Append(" Email: ").Append(Email).Append("\n"); + + sb.Append(" Password: ").Append(Password).Append("\n"); + + sb.Append(" Phone: ").Append(Phone).Append("\n"); + + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} + + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs index 9c0a419067..b001a38845 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs @@ -9,310 +9,214 @@ using Newtonsoft.Json; using RestSharp; namespace IO.Swagger.Client { -/// - - /// API client is mainly responible for making the HTTP call to the API backend - /// - -public class ApiClient { + /// + /// API client is mainly responible for making the HTTP call to the API backend + /// + public class ApiClient { -/// - - /// Initializes a new instance of the - - class. - /// - -/// -The base path. -public ApiClient(String basePath="http://petstore.swagger.io/v2") { -this.basePath = basePath; -this.restClient = new RestClient(this.basePath); -} + /// + /// Initializes a new instance of the class. + /// + /// The base path. + public ApiClient(String basePath="http://petstore.swagger.io/v2") { + this.basePath = basePath; + this.restClient = new RestClient(this.basePath); + } -/// - + /// /// Gets or sets the base path. - /// - -/// -The base path. -public string basePath { get; set; } + /// + /// The base path. + public string basePath { get; set; } -/// - + /// /// Gets or sets the RestClient - /// - -/// -The RestClient. -public RestClient restClient { get; set; } + /// + /// The RestClient. + public RestClient restClient { get; set; } -private Dictionary - defaultHeaderMap = new Dictionary -(); + private Dictionary defaultHeaderMap = new Dictionary(); -public Object CallApi(String Path, RestSharp.Method Method, Dictionary - QueryParams, String PostBody, -Dictionary - HeaderParams, Dictionary - FormParams, Dictionary - FileParams, String[] AuthSettings) { -var response = Task.Run(async () => { -var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings); -return resp; -}); -return response.Result; -} - -public async Task - CallApiAsync(String Path, RestSharp.Method Method, Dictionary - QueryParams, String PostBody, - Dictionary - HeaderParams, Dictionary - FormParams, Dictionary - FileParams, String[] AuthSettings) { - - var request = new RestRequest(Path, Method); - - UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings); - - // add default header, if any - foreach(KeyValuePair - defaultHeader in this.defaultHeaderMap) - request.AddHeader(defaultHeader.Key, defaultHeader.Value); - - // add header parameter, if any - foreach(KeyValuePair - param in HeaderParams) - request.AddHeader(param.Key, param.Value); - - // add query parameter, if any - foreach(KeyValuePair - param in QueryParams) - request.AddQueryParameter(param.Key, param.Value); - - // add form parameter, if any - foreach(KeyValuePair - param in FormParams) - request.AddParameter(param.Key, param.Value); - - // add file parameter, if any - foreach(KeyValuePair - param in FileParams) - request.AddFile(param.Key, param.Value); - - if (PostBody != null) { - request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter + public Object CallApi(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody, + Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, String[] AuthSettings) { + var response = Task.Run(async () => { + var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings); + return resp; + }); + return response.Result; } - return (Object) await restClient.ExecuteTaskAsync(request); + public async Task CallApiAsync(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody, + Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, String[] AuthSettings) { + + var request = new RestRequest(Path, Method); + + UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings); + + // add default header, if any + foreach(KeyValuePair defaultHeader in this.defaultHeaderMap) + request.AddHeader(defaultHeader.Key, defaultHeader.Value); + + // add header parameter, if any + foreach(KeyValuePair param in HeaderParams) + request.AddHeader(param.Key, param.Value); + + // add query parameter, if any + foreach(KeyValuePair param in QueryParams) + request.AddQueryParameter(param.Key, param.Value); + + // add form parameter, if any + foreach(KeyValuePair param in FormParams) + request.AddParameter(param.Key, param.Value); + + // add file parameter, if any + foreach(KeyValuePair param in FileParams) + request.AddFile(param.Key, param.Value); + + if (PostBody != null) { + request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter + } + + return (Object) await restClient.ExecuteTaskAsync(request); } - /// - - /// Add default header - /// - - /// - - Header field name - /// - - Header field value - /// - + /// + /// Add default header + /// + /// Header field name + /// Header field value + /// public void AddDefaultHeader(string key, string value) { - defaultHeaderMap.Add(key, value); + defaultHeaderMap.Add(key, value); } - /// - - /// Get default header - /// - - /// - Dictionary of default header - public Dictionary - GetDefaultHeader() { - return defaultHeaderMap; + /// + /// Get default header + /// + /// Dictionary of default header + public Dictionary GetDefaultHeader() { + return defaultHeaderMap; } - /// - - /// escape string (url-encoded) - /// - - /// - - String to be escaped - /// - Escaped string + /// + /// escape string (url-encoded) + /// + /// String to be escaped + /// Escaped string public string EscapeString(string str) { - return str; + return str; } - /// - - /// if parameter is DateTime, output in ISO8601 format - /// if parameter is a list of string, join the list with "," - /// otherwise just return the string - /// - - /// - - The parameter (header, path, query, form) - /// - Formatted string + /// + /// if parameter is DateTime, output in ISO8601 format + /// if parameter is a list of string, join the list with "," + /// otherwise just return the string + /// + /// The parameter (header, path, query, form) + /// Formatted string public string ParameterToString(object obj) { - if (obj is DateTime) { - return ((DateTime)obj).ToString ("u"); - } else if (obj is List - ) { - return String.Join(",", obj as List - ); - } else { - return Convert.ToString (obj); - } - } + if (obj is DateTime) { + return ((DateTime)obj).ToString ("u"); + } else if (obj is List) { + return String.Join(",", obj as List); + } else { + return Convert.ToString (obj); + } + } - /// - - /// Deserialize the JSON string into a proper object - /// - - /// - - JSON string - /// - - Object type - /// - Object representation of the JSON string - public object Deserialize(string content, Type type) { - if (type.GetType() == typeof(Object)) - return (Object)content; + /// + /// Deserialize the JSON string into a proper object + /// + /// JSON string + /// Object type + /// Object representation of the JSON string + public object Deserialize(string content, Type type) { + if (type.GetType() == typeof(Object)) + return (Object)content; - try - { - return JsonConvert.DeserializeObject(content, type); - } - catch (IOException e) { - throw new ApiException(500, e.Message); - } - } + try + { + return JsonConvert.DeserializeObject(content, type); + } + catch (IOException e) { + throw new ApiException(500, e.Message); + } + } - /// - - /// Serialize an object into JSON string - /// - - /// - - Object - /// - JSON string - public string Serialize(object obj) { - try - { - return obj != null ? JsonConvert.SerializeObject(obj) : null; - } - catch (Exception e) { - throw new ApiException(500, e.Message); - } - } + /// + /// Serialize an object into JSON string + /// + /// Object + /// JSON string + public string Serialize(object obj) { + try + { + return obj != null ? JsonConvert.SerializeObject(obj) : null; + } + catch (Exception e) { + throw new ApiException(500, e.Message); + } + } - /// - - /// Get the API key with prefix - /// - - /// - - Object - /// - API key with prefix - public string GetApiKeyWithPrefix (string apiKey) - { - var apiKeyValue = ""; - Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue); - var apiKeyPrefix = ""; - if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) { - return apiKeyPrefix + " " + apiKeyValue; - } else { - return apiKeyValue; - } - } + /// + /// Get the API key with prefix + /// + /// Object + /// API key with prefix + public string GetApiKeyWithPrefix (string apiKey) + { + var apiKeyValue = ""; + Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue); + var apiKeyPrefix = ""; + if (Configuration.apiKeyPrefix.TryGetValue (apiKey, 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) { + /// + /// 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": + HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key"); - case "api_key": - HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key - "); - - break; - - case "petstore_auth": - - //TODO support oauth - break; - - default: - //TODO show warning about security definition not found break; - } - } + + case "petstore_auth": + + //TODO support oauth + break; + + default: + //TODO show warning about security definition not found + break; + } + } - } + } - /// - - /// Encode string in base64 format - /// - - /// - - String to be encoded - public static string Base64Encode(string text) { - var textByte = System.Text.Encoding.UTF8.GetBytes(text); - return System.Convert.ToBase64String(textByte); - } + /// + /// Encode string in base64 format + /// + /// String to be encoded + public static string Base64Encode(string text) { + var textByte = System.Text.Encoding.UTF8.GetBytes(text); + return System.Convert.ToBase64String(textByte); + } - } - } + } +} diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs index d668e0b3a6..f9cf380e68 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs @@ -1,61 +1,42 @@ using System; namespace IO.Swagger.Client { -/// - - /// API Exception - /// - -public class ApiException : Exception { -/// - + /// + /// 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; } + /// + /// 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; } + /// + /// The error content (Http response body). + public dynamic ErrorContent { get; private set; } -/// - - /// Initializes a new instance of the - - class. - /// - -/// -The base path. -public ApiException() {} + /// + /// Initializes a new instance of the class. + /// + /// The base path. + 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. + public ApiException(int errorCode, string message) : base(message) { + this.ErrorCode = errorCode; + } -public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { -this.ErrorCode = errorCode; -this.ErrorContent = errorContent; -} - -} + public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { + this.ErrorCode = errorCode; + this.ErrorContent = errorContent; + } + + } } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/Configuration.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/Configuration.cs index 7e41272740..4e7975e3ad 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/Configuration.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/Configuration.cs @@ -7,62 +7,41 @@ using System.Text; using IO.Swagger.Client; namespace IO.Swagger.Client { -/// - - /// Represents a set of configuration settings - /// - -public class Configuration{ + /// + /// Represents a set of configuration settings + /// + public class Configuration{ -/// - + /// /// Gets or sets the API client. This is the default API client for making HTTP calls. - /// - -/// -The API client. -public static ApiClient apiClient = new ApiClient(); + /// + /// The API client. + public static ApiClient apiClient = new ApiClient(); -/// - + /// /// Gets or sets the username (HTTP basic authentication) - /// - -/// -The username. -public static String username { get; set; } + /// + /// The username. + public static String username { get; set; } -/// - + /// /// Gets or sets the password (HTTP basic authentication) - /// - -/// -The password. -public static String password { get; set; } + /// + /// The password. + public static String password { get; set; } -/// - - /// Gets or sets the API key based on the authentication name - /// - -/// -The API key. -public static Dictionary - apiKey = new Dictionary -(); + /// + /// Gets or sets the API key based on the authentication name + /// + /// The API key. + public static 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 -(); + /// + /// 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(); -} + } } diff --git a/samples/client/petstore/python/SwaggerPetstore-python/README.md b/samples/client/petstore/python/SwaggerPetstore-python/README.md index f4e99c9fbc..9c590a9a50 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/README.md +++ b/samples/client/petstore/python/SwaggerPetstore-python/README.md @@ -67,8 +67,8 @@ If you want to run the tests in all the python platforms: ```sh $ make test-all [... tox creates a virtualenv for every platform and runs tests inside of each] -py27: commands succeeded -py34: commands succeeded -congratulations :) + py27: commands succeeded + py34: commands succeeded + congratulations :) ``` diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/api_client.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/api_client.py index fc0e7c6054..b8cc4cc2a8 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/api_client.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/api_client.py @@ -22,282 +22,282 @@ import random from six import iteritems try: -# for python3 -from urllib.parse import quote + # for python3 + from urllib.parse import quote except ImportError: -# for python2 -from urllib import quote + # for python2 + from urllib import quote from . import configuration class ApiClient(object): -""" -Generic API client for Swagger client library builds + """ + Generic API client for Swagger client library builds -:param host: The base path for the server to call -:param header_name: a header to pass when making calls to the API -:param header_value: a header value to pass when making calls to the API -""" -def __init__(self, host=configuration.host, header_name=None, header_value=None): -self.default_headers = {} -if header_name is not None: -self.default_headers[header_name] = header_value -self.host = host -self.cookie = None -# Set default User-Agent. -self.user_agent = 'Python-Swagger' + :param host: The base path for the server to call + :param header_name: a header to pass when making calls to the API + :param header_value: a header value to pass when making calls to the API + """ + def __init__(self, host=configuration.host, header_name=None, header_value=None): + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.host = host + self.cookie = None + # Set default User-Agent. + self.user_agent = 'Python-Swagger' -@property -def user_agent(self): -return self.default_headers['User-Agent'] + @property + def user_agent(self): + return self.default_headers['User-Agent'] -@user_agent.setter -def user_agent(self, value): -self.default_headers['User-Agent'] = value + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value -def set_default_header(self, header_name, header_value): -self.default_headers[header_name] = header_value + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value -def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, -body=None, post_params=None, files=None, response=None, auth_settings=None): + def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, response=None, auth_settings=None): -# headers parameters -header_params = header_params or {} -header_params.update(self.default_headers) -if self.cookie: -header_params['Cookie'] = self.cookie -if header_params: -header_params = self.sanitize_for_serialization(header_params) + # headers parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) -# path parameters -if path_params: -path_params = self.sanitize_for_serialization(path_params) -for k, v in iteritems(path_params): -replacement = quote(str(self.to_path_value(v))) -resource_path = resource_path.replace('{' + k + '}', replacement) + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + for k, v in iteritems(path_params): + replacement = quote(str(self.to_path_value(v))) + resource_path = resource_path.replace('{' + k + '}', replacement) -# query parameters -if query_params: -query_params = self.sanitize_for_serialization(query_params) -query_params = {k: self.to_path_value(v) for k, v in iteritems(query_params)} + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = {k: self.to_path_value(v) for k, v in iteritems(query_params)} -# post parameters -if post_params: -post_params = self.prepare_post_parameters(post_params, files) -post_params = self.sanitize_for_serialization(post_params) + # post parameters + if post_params: + post_params = self.prepare_post_parameters(post_params, files) + post_params = self.sanitize_for_serialization(post_params) -# auth setting -self.update_params_for_auth(header_params, query_params, auth_settings) + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) -# body -if body: -body = self.sanitize_for_serialization(body) + # body + if body: + body = self.sanitize_for_serialization(body) -# request url -url = self.host + resource_path + # request url + url = self.host + resource_path -# perform request and return response -response_data = self.request(method, url, query_params=query_params, headers=header_params, -post_params=post_params, body=body) + # perform request and return response + response_data = self.request(method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body) -# deserialize response data -if response: -return self.deserialize(response_data, response) -else: -return None + # deserialize response data + if response: + return self.deserialize(response_data, response) + else: + return None -def to_path_value(self, obj): -""" -Convert a string or object to a path-friendly value + def to_path_value(self, obj): + """ + Convert a string or object to a path-friendly value -:param obj: object or string value + :param obj: object or string value -:return string: quoted value -""" -if type(obj) == list: -return ','.join(obj) -else: -return str(obj) + :return string: quoted value + """ + if type(obj) == list: + return ','.join(obj) + else: + return str(obj) -def sanitize_for_serialization(self, obj): -""" -Sanitize an object for Request. + def sanitize_for_serialization(self, obj): + """ + Sanitize an object for Request. -If obj is None, return None. -If obj is str, int, float, bool, return directly. -If obj is datetime.datetime, datetime.date convert to string in iso8601 format. -If obj is list, santize each element in the list. -If obj is dict, return the dict. -If obj is swagger model, return the properties dict. -""" -if isinstance(obj, type(None)): -return None -elif isinstance(obj, (str, int, float, bool, tuple)): -return obj -elif isinstance(obj, list): -return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] -elif isinstance(obj, (datetime.datetime, datetime.date)): -return obj.isoformat() -else: -if isinstance(obj, dict): -obj_dict = obj -else: -# Convert model obj to dict except attributes `swagger_types`, `attribute_map` -# and attributes which value is not None. -# Convert attribute name to json key in model definition for request. -obj_dict = {obj.attribute_map[key]: val -for key, val in iteritems(obj.__dict__) -if key != 'swagger_types' and key != 'attribute_map' and val is not None} -return {key: self.sanitize_for_serialization(val) -for key, val in iteritems(obj_dict)} + If obj is None, return None. + If obj is str, int, float, bool, return directly. + If obj is datetime.datetime, datetime.date convert to string in iso8601 format. + If obj is list, santize each element in the list. + If obj is dict, return the dict. + If obj is swagger model, return the properties dict. + """ + if isinstance(obj, type(None)): + return None + elif isinstance(obj, (str, int, float, bool, tuple)): + return obj + elif isinstance(obj, list): + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, (datetime.datetime, datetime.date)): + return obj.isoformat() + else: + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except attributes `swagger_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in model definition for request. + obj_dict = {obj.attribute_map[key]: val + for key, val in iteritems(obj.__dict__) + if key != 'swagger_types' and key != 'attribute_map' and val is not None} + return {key: self.sanitize_for_serialization(val) + for key, val in iteritems(obj_dict)} -def deserialize(self, obj, obj_class): -""" -Derialize a JSON string into an object. + def deserialize(self, obj, obj_class): + """ + Derialize a JSON string into an object. -:param obj: string or object to be deserialized -:param obj_class: class literal for deserialzied object, or string of class name + :param obj: string or object to be deserialized + :param obj_class: class literal for deserialzied object, or string of class name -:return object: deserialized object -""" -# Have to accept obj_class as string or actual type. Type could be a -# native Python type, or one of the model classes. -if type(obj_class) == str: -if 'list[' in obj_class: -match = re.match('list\[(.*)\]', obj_class) -sub_class = match.group(1) -return [self.deserialize(sub_obj, sub_class) for sub_obj in obj] + :return object: deserialized object + """ + # Have to accept obj_class as string or actual type. Type could be a + # native Python type, or one of the model classes. + if type(obj_class) == str: + if 'list[' in obj_class: + match = re.match('list\[(.*)\]', obj_class) + sub_class = match.group(1) + return [self.deserialize(sub_obj, sub_class) for sub_obj in obj] -if obj_class in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']: -obj_class = eval(obj_class) -else: # not a native type, must be model class -obj_class = eval('models.' + obj_class) + if obj_class in ['int', 'float', 'dict', 'list', 'str', 'bool', 'datetime']: + obj_class = eval(obj_class) + else: # not a native type, must be model class + obj_class = eval('models.' + obj_class) -if obj_class in [int, float, dict, list, str, bool]: -return obj_class(obj) -elif obj_class == datetime: -return self.__parse_string_to_datetime(obj) + if obj_class in [int, float, dict, list, str, bool]: + return obj_class(obj) + elif obj_class == datetime: + return self.__parse_string_to_datetime(obj) -instance = obj_class() + instance = obj_class() -for attr, attr_type in iteritems(instance.swagger_types): -if obj is not None and instance.attribute_map[attr] in obj and type(obj) in [list, dict]: -value = obj[instance.attribute_map[attr]] -if attr_type in ['str', 'int', 'float', 'bool']: -attr_type = eval(attr_type) -try: -value = attr_type(value) -except UnicodeEncodeError: -value = unicode(value) -except TypeError: -value = value -setattr(instance, attr, value) -elif attr_type == 'datetime': -setattr(instance, attr, self.__parse_string_to_datetime(value)) -elif 'list[' in attr_type: -match = re.match('list\[(.*)\]', attr_type) -sub_class = match.group(1) -sub_values = [] -if not value: -setattr(instance, attr, None) -else: -for sub_value in value: -sub_values.append(self.deserialize(sub_value, sub_class)) -setattr(instance, attr, sub_values) -else: -setattr(instance, attr, self.deserialize(value, attr_type)) + for attr, attr_type in iteritems(instance.swagger_types): + if obj is not None and instance.attribute_map[attr] in obj and type(obj) in [list, dict]: + value = obj[instance.attribute_map[attr]] + if attr_type in ['str', 'int', 'float', 'bool']: + attr_type = eval(attr_type) + try: + value = attr_type(value) + except UnicodeEncodeError: + value = unicode(value) + except TypeError: + value = value + setattr(instance, attr, value) + elif attr_type == 'datetime': + setattr(instance, attr, self.__parse_string_to_datetime(value)) + elif 'list[' in attr_type: + match = re.match('list\[(.*)\]', attr_type) + sub_class = match.group(1) + sub_values = [] + if not value: + setattr(instance, attr, None) + else: + for sub_value in value: + sub_values.append(self.deserialize(sub_value, sub_class)) + setattr(instance, attr, sub_values) + else: + setattr(instance, attr, self.deserialize(value, attr_type)) -return instance + return instance -def __parse_string_to_datetime(self, string): -""" -Parse datetime in string to datetime. + def __parse_string_to_datetime(self, string): + """ + Parse datetime in string to datetime. -The string should be in iso8601 datetime format. -""" -try: -from dateutil.parser import parse -return parse(string) -except ImportError: -return string + The string should be in iso8601 datetime format. + """ + try: + from dateutil.parser import parse + return parse(string) + except ImportError: + return string -def request(self, method, url, query_params=None, headers=None, post_params=None, body=None): -""" -Perform http request using RESTClient. -""" -if method == "GET": -return RESTClient.GET(url, query_params=query_params, headers=headers) -elif method == "HEAD": -return RESTClient.HEAD(url, query_params=query_params, headers=headers) -elif method == "POST": -return RESTClient.POST(url, headers=headers, post_params=post_params, body=body) -elif method == "PUT": -return RESTClient.PUT(url, headers=headers, post_params=post_params, body=body) -elif method == "PATCH": -return RESTClient.PATCH(url, headers=headers, post_params=post_params, body=body) -elif method == "DELETE": -return RESTClient.DELETE(url, query_params=query_params, headers=headers) -else: -raise ValueError("http method must be `GET`, `HEAD`, `POST`, `PATCH`, `PUT` or `DELETE`") + def request(self, method, url, query_params=None, headers=None, post_params=None, body=None): + """ + Perform http request using RESTClient. + """ + if method == "GET": + return RESTClient.GET(url, query_params=query_params, headers=headers) + elif method == "HEAD": + return RESTClient.HEAD(url, query_params=query_params, headers=headers) + elif method == "POST": + return RESTClient.POST(url, headers=headers, post_params=post_params, body=body) + elif method == "PUT": + return RESTClient.PUT(url, headers=headers, post_params=post_params, body=body) + elif method == "PATCH": + return RESTClient.PATCH(url, headers=headers, post_params=post_params, body=body) + elif method == "DELETE": + return RESTClient.DELETE(url, query_params=query_params, headers=headers) + else: + raise ValueError("http method must be `GET`, `HEAD`, `POST`, `PATCH`, `PUT` or `DELETE`") -def prepare_post_parameters(self, post_params=None, files=None): -params = {} + def prepare_post_parameters(self, post_params=None, files=None): + params = {} -if post_params: -params.update(post_params) + if post_params: + params.update(post_params) -if files: -for k, v in iteritems(files): -if v: -with open(v, 'rb') as f: -filename = os.path.basename(f.name) -filedata = f.read() -mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' -params[k] = tuple([filename, filedata, mimetype]) + if files: + for k, v in iteritems(files): + if v: + with open(v, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' + params[k] = tuple([filename, filedata, mimetype]) -return params + return params -def select_header_accept(self, accepts): -""" -Return `Accept` based on an array of accepts provided -""" -if not accepts: -return + def select_header_accept(self, accepts): + """ + Return `Accept` based on an array of accepts provided + """ + if not accepts: + return -accepts = list(map(lambda x: x.lower(), accepts)) + accepts = list(map(lambda x: x.lower(), accepts)) -if 'application/json' in accepts: -return 'application/json' -else: -return ', '.join(accepts) + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) -def select_header_content_type(self, content_types): -""" -Return `Content-Type` baseed on an array of content_types provided -""" -if not content_types: -return 'application/json' + def select_header_content_type(self, content_types): + """ + Return `Content-Type` baseed on an array of content_types provided + """ + if not content_types: + return 'application/json' -content_types = list(map(lambda x: x.lower(), content_types)) + content_types = list(map(lambda x: x.lower(), content_types)) -if 'application/json' in content_types: -return 'application/json' -else: -return content_types[0] + if 'application/json' in content_types: + return 'application/json' + else: + return content_types[0] -def update_params_for_auth(self, headers, querys, auth_settings): -""" -Update header and query params based on authentication setting -""" -if not auth_settings: -return - -for auth in auth_settings: -auth_setting = configuration.auth_settings().get(auth) -if auth_setting: -if auth_setting['in'] == 'header': -headers[auth_setting['key']] = auth_setting['value'] -elif auth_setting['in'] == 'query': -querys[auth_setting['key']] = auth_setting['value'] -else: -raise ValueError('Authentication token must be in `query` or `header`') + def update_params_for_auth(self, headers, querys, auth_settings): + """ + Update header and query params based on authentication setting + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = configuration.auth_settings().get(auth) + if auth_setting: + if auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys[auth_setting['key']] = auth_setting['value'] + else: + raise ValueError('Authentication token must be in `query` or `header`') diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/pet_api.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/pet_api.py index cb262e4534..5f5c2fe81f 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/pet_api.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/pet_api.py @@ -5,17 +5,17 @@ PetApi.py Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ @@ -30,18 +30,18 @@ from six import iteritems from .. import configuration from ..api_client import ApiClient - class PetApi(object): +class PetApi(object): def __init__(self, api_client=None): - if api_client: - self.api_client = api_client - else: - if not configuration.api_client: - configuration.api_client = ApiClient('http://petstore.swagger.io/v2') - self.api_client = configuration.api_client - + if api_client: + self.api_client = api_client + else: + if not configuration.api_client: + configuration.api_client = ApiClient('http://petstore.swagger.io/v2') + self.api_client = configuration.api_client - def update_pet(self, **kwargs): + + def update_pet(self, **kwargs): """ Update an existing pet @@ -55,9 +55,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method update_pet" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method update_pet" % key) + params[key] = val del params['kwargs'] resource_path = '/pet'.replace('{format}', 'json') @@ -74,13 +74,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json', 'application/xml']) @@ -89,10 +89,10 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def add_pet(self, **kwargs): + def add_pet(self, **kwargs): """ Add a new pet to the store @@ -106,9 +106,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method add_pet" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method add_pet" % key) + params[key] = val del params['kwargs'] resource_path = '/pet'.replace('{format}', 'json') @@ -125,13 +125,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type(['application/json', 'application/xml']) @@ -140,10 +140,10 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def find_pets_by_status(self, **kwargs): + def find_pets_by_status(self, **kwargs): """ Finds Pets by status Multiple status values can be provided with comma seperated strings @@ -157,9 +157,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_status" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_status" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/findByStatus'.replace('{format}', 'json') @@ -169,7 +169,7 @@ from ..api_client import ApiClient query_params = {} - if 'status' in params: + if 'status' in params: query_params['status'] = params['status'] header_params = {} @@ -182,7 +182,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -191,12 +191,12 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='list[Pet]', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='list[Pet]', auth_settings=auth_settings) - return response + return response - def find_pets_by_tags(self, **kwargs): + def find_pets_by_tags(self, **kwargs): """ Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. @@ -210,9 +210,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_tags" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method find_pets_by_tags" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/findByTags'.replace('{format}', 'json') @@ -222,7 +222,7 @@ from ..api_client import ApiClient query_params = {} - if 'tags' in params: + if 'tags' in params: query_params['tags'] = params['tags'] header_params = {} @@ -235,7 +235,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -244,12 +244,12 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='list[Pet]', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='list[Pet]', auth_settings=auth_settings) - return response + return response - def get_pet_by_id(self, pet_id, **kwargs): + def get_pet_by_id(self, pet_id, **kwargs): """ Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -259,17 +259,17 @@ from ..api_client import ApiClient :return: Pet """ - # verify the required parameter 'pet_id' is set - if pet_id is None: + # verify the required parameter 'pet_id' is set + if pet_id is None: raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") all_params = ['pet_id'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method get_pet_by_id" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method get_pet_by_id" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/{petId}'.replace('{format}', 'json') @@ -277,8 +277,8 @@ from ..api_client import ApiClient path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] query_params = {} @@ -292,7 +292,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -301,12 +301,12 @@ from ..api_client import ApiClient auth_settings = ['api_key', 'petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='Pet', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='Pet', auth_settings=auth_settings) - return response + return response - def update_pet_with_form(self, pet_id, **kwargs): + def update_pet_with_form(self, pet_id, **kwargs): """ Updates a pet in the store with form data @@ -318,17 +318,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'pet_id' is set - if pet_id is None: + # verify the required parameter 'pet_id' is set + if pet_id is None: raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") all_params = ['pet_id', 'name', 'status'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method update_pet_with_form" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method update_pet_with_form" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/{petId}'.replace('{format}', 'json') @@ -336,8 +336,8 @@ from ..api_client import ApiClient path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] query_params = {} @@ -346,10 +346,10 @@ from ..api_client import ApiClient form_params = {} files = {} - if 'name' in params: + if 'name' in params: form_params['name'] = params['name'] - if 'status' in params: + if 'status' in params: form_params['status'] = params['status'] body_params = None @@ -357,7 +357,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type(['application/x-www-form-urlencoded']) @@ -366,10 +366,10 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def delete_pet(self, pet_id, **kwargs): + def delete_pet(self, pet_id, **kwargs): """ Deletes a pet @@ -380,17 +380,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'pet_id' is set - if pet_id is None: + # verify the required parameter 'pet_id' is set + if pet_id is None: raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") all_params = ['api_key', 'pet_id'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method delete_pet" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method delete_pet" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/{petId}'.replace('{format}', 'json') @@ -398,14 +398,14 @@ from ..api_client import ApiClient path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] query_params = {} header_params = {} - if 'api_key' in params: + if 'api_key' in params: header_params['api_key'] = params['api_key'] form_params = {} @@ -416,7 +416,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -425,10 +425,10 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def upload_file(self, pet_id, **kwargs): + def upload_file(self, pet_id, **kwargs): """ uploads an image @@ -440,17 +440,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'pet_id' is set - if pet_id is None: + # verify the required parameter 'pet_id' is set + if pet_id is None: raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") all_params = ['pet_id', 'additional_metadata', 'file'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method upload_file" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method upload_file" % key) + params[key] = val del params['kwargs'] resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') @@ -458,8 +458,8 @@ from ..api_client import ApiClient path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] query_params = {} @@ -468,10 +468,10 @@ from ..api_client import ApiClient form_params = {} files = {} - if 'additional_metadata' in params: + if 'additional_metadata' in params: form_params['additionalMetadata'] = params['additional_metadata'] - if 'file' in params: + if 'file' in params: files['file'] = params['file'] body_params = None @@ -479,7 +479,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type(['multipart/form-data']) @@ -488,8 +488,8 @@ from ..api_client import ApiClient auth_settings = ['petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/store_api.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/store_api.py index 4483ea01bd..1523e3b4be 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/store_api.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/store_api.py @@ -5,17 +5,17 @@ StoreApi.py Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ @@ -30,18 +30,18 @@ from six import iteritems from .. import configuration from ..api_client import ApiClient - class StoreApi(object): +class StoreApi(object): def __init__(self, api_client=None): - if api_client: - self.api_client = api_client - else: - if not configuration.api_client: - configuration.api_client = ApiClient('http://petstore.swagger.io/v2') - self.api_client = configuration.api_client - + if api_client: + self.api_client = api_client + else: + if not configuration.api_client: + configuration.api_client = ApiClient('http://petstore.swagger.io/v2') + self.api_client = configuration.api_client - def get_inventory(self, **kwargs): + + def get_inventory(self, **kwargs): """ Returns pet inventories by status Returns a map of status codes to quantities @@ -54,9 +54,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method get_inventory" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method get_inventory" % key) + params[key] = val del params['kwargs'] resource_path = '/store/inventory'.replace('{format}', 'json') @@ -76,7 +76,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -85,12 +85,12 @@ from ..api_client import ApiClient auth_settings = ['api_key'] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='map(String, int)', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='map(String, int)', auth_settings=auth_settings) - return response + return response - def place_order(self, **kwargs): + def place_order(self, **kwargs): """ Place an order for a pet @@ -104,9 +104,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method place_order" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method place_order" % key) + params[key] = val del params['kwargs'] resource_path = '/store/order'.replace('{format}', 'json') @@ -123,13 +123,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -138,12 +138,12 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='Order', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='Order', auth_settings=auth_settings) - return response + return response - def get_order_by_id(self, order_id, **kwargs): + def get_order_by_id(self, order_id, **kwargs): """ Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -153,17 +153,17 @@ from ..api_client import ApiClient :return: Order """ - # verify the required parameter 'order_id' is set - if order_id is None: + # verify the required parameter 'order_id' is set + if order_id is None: raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") all_params = ['order_id'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method get_order_by_id" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method get_order_by_id" % key) + params[key] = val del params['kwargs'] resource_path = '/store/order/{orderId}'.replace('{format}', 'json') @@ -171,8 +171,8 @@ from ..api_client import ApiClient path_params = {} - if 'order_id' in params: - path_params['orderId'] = params['order_id'] + if 'order_id' in params: + path_params['orderId'] = params['order_id'] query_params = {} @@ -186,7 +186,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -195,12 +195,12 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='Order', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='Order', auth_settings=auth_settings) - return response + return response - def delete_order(self, order_id, **kwargs): + def delete_order(self, order_id, **kwargs): """ Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -210,17 +210,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'order_id' is set - if order_id is None: + # verify the required parameter 'order_id' is set + if order_id is None: raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") all_params = ['order_id'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method delete_order" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method delete_order" % key) + params[key] = val del params['kwargs'] resource_path = '/store/order/{orderId}'.replace('{format}', 'json') @@ -228,8 +228,8 @@ from ..api_client import ApiClient path_params = {} - if 'order_id' in params: - path_params['orderId'] = params['order_id'] + if 'order_id' in params: + path_params['orderId'] = params['order_id'] query_params = {} @@ -243,7 +243,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -252,8 +252,8 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/user_api.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/user_api.py index 893e5e3a5c..84a40b0657 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/user_api.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/apis/user_api.py @@ -5,17 +5,17 @@ UserApi.py Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ @@ -30,18 +30,18 @@ from six import iteritems from .. import configuration from ..api_client import ApiClient - class UserApi(object): +class UserApi(object): def __init__(self, api_client=None): - if api_client: - self.api_client = api_client - else: - if not configuration.api_client: - configuration.api_client = ApiClient('http://petstore.swagger.io/v2') - self.api_client = configuration.api_client - + if api_client: + self.api_client = api_client + else: + if not configuration.api_client: + configuration.api_client = ApiClient('http://petstore.swagger.io/v2') + self.api_client = configuration.api_client - def create_user(self, **kwargs): + + def create_user(self, **kwargs): """ Create user This can only be done by the logged in user. @@ -55,9 +55,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method create_user" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method create_user" % key) + params[key] = val del params['kwargs'] resource_path = '/user'.replace('{format}', 'json') @@ -74,13 +74,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -89,10 +89,10 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def create_users_with_array_input(self, **kwargs): + def create_users_with_array_input(self, **kwargs): """ Creates list of users with given input array @@ -106,9 +106,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_array_input" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_array_input" % key) + params[key] = val del params['kwargs'] resource_path = '/user/createWithArray'.replace('{format}', 'json') @@ -125,13 +125,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -140,10 +140,10 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def create_users_with_list_input(self, **kwargs): + def create_users_with_list_input(self, **kwargs): """ Creates list of users with given input array @@ -157,9 +157,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_list_input" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method create_users_with_list_input" % key) + params[key] = val del params['kwargs'] resource_path = '/user/createWithList'.replace('{format}', 'json') @@ -176,13 +176,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -191,10 +191,10 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def login_user(self, **kwargs): + def login_user(self, **kwargs): """ Logs user into the system @@ -209,9 +209,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method login_user" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method login_user" % key) + params[key] = val del params['kwargs'] resource_path = '/user/login'.replace('{format}', 'json') @@ -221,10 +221,10 @@ from ..api_client import ApiClient query_params = {} - if 'username' in params: + if 'username' in params: query_params['username'] = params['username'] - if 'password' in params: + if 'password' in params: query_params['password'] = params['password'] header_params = {} @@ -237,7 +237,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -246,12 +246,12 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='str', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='str', auth_settings=auth_settings) - return response + return response - def logout_user(self, **kwargs): + def logout_user(self, **kwargs): """ Logs out current logged in user session @@ -264,9 +264,9 @@ from ..api_client import ApiClient params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method logout_user" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method logout_user" % key) + params[key] = val del params['kwargs'] resource_path = '/user/logout'.replace('{format}', 'json') @@ -286,7 +286,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -295,10 +295,10 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def get_user_by_name(self, username, **kwargs): + def get_user_by_name(self, username, **kwargs): """ Get user by user name @@ -308,17 +308,17 @@ from ..api_client import ApiClient :return: User """ - # verify the required parameter 'username' is set - if username is None: + # verify the required parameter 'username' is set + if username is None: raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") all_params = ['username'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method get_user_by_name" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method get_user_by_name" % key) + params[key] = val del params['kwargs'] resource_path = '/user/{username}'.replace('{format}', 'json') @@ -326,8 +326,8 @@ from ..api_client import ApiClient path_params = {} - if 'username' in params: - path_params['username'] = params['username'] + if 'username' in params: + path_params['username'] = params['username'] query_params = {} @@ -341,7 +341,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -350,12 +350,12 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response='User', auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response='User', auth_settings=auth_settings) - return response + return response - def update_user(self, username, **kwargs): + def update_user(self, username, **kwargs): """ Updated user This can only be done by the logged in user. @@ -366,17 +366,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'username' is set - if username is None: + # verify the required parameter 'username' is set + if username is None: raise ValueError("Missing the required parameter `username` when calling `update_user`") all_params = ['username', 'body'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method update_user" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method update_user" % key) + params[key] = val del params['kwargs'] resource_path = '/user/{username}'.replace('{format}', 'json') @@ -384,8 +384,8 @@ from ..api_client import ApiClient path_params = {} - if 'username' in params: - path_params['username'] = params['username'] + if 'username' in params: + path_params['username'] = params['username'] query_params = {} @@ -396,13 +396,13 @@ from ..api_client import ApiClient body_params = None - if 'body' in params: + if 'body' in params: body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -411,10 +411,10 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) - def delete_user(self, username, **kwargs): + def delete_user(self, username, **kwargs): """ Delete user This can only be done by the logged in user. @@ -424,17 +424,17 @@ from ..api_client import ApiClient :return: None """ - # verify the required parameter 'username' is set - if username is None: + # verify the required parameter 'username' is set + if username is None: raise ValueError("Missing the required parameter `username` when calling `delete_user`") all_params = ['username'] params = locals() for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError("Got an unexpected keyword argument '%s' to method delete_user" % key) - params[key] = val + if key not in all_params: + raise TypeError("Got an unexpected keyword argument '%s' to method delete_user" % key) + params[key] = val del params['kwargs'] resource_path = '/user/{username}'.replace('{format}', 'json') @@ -442,8 +442,8 @@ from ..api_client import ApiClient path_params = {} - if 'username' in params: - path_params['username'] = params['username'] + if 'username' in params: + path_params['username'] = params['username'] query_params = {} @@ -457,7 +457,7 @@ from ..api_client import ApiClient # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept(['application/json', 'application/xml']) if not header_params['Accept']: - del header_params['Accept'] + del header_params['Accept'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type([]) @@ -466,8 +466,8 @@ from ..api_client import ApiClient auth_settings = [] response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params, - body=body_params, post_params=form_params, files=files, - response=None, auth_settings=auth_settings) + body=body_params, post_params=form_params, files=files, + response=None, auth_settings=auth_settings) diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/configuration.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/configuration.py index c7b3d5af14..b5bd0a64e0 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/configuration.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/configuration.py @@ -3,37 +3,37 @@ import base64 import urllib3 def get_api_key_with_prefix(key): -global api_key -global api_key_prefix + global api_key + global api_key_prefix -if api_key.get(key) and api_key_prefix.get(key): -return api_key_prefix[key] + ' ' + api_key[key] -elif api_key.get(key): -return api_key[key] + if api_key.get(key) and api_key_prefix.get(key): + return api_key_prefix[key] + ' ' + api_key[key] + elif api_key.get(key): + return api_key[key] def get_basic_auth_token(): -global username -global password + global username + global password -return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization') + return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization') def auth_settings(): -return { - 'api_key': { - 'type': 'api_key', - 'in': 'header', - 'key': 'api_key', - 'value': get_api_key_with_prefix('api_key') - }, - -} + return { + 'api_key': { + 'type': 'api_key', + 'in': 'header', + 'key': 'api_key', + 'value': get_api_key_with_prefix('api_key') + }, + + } # Default Base url host = "http://petstore.swagger.io/v2" # Default api client api_client = None - + # Authentication settings api_key = {} diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py index ada2f33efd..cfd69ee955 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py @@ -4,27 +4,26 @@ """ Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. """ - - class Category(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ +class Category(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ - def __init__(self): + def __init__(self): """ Swagger model @@ -32,29 +31,28 @@ limitations under the License. :param dict attributeMap: The key is attribute name and the value is json key in definition. """ self.swagger_types = { - 'id': 'int', - 'name': 'str' + 'id': 'int', + 'name': 'str' } self.attribute_map = { - 'id': 'id', - 'name': 'name' + 'id': 'id', + 'name': 'name' } - - self.id = None # int - - self.name = None # str + self.id = None # int + + + self.name = None # str - def __repr__(self): + def __repr__(self): properties = [] for p in self.__dict__: - if p != 'swaggerTypes' and p != 'attributeMap': - properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) + if p != 'swaggerTypes' and p != 'attributeMap': + properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) return '<{name} {props}>'.format(name=__name__, props=' '.join(properties)) - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py index 02f3d75bb9..e364ba5b15 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py @@ -4,27 +4,26 @@ """ Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. """ - - class Order(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ +class Order(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ - def __init__(self): + def __init__(self): """ Swagger model @@ -32,49 +31,48 @@ limitations under the License. :param dict attributeMap: The key is attribute name and the value is json key in definition. """ self.swagger_types = { - 'id': 'int', - 'pet_id': 'int', - 'quantity': 'int', - 'ship_date': 'DateTime', - 'status': 'str', - 'complete': 'bool' + 'id': 'int', + 'pet_id': 'int', + 'quantity': 'int', + 'ship_date': 'DateTime', + 'status': 'str', + 'complete': 'bool' } self.attribute_map = { - 'id': 'id', - 'pet_id': 'petId', - 'quantity': 'quantity', - 'ship_date': 'shipDate', - 'status': 'status', - 'complete': 'complete' + 'id': 'id', + 'pet_id': 'petId', + 'quantity': 'quantity', + 'ship_date': 'shipDate', + 'status': 'status', + 'complete': 'complete' } - - self.id = None # int - - self.pet_id = None # int + self.id = None # int - - self.quantity = None # int - - self.ship_date = None # DateTime + self.pet_id = None # int - # Order Status - self.status = None # str - - self.complete = None # bool + self.quantity = None # int + + + self.ship_date = None # DateTime + + # Order Status + self.status = None # str + + + self.complete = None # bool - def __repr__(self): + def __repr__(self): properties = [] for p in self.__dict__: - if p != 'swaggerTypes' and p != 'attributeMap': - properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) + if p != 'swaggerTypes' and p != 'attributeMap': + properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) return '<{name} {props}>'.format(name=__name__, props=' '.join(properties)) - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py index dedde9a455..a943b63966 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py @@ -4,27 +4,26 @@ """ Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. """ - - class Pet(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ +class Pet(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ - def __init__(self): + def __init__(self): """ Swagger model @@ -32,49 +31,48 @@ limitations under the License. :param dict attributeMap: The key is attribute name and the value is json key in definition. """ self.swagger_types = { - 'id': 'int', - 'category': 'Category', - 'name': 'str', - 'photo_urls': 'list[str]', - 'tags': 'list[Tag]', - 'status': 'str' + 'id': 'int', + 'category': 'Category', + 'name': 'str', + 'photo_urls': 'list[str]', + 'tags': 'list[Tag]', + 'status': 'str' } self.attribute_map = { - 'id': 'id', - 'category': 'category', - 'name': 'name', - 'photo_urls': 'photoUrls', - 'tags': 'tags', - 'status': 'status' + 'id': 'id', + 'category': 'category', + 'name': 'name', + 'photo_urls': 'photoUrls', + 'tags': 'tags', + 'status': 'status' } - - self.id = None # int - - self.category = None # Category + self.id = None # int - - self.name = None # str - - self.photo_urls = None # list[str] + self.category = None # Category - - self.tags = None # list[Tag] - # pet status in the store - self.status = None # str + self.name = None # str + + + self.photo_urls = None # list[str] + + + self.tags = None # list[Tag] + + # pet status in the store + self.status = None # str - def __repr__(self): + def __repr__(self): properties = [] for p in self.__dict__: - if p != 'swaggerTypes' and p != 'attributeMap': - properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) + if p != 'swaggerTypes' and p != 'attributeMap': + properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) return '<{name} {props}>'.format(name=__name__, props=' '.join(properties)) - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py index fdf647a6e2..6347352eba 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py @@ -4,27 +4,26 @@ """ Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. """ - - class Tag(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ +class Tag(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ - def __init__(self): + def __init__(self): """ Swagger model @@ -32,29 +31,28 @@ limitations under the License. :param dict attributeMap: The key is attribute name and the value is json key in definition. """ self.swagger_types = { - 'id': 'int', - 'name': 'str' + 'id': 'int', + 'name': 'str' } self.attribute_map = { - 'id': 'id', - 'name': 'name' + 'id': 'id', + 'name': 'name' } - - self.id = None # int - - self.name = None # str + self.id = None # int + + + self.name = None # str - def __repr__(self): + def __repr__(self): properties = [] for p in self.__dict__: - if p != 'swaggerTypes' and p != 'attributeMap': - properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) + if p != 'swaggerTypes' and p != 'attributeMap': + properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) return '<{name} {props}>'.format(name=__name__, props=' '.join(properties)) - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py index b6c2eb930d..83efcd9ee2 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py @@ -4,27 +4,26 @@ """ Copyright 2015 SmartBear Software -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. """ - - class User(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ +class User(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ - def __init__(self): + def __init__(self): """ Swagger model @@ -32,59 +31,58 @@ limitations under the License. :param dict attributeMap: The key is attribute name and the value is json key in definition. """ self.swagger_types = { - 'id': 'int', - 'username': 'str', - 'first_name': 'str', - 'last_name': 'str', - 'email': 'str', - 'password': 'str', - 'phone': 'str', - 'user_status': 'int' + 'id': 'int', + 'username': 'str', + 'first_name': 'str', + 'last_name': 'str', + 'email': 'str', + 'password': 'str', + 'phone': 'str', + 'user_status': 'int' } self.attribute_map = { - 'id': 'id', - 'username': 'username', - 'first_name': 'firstName', - 'last_name': 'lastName', - 'email': 'email', - 'password': 'password', - 'phone': 'phone', - 'user_status': 'userStatus' + 'id': 'id', + 'username': 'username', + 'first_name': 'firstName', + 'last_name': 'lastName', + 'email': 'email', + 'password': 'password', + 'phone': 'phone', + 'user_status': 'userStatus' } - - self.id = None # int - - self.username = None # str + self.id = None # int - - self.first_name = None # str - - self.last_name = None # str + self.username = None # str - - self.email = None # str - - self.password = None # str + self.first_name = None # str - - self.phone = None # str - # User Status - self.user_status = None # int + self.last_name = None # str + + + self.email = None # str + + + self.password = None # str + + + self.phone = None # str + + # User Status + self.user_status = None # int - def __repr__(self): + def __repr__(self): properties = [] for p in self.__dict__: - if p != 'swaggerTypes' and p != 'attributeMap': - properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) + if p != 'swaggerTypes' and p != 'attributeMap': + properties.append('{prop}={val!r}'.format(prop=p, val=self.__dict__[p])) return '<{name} {props}>'.format(name=__name__, props=' '.join(properties)) - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/rest.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/rest.py index d5c79d8395..508f3d6693 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/rest.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/rest.py @@ -15,239 +15,239 @@ import certifi from six import iteritems try: -import urllib3 + import urllib3 except ImportError: -raise ImportError('Swagger python client requires urllib3.') + raise ImportError('Swagger python client requires urllib3.') try: -# for python3 -from urllib.parse import urlencode + # for python3 + from urllib.parse import urlencode except ImportError: -# for python2 -from urllib import urlencode + # for python2 + from urllib import urlencode class RESTResponse(io.IOBase): -def __init__(self, resp): -self.urllib3_response = resp -self.status = resp.status -self.reason = resp.reason -self.data = resp.data + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data -def getheaders(self): -""" -Returns a dictionary of the response headers. -""" -return self.urllib3_response.getheaders() + def getheaders(self): + """ + Returns a dictionary of the response headers. + """ + return self.urllib3_response.getheaders() -def getheader(self, name, default=None): -""" -Returns a given response header. -""" -return self.urllib3_response.getheader(name, default) + def getheader(self, name, default=None): + """ + Returns a given response header. + """ + return self.urllib3_response.getheader(name, default) class RESTClientObject(object): -def __init__(self, pools_size=4): -# http pool manager -self.pool_manager = urllib3.PoolManager( -num_pools=pools_size -) + def __init__(self, pools_size=4): + # http pool manager + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size + ) -# https pool manager -# certificates validated using Mozilla’s root certificates -self.ssl_pool_manager = urllib3.PoolManager( -num_pools=pools_size, -cert_reqs=ssl.CERT_REQUIRED, -ca_certs=certifi.where() -) + # https pool manager + # certificates validated using Mozilla’s root certificates + self.ssl_pool_manager = urllib3.PoolManager( + num_pools=pools_size, + cert_reqs=ssl.CERT_REQUIRED, + ca_certs=certifi.where() + ) -def agent(self, url): -""" -Return proper pool manager for the http\https schemes. -""" -url = urllib3.util.url.parse_url(url) -scheme = url.scheme -if scheme == 'https': -return self.ssl_pool_manager -else: -return self.pool_manager + def agent(self, url): + """ + Return proper pool manager for the http\https schemes. + """ + url = urllib3.util.url.parse_url(url) + scheme = url.scheme + if scheme == 'https': + return self.ssl_pool_manager + else: + return self.pool_manager -def request(self, method, url, query_params=None, headers=None, -body=None, post_params=None): -""" -:param method: http request method -:param url: http request url -:param query_params: query parameters in the url -:param headers: http request headers -:param body: request json body, for `application/json` -:param post_params: request post parameters, `application/x-www-form-urlencode` -and `multipart/form-data` -""" -method = method.upper() -assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH'] + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None): + """ + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, `application/x-www-form-urlencode` + and `multipart/form-data` + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH'] -if post_params and body: -raise ValueError("body parameter cannot be used with post_params parameter.") + if post_params and body: + raise ValueError("body parameter cannot be used with post_params parameter.") -post_params = post_params or {} -headers = headers or {} + post_params = post_params or {} + headers = headers or {} -if 'Content-Type' not in headers: -headers['Content-Type'] = 'application/json' + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' -# For `POST`, `PUT`, `PATCH` -if method in ['POST', 'PUT', 'PATCH']: -if query_params: -url += '?' + urlencode(query_params) -if headers['Content-Type'] == 'application/json': -r = self.agent(url).request(method, url, -body=json.dumps(body), -headers=headers) -if headers['Content-Type'] == 'application/x-www-form-urlencoded': -r = self.agent(url).request(method, url, -fields=post_params, -encode_multipart=False, -headers=headers) -if headers['Content-Type'] == 'multipart/form-data': -# must del headers['Content-Type'], or the correct Content-Type -# which generated by urllib3 will be overwritten. -del headers['Content-Type'] -r = self.agent(url).request(method, url, -fields=post_params, -encode_multipart=True, -headers=headers) -# For `GET`, `HEAD`, `DELETE` -else: -r = self.agent(url).request(method, url, -fields=query_params, -headers=headers) -r = RESTResponse(r) + # For `POST`, `PUT`, `PATCH` + if method in ['POST', 'PUT', 'PATCH']: + if query_params: + url += '?' + urlencode(query_params) + if headers['Content-Type'] == 'application/json': + r = self.agent(url).request(method, url, + body=json.dumps(body), + headers=headers) + if headers['Content-Type'] == 'application/x-www-form-urlencoded': + r = self.agent(url).request(method, url, + fields=post_params, + encode_multipart=False, + headers=headers) + if headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct Content-Type + # which generated by urllib3 will be overwritten. + del headers['Content-Type'] + r = self.agent(url).request(method, url, + fields=post_params, + encode_multipart=True, + headers=headers) + # For `GET`, `HEAD`, `DELETE` + else: + r = self.agent(url).request(method, url, + fields=query_params, + headers=headers) + r = RESTResponse(r) -if r.status not in range(200, 206): -raise ApiException(r) + if r.status not in range(200, 206): + raise ApiException(r) -return self.process_response(r) + return self.process_response(r) -def process_response(self, response): -# In the python 3, the response.data is bytes. -# we need to decode it to string. -if sys.version_info > (3,): -data = response.data.decode('utf8') -else: -data = response.data -try: -resp = json.loads(data) -except ValueError: -resp = data + def process_response(self, response): + # In the python 3, the response.data is bytes. + # we need to decode it to string. + if sys.version_info > (3,): + data = response.data.decode('utf8') + else: + data = response.data + try: + resp = json.loads(data) + except ValueError: + resp = data -return resp + return resp -def GET(self, url, headers=None, query_params=None): -return self.request("GET", url, headers=headers, query_params=query_params) + def GET(self, url, headers=None, query_params=None): + return self.request("GET", url, headers=headers, query_params=query_params) -def HEAD(self, url, headers=None, query_params=None): -return self.request("HEAD", url, headers=headers, query_params=query_params) + def HEAD(self, url, headers=None, query_params=None): + return self.request("HEAD", url, headers=headers, query_params=query_params) -def DELETE(self, url, headers=None, query_params=None): -return self.request("DELETE", url, headers=headers, query_params=query_params) + def DELETE(self, url, headers=None, query_params=None): + return self.request("DELETE", url, headers=headers, query_params=query_params) -def POST(self, url, headers=None, post_params=None, body=None): -return self.request("POST", url, headers=headers, post_params=post_params, body=body) + def POST(self, url, headers=None, post_params=None, body=None): + return self.request("POST", url, headers=headers, post_params=post_params, body=body) -def PUT(self, url, headers=None, post_params=None, body=None): -return self.request("PUT", url, headers=headers, post_params=post_params, body=body) + def PUT(self, url, headers=None, post_params=None, body=None): + return self.request("PUT", url, headers=headers, post_params=post_params, body=body) -def PATCH(self, url, headers=None, post_params=None, body=None): -return self.request("PATCH", url, headers=headers, post_params=post_params, body=body) + def PATCH(self, url, headers=None, post_params=None, body=None): + return self.request("PATCH", url, headers=headers, post_params=post_params, body=body) class ApiException(Exception): -""" -Non-2xx HTTP response -""" + """ + Non-2xx HTTP response + """ -def __init__(self, http_resp): -self.status = http_resp.status -self.reason = http_resp.reason -self.body = http_resp.data -self.headers = http_resp.getheaders() + def __init__(self, http_resp): + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() -# In the python 3, the self.body is bytes. -# we need to decode it to string. -if sys.version_info > (3,): -data = self.body.decode('utf8') -else: -data = self.body + # In the python 3, the self.body is bytes. + # we need to decode it to string. + if sys.version_info > (3,): + data = self.body.decode('utf8') + else: + data = self.body + + try: + self.body = json.loads(data) + except ValueError: + self.body = data -try: -self.body = json.loads(data) -except ValueError: -self.body = data - -def __str__(self): -""" -Custom error response messages -""" -return "({0})\n"\ -"Reason: {1}\n"\ -"HTTP response headers: {2}\n"\ -"HTTP response body: {3}\n".\ -format(self.status, self.reason, self.headers, self.body) + def __str__(self): + """ + Custom error response messages + """ + return "({0})\n"\ + "Reason: {1}\n"\ + "HTTP response headers: {2}\n"\ + "HTTP response body: {3}\n".\ + format(self.status, self.reason, self.headers, self.body) class RESTClient(object): -""" -A class with all class methods to perform JSON requests. -""" + """ + A class with all class methods to perform JSON requests. + """ -IMPL = RESTClientObject() + IMPL = RESTClientObject() -@classmethod -def request(cls, *n, **kw): -""" -Perform a REST request and parse the response. -""" -return cls.IMPL.request(*n, **kw) + @classmethod + def request(cls, *n, **kw): + """ + Perform a REST request and parse the response. + """ + return cls.IMPL.request(*n, **kw) -@classmethod -def GET(cls, *n, **kw): -""" -Perform a GET request using `RESTClient.request()`. -""" -return cls.IMPL.GET(*n, **kw) + @classmethod + def GET(cls, *n, **kw): + """ + Perform a GET request using `RESTClient.request()`. + """ + return cls.IMPL.GET(*n, **kw) -@classmethod -def HEAD(cls, *n, **kw): -""" -Perform a HEAD request using `RESTClient.request()`. -""" -return cls.IMPL.GET(*n, **kw) + @classmethod + def HEAD(cls, *n, **kw): + """ + Perform a HEAD request using `RESTClient.request()`. + """ + return cls.IMPL.GET(*n, **kw) -@classmethod -def POST(cls, *n, **kw): -""" -Perform a POST request using `RESTClient.request()` -""" -return cls.IMPL.POST(*n, **kw) + @classmethod + def POST(cls, *n, **kw): + """ + Perform a POST request using `RESTClient.request()` + """ + return cls.IMPL.POST(*n, **kw) -@classmethod -def PUT(cls, *n, **kw): -""" -Perform a PUT request using `RESTClient.request()` -""" -return cls.IMPL.PUT(*n, **kw) + @classmethod + def PUT(cls, *n, **kw): + """ + Perform a PUT request using `RESTClient.request()` + """ + return cls.IMPL.PUT(*n, **kw) -@classmethod -def PATCH(cls, *n, **kw): -""" -Perform a PATCH request using `RESTClient.request()` -""" -return cls.IMPL.PATCH(*n, **kw) + @classmethod + def PATCH(cls, *n, **kw): + """ + Perform a PATCH request using `RESTClient.request()` + """ + return cls.IMPL.PATCH(*n, **kw) -@classmethod -def DELETE(cls, *n, **kw): -""" -Perform a DELETE request using `RESTClient.request()` -""" -return cls.IMPL.DELETE(*n, **kw) + @classmethod + def DELETE(cls, *n, **kw): + """ + Perform a DELETE request using `RESTClient.request()` + """ + return cls.IMPL.DELETE(*n, **kw) diff --git a/samples/client/petstore/python/SwaggerPetstore-python/setup.py b/samples/client/petstore/python/SwaggerPetstore-python/setup.py index 4a1985d471..fbd738be68 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/setup.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/setup.py @@ -3,18 +3,18 @@ from setuptools import setup, find_packages - # To install the library, open a Terminal shell, then run this - # file by typing: - # - # python setup.py install - # - # You need to have the setuptools module installed. - # Try reading the setuptools documentation: - # http://pypi.python.org/pypi/setuptools +# To install the library, open a Terminal shell, then run this +# file by typing: +# +# python setup.py install +# +# You need to have the setuptools module installed. +# Try reading the setuptools documentation: +# http://pypi.python.org/pypi/setuptools - REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi"] +REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi"] - setup( +setup( name="SwaggerPetstore", version="1.0.0", description="Swagger Petstore", @@ -27,7 +27,7 @@ from setuptools import setup, find_packages long_description="""\ This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters """ - ) +) diff --git a/samples/client/petstore/ruby/lib/swagger_client.rb b/samples/client/petstore/ruby/lib/swagger_client.rb index 6b2f591df8..6d23918500 100644 --- a/samples/client/petstore/ruby/lib/swagger_client.rb +++ b/samples/client/petstore/ruby/lib/swagger_client.rb @@ -8,22 +8,18 @@ require 'swagger_client/swagger/version' # Models require 'swagger_client/models/base_object' - require 'swagger_client/models/user' - require 'swagger_client/models/category' - require 'swagger_client/models/pet' - require 'swagger_client/models/tag' - require 'swagger_client/models/order' +require 'swagger_client/models/user' +require 'swagger_client/models/category' +require 'swagger_client/models/pet' +require 'swagger_client/models/tag' +require 'swagger_client/models/order' # APIs - - require 'swagger_client/api/user_api' - - require 'swagger_client/api/pet_api' - - require 'swagger_client/api/store_api' - +require 'swagger_client/api/user_api' +require 'swagger_client/api/pet_api' +require 'swagger_client/api/store_api' module SwaggerClient -# Initialize the default configuration -Swagger.configuration ||= Swagger::Configuration.new + # Initialize the default configuration + Swagger.configuration ||= Swagger::Configuration.new end diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb index 5e0d453986..7bed9b4778 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/api/pet_api.rb @@ -1,337 +1,328 @@ require "uri" module SwaggerClient - class PetApi + class PetApi basePath = "http://petstore.swagger.io/v2" # apiInvoker = APIInvoker - - - # Update an existing pet - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [nil] - def self.update_pet(opts = {}) - - # resource path - path = "/pet".sub('{format}','json') + # Update an existing pet + # + # @param [Hash] opts the optional parameters + # @option opts [Pet] :body Pet object that needs to be added to the store + # @return [nil] + def self.update_pet(opts = {}) + - # query parameters - query_params = {} + # resource path + path = "/pet".sub('{format}','json') - # header parameters - header_params = {} + # query parameters + query_params = {} - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + # header parameters + header_params = {} - # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - # form parameters - form_params = {} + # HTTP header 'Content-Type' + _header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - + # form parameters + form_params = {} - auth_names = ['petstore_auth'] - Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Add a new pet to the store - # - # @param [Hash] opts the optional parameters - # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [nil] - def self.add_pet(opts = {}) - + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + - # resource path - path = "/pet".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - - - auth_names = ['petstore_auth'] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Finds Pets by status - # Multiple status values can be provided with comma seperated strings - # @param [Hash] opts the optional parameters - # @option opts [array[string]] :status Status values that need to be considered for filter - # @return [array[Pet]] - def self.find_pets_by_status(opts = {}) - - - # resource path - path = "/pet/findByStatus".sub('{format}','json') - - # query parameters - query_params = {} - query_params[:'status'] = opts[:'status'] if opts[:'status'] - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = ['petstore_auth'] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - response.map {|response| obj = Pet.new() and obj.build_from_hash(response) } - end - - - # Finds Pets by tags - # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - # @param [Hash] opts the optional parameters - # @option opts [array[string]] :tags Tags to filter by - # @return [array[Pet]] - def self.find_pets_by_tags(opts = {}) - - - # resource path - path = "/pet/findByTags".sub('{format}','json') - - # query parameters - query_params = {} - query_params[:'tags'] = opts[:'tags'] if opts[:'tags'] - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = ['petstore_auth'] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - response.map {|response| obj = Pet.new() and obj.build_from_hash(response) } - end - - - # Find pet by ID - # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - # @param pet_id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters - # @return [Pet] - def self.get_pet_by_id(pet_id, opts = {}) - - # verify the required parameter 'pet_id' is set - raise "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil? - - - # resource path - path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = ['api_key', 'petstore_auth'] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - obj = Pet.new() and obj.build_from_hash(response) - end - - - # Updates a pet in the store with form data - # - # @param pet_id ID of pet that needs to be updated - # @param [Hash] opts the optional parameters - # @option opts [string] :name Updated name of the pet - # @option opts [string] :status Updated status of the pet - # @return [nil] - def self.update_pet_with_form(pet_id, opts = {}) - - # verify the required parameter 'pet_id' is set - raise "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? - - - # resource path - path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['application/x-www-form-urlencoded'] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - form_params["name"] = opts[:'name'] if opts[:'name'] - form_params["status"] = opts[:'status'] if opts[:'status'] - - # http body (model) - post_body = nil - - - auth_names = ['petstore_auth'] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Deletes a pet - # - # @param pet_id Pet id to delete - # @param [Hash] opts the optional parameters - # @option opts [string] :api_key - # @return [nil] - def self.delete_pet(pet_id, opts = {}) - - # verify the required parameter 'pet_id' is set - raise "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? - - - # resource path - path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key'] - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = ['petstore_auth'] - Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # uploads an image - # - # @param pet_id ID of pet to update - # @param [Hash] opts the optional parameters - # @option opts [string] :additional_metadata Additional data to pass to server - # @option opts [file] :file file to upload - # @return [nil] - def self.upload_file(pet_id, opts = {}) - - # verify the required parameter 'pet_id' is set - raise "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? - - - # resource path - path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = ['multipart/form-data'] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata'] - form_params["file"] = opts[:'file'] if opts[:'file'] - - # http body (model) - post_body = nil - - - auth_names = ['petstore_auth'] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - + auth_names = ['petstore_auth'] + Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil end + + # Add a new pet to the store + # + # @param [Hash] opts the optional parameters + # @option opts [Pet] :body Pet object that needs to be added to the store + # @return [nil] + def self.add_pet(opts = {}) + + + # resource path + path = "/pet".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + + + auth_names = ['petstore_auth'] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Finds Pets by status + # Multiple status values can be provided with comma seperated strings + # @param [Hash] opts the optional parameters + # @option opts [array[string]] :status Status values that need to be considered for filter + # @return [array[Pet]] + def self.find_pets_by_status(opts = {}) + + + # resource path + path = "/pet/findByStatus".sub('{format}','json') + + # query parameters + query_params = {} + query_params[:'status'] = opts[:'status'] if opts[:'status'] + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = ['petstore_auth'] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + response.map {|response| obj = Pet.new() and obj.build_from_hash(response) } + end + + # Finds Pets by tags + # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + # @param [Hash] opts the optional parameters + # @option opts [array[string]] :tags Tags to filter by + # @return [array[Pet]] + def self.find_pets_by_tags(opts = {}) + + + # resource path + path = "/pet/findByTags".sub('{format}','json') + + # query parameters + query_params = {} + query_params[:'tags'] = opts[:'tags'] if opts[:'tags'] + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = ['petstore_auth'] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + response.map {|response| obj = Pet.new() and obj.build_from_hash(response) } + end + + # Find pet by ID + # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + # @param pet_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Pet] + def self.get_pet_by_id(pet_id, opts = {}) + + # verify the required parameter 'pet_id' is set + raise "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil? + + + # resource path + path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = ['api_key', 'petstore_auth'] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + obj = Pet.new() and obj.build_from_hash(response) + end + + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [string] :name Updated name of the pet + # @option opts [string] :status Updated status of the pet + # @return [nil] + def self.update_pet_with_form(pet_id, opts = {}) + + # verify the required parameter 'pet_id' is set + raise "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? + + + # resource path + path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['application/x-www-form-urlencoded'] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + form_params["name"] = opts[:'name'] if opts[:'name'] + form_params["status"] = opts[:'status'] if opts[:'status'] + + # http body (model) + post_body = nil + + + auth_names = ['petstore_auth'] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [string] :api_key + # @return [nil] + def self.delete_pet(pet_id, opts = {}) + + # verify the required parameter 'pet_id' is set + raise "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? + + + # resource path + path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key'] + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = ['petstore_auth'] + Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [string] :additional_metadata Additional data to pass to server + # @option opts [file] :file file to upload + # @return [nil] + def self.upload_file(pet_id, opts = {}) + + # verify the required parameter 'pet_id' is set + raise "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? + + + # resource path + path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = ['multipart/form-data'] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata'] + form_params["file"] = opts[:'file'] if opts[:'file'] + + # http body (model) + post_body = nil + + + auth_names = ['petstore_auth'] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb index ab468e9466..010d170945 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/api/store_api.rb @@ -1,166 +1,161 @@ require "uri" module SwaggerClient - class StoreApi + class StoreApi basePath = "http://petstore.swagger.io/v2" # apiInvoker = APIInvoker - - - # Returns pet inventories by status - # Returns a map of status codes to quantities - # @param [Hash] opts the optional parameters - # @return [map[string,int]] - def self.get_inventory(opts = {}) - - # resource path - path = "/store/inventory".sub('{format}','json') + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @param [Hash] opts the optional parameters + # @return [map[string,int]] + def self.get_inventory(opts = {}) + - # query parameters - query_params = {} + # resource path + path = "/store/inventory".sub('{format}','json') - # header parameters - header_params = {} + # query parameters + query_params = {} - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + # header parameters + header_params = {} - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - # form parameters - form_params = {} + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - # http body (model) - post_body = nil - + # form parameters + form_params = {} - auth_names = ['api_key'] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - response.map {|response| obj = map.new() and obj.build_from_hash(response) } - end - - - # Place an order for a pet - # - # @param [Hash] opts the optional parameters - # @option opts [Order] :body order placed for purchasing the pet - # @return [Order] - def self.place_order(opts = {}) - + # http body (model) + post_body = nil + - # resource path - path = "/store/order".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - - - auth_names = [] - response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - obj = Order.new() and obj.build_from_hash(response) - end - - - # Find purchase order by ID - # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - # @param order_id ID of pet that needs to be fetched - # @param [Hash] opts the optional parameters - # @return [Order] - def self.get_order_by_id(order_id, opts = {}) - - # verify the required parameter 'order_id' is set - raise "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil? - - - # resource path - path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - obj = Order.new() and obj.build_from_hash(response) - end - - - # Delete purchase order by ID - # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - # @param order_id ID of the order that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - def self.delete_order(order_id, opts = {}) - - # verify the required parameter 'order_id' is set - raise "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? - - - # resource path - path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - + auth_names = ['api_key'] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + response.map {|response| obj = map.new() and obj.build_from_hash(response) } end + + # Place an order for a pet + # + # @param [Hash] opts the optional parameters + # @option opts [Order] :body order placed for purchasing the pet + # @return [Order] + def self.place_order(opts = {}) + + + # resource path + path = "/store/order".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + + + auth_names = [] + response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + obj = Order.new() and obj.build_from_hash(response) + end + + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Order] + def self.get_order_by_id(order_id, opts = {}) + + # verify the required parameter 'order_id' is set + raise "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil? + + + # resource path + path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + obj = Order.new() and obj.build_from_hash(response) + end + + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def self.delete_order(order_id, opts = {}) + + # verify the required parameter 'order_id' is set + raise "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? + + + # resource path + path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb b/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb index 72ecae9f26..a3a57503b0 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/api/user_api.rb @@ -1,325 +1,316 @@ require "uri" module SwaggerClient - class UserApi + class UserApi basePath = "http://petstore.swagger.io/v2" # apiInvoker = APIInvoker - - - # Create user - # This can only be done by the logged in user. - # @param [Hash] opts the optional parameters - # @option opts [User] :body Created user object - # @return [nil] - def self.create_user(opts = {}) - - # resource path - path = "/user".sub('{format}','json') + # Create user + # This can only be done by the logged in user. + # @param [Hash] opts the optional parameters + # @option opts [User] :body Created user object + # @return [nil] + def self.create_user(opts = {}) + - # query parameters - query_params = {} + # resource path + path = "/user".sub('{format}','json') - # header parameters - header_params = {} + # query parameters + query_params = {} - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + # header parameters + header_params = {} - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - # form parameters - form_params = {} + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - + # form parameters + form_params = {} - auth_names = [] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Creates list of users with given input array - # - # @param [Hash] opts the optional parameters - # @option opts [array[User]] :body List of user object - # @return [nil] - def self.create_users_with_array_input(opts = {}) - + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + - # resource path - path = "/user/createWithArray".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - - - auth_names = [] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Creates list of users with given input array - # - # @param [Hash] opts the optional parameters - # @option opts [array[User]] :body List of user object - # @return [nil] - def self.create_users_with_list_input(opts = {}) - - - # resource path - path = "/user/createWithList".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - - - auth_names = [] - Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Logs user into the system - # - # @param [Hash] opts the optional parameters - # @option opts [string] :username The user name for login - # @option opts [string] :password The password for login in clear text - # @return [string] - def self.login_user(opts = {}) - - - # resource path - path = "/user/login".sub('{format}','json') - - # query parameters - query_params = {} - query_params[:'username'] = opts[:'username'] if opts[:'username'] - query_params[:'password'] = opts[:'password'] if opts[:'password'] - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - obj = string.new() and obj.build_from_hash(response) - end - - - # Logs out current logged in user session - # - # @param [Hash] opts the optional parameters - # @return [nil] - def self.logout_user(opts = {}) - - - # resource path - path = "/user/logout".sub('{format}','json') - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. - # @param [Hash] opts the optional parameters - # @return [User] - def self.get_user_by_name(username, opts = {}) - - # verify the required parameter 'username' is set - raise "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? - - - # resource path - path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body - obj = User.new() and obj.build_from_hash(response) - end - - - # Updated user - # This can only be done by the logged in user. - # @param username name that need to be deleted - # @param [Hash] opts the optional parameters - # @option opts [User] :body Updated user object - # @return [nil] - def self.update_user(username, opts = {}) - - # verify the required parameter 'username' is set - raise "Missing the required parameter 'username' when calling update_user" if username.nil? - - - # resource path - path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - - - auth_names = [] - Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - - - # Delete user - # This can only be done by the logged in user. - # @param username The name that needs to be deleted - # @param [Hash] opts the optional parameters - # @return [nil] - def self.delete_user(username, opts = {}) - - # verify the required parameter 'username' is set - raise "Missing the required parameter 'username' when calling delete_user" if username.nil? - - - # resource path - path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) - - # query parameters - query_params = {} - - # header parameters - header_params = {} - - # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result - - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - - - auth_names = [] - Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make - nil - end - + auth_names = [] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil end + + # Creates list of users with given input array + # + # @param [Hash] opts the optional parameters + # @option opts [array[User]] :body List of user object + # @return [nil] + def self.create_users_with_array_input(opts = {}) + + + # resource path + path = "/user/createWithArray".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + + + auth_names = [] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Creates list of users with given input array + # + # @param [Hash] opts the optional parameters + # @option opts [array[User]] :body List of user object + # @return [nil] + def self.create_users_with_list_input(opts = {}) + + + # resource path + path = "/user/createWithList".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + + + auth_names = [] + Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Logs user into the system + # + # @param [Hash] opts the optional parameters + # @option opts [string] :username The user name for login + # @option opts [string] :password The password for login in clear text + # @return [string] + def self.login_user(opts = {}) + + + # resource path + path = "/user/login".sub('{format}','json') + + # query parameters + query_params = {} + query_params[:'username'] = opts[:'username'] if opts[:'username'] + query_params[:'password'] = opts[:'password'] if opts[:'password'] + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + obj = string.new() and obj.build_from_hash(response) + end + + # Logs out current logged in user session + # + # @param [Hash] opts the optional parameters + # @return [nil] + def self.logout_user(opts = {}) + + + # resource path + path = "/user/logout".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [User] + def self.get_user_by_name(username, opts = {}) + + # verify the required parameter 'username' is set + raise "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? + + + # resource path + path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make.body + obj = User.new() and obj.build_from_hash(response) + end + + # Updated user + # This can only be done by the logged in user. + # @param username name that need to be deleted + # @param [Hash] opts the optional parameters + # @option opts [User] :body Updated user object + # @return [nil] + def self.update_user(username, opts = {}) + + # verify the required parameter 'username' is set + raise "Missing the required parameter 'username' when calling update_user" if username.nil? + + + # resource path + path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + + + auth_names = [] + Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def self.delete_user(username, opts = {}) + + # verify the required parameter 'username' is set + raise "Missing the required parameter 'username' when calling delete_user" if username.nil? + + + # resource path + path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + _header_accept = ['application/json', 'application/xml'] + _header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + + # HTTP header 'Content-Type' + _header_content_type = [] + header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + + + auth_names = [] + Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body, :auth_names => auth_names}).make + nil + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb b/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb index 93354b7f1d..642e4769e5 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/base_object.rb @@ -1,83 +1,83 @@ module SwaggerClient -# base class containing fundamental method such as to_hash, build_from_hash and more -class BaseObject + # base class containing fundamental method such as to_hash, build_from_hash and more + class BaseObject -# return the object in the form of hash -def to_body -body = {} -self.class.attribute_map.each_pair do |key, value| -body[value] = self.send(key) unless self.send(key).nil? -end -body -end + # return the object in the form of hash + def to_body + body = {} + self.class.attribute_map.each_pair do |key, value| + body[value] = self.send(key) unless self.send(key).nil? + end + body + end -# build the object from hash -def build_from_hash(attributes) -return nil unless attributes.is_a?(Hash) -self.class.swagger_types.each_pair do |key, type| -if type =~ /^array\[(.*)\]/i -if attributes[self.class.attribute_map[key]].is_a?(Array) -self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) -else -#TODO show warning in debug mode -end -elsif !attributes[self.class.attribute_map[key]].nil? -self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) -else -# data not found in attributes(hash), not an issue as the data can be optional -end -end + # build the object from hash + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.swagger_types.each_pair do |key, type| + if type =~ /^array\[(.*)\]/i + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) + else + #TODO show warning in debug mode + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + else + # data not found in attributes(hash), not an issue as the data can be optional + end + end -self -end + self + end -def _deserialize(type, value) -case type.to_sym -when :DateTime -DateTime.parse(value) -when :string -value.to_s -when :int -value.to_i -when :double -value.to_f -when :boolean -if value =~ /^(true|t|yes|y|1)$/i -true -else -false -end -else # model -_model = SwaggerClient.const_get(type).new -_model.build_from_hash(value) -end -end + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :string + value.to_s + when :int + value.to_i + when :double + value.to_f + when :boolean + if value =~ /^(true|t|yes|y|1)$/i + true + else + false + end + else # model + _model = SwaggerClient.const_get(type).new + _model.build_from_hash(value) + end + end -# to_body is an alias to to_body (backward compatibility) -def to_hash -hash = {} -self.class.attribute_map.each_pair do |key, value| -if self.send(key).is_a?(Array) -next if self.send(key).empty? -hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil? -else -unless (_tmp_value = _to_hash self.send(key)).nil? -hash[value] = _tmp_value -end -end -end -hash -end + # to_body is an alias to to_body (backward compatibility) + def to_hash + hash = {} + self.class.attribute_map.each_pair do |key, value| + if self.send(key).is_a?(Array) + next if self.send(key).empty? + hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil? + else + unless (_tmp_value = _to_hash self.send(key)).nil? + hash[value] = _tmp_value + end + end + end + hash + end -# Method to output non-array value in the form of hash -# For object, use to_hash. Otherwise, just return the value -def _to_hash(value) -if value.respond_to? :to_hash -value.to_hash -else -value -end -end + # Method to output non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + def _to_hash(value) + if value.respond_to? :to_hash + value.to_hash + else + value + end + end -end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb b/samples/client/petstore/ruby/lib/swagger_client/models/category.rb index 08b3b9e8d4..fe195c7ac8 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/category.rb @@ -1,37 +1,44 @@ module SwaggerClient # class Category < BaseObject -attr_accessor :id, :name -# attribute mapping from ruby-style variable name to JSON key -def self.attribute_map -{ - # - :'id' => :'id', - # - :'name' => :'name' -} -end - -# attribute type -def self.swagger_types -{ -:'id' => :'int', -:'name' => :'string' -} -end - -def initialize(attributes = {}) -return if !attributes.is_a?(Hash) || attributes.empty? - -# convert string to symbol for hash key -attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - - if attributes[:'id'] - @id = attributes[:'id'] + attr_accessor :id, :name + # attribute mapping from ruby-style variable name to JSON key + def self.attribute_map + { + + # + :'id' => :'id', + + # + :'name' => :'name' + + } end - if attributes[:'name'] - @name = attributes[:'name'] + + # attribute type + def self.swagger_types + { + :'id' => :'int', + :'name' => :'string' + + } end -end -end + + def initialize(attributes = {}) + return if !attributes.is_a?(Hash) || attributes.empty? + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'id'] + @id = attributes[:'id'] + end + + if attributes[:'name'] + @name = attributes[:'name'] + end + + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb b/samples/client/petstore/ruby/lib/swagger_client/models/order.rb index faf62fb6a2..3fe0282ed9 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/order.rb @@ -1,61 +1,76 @@ module SwaggerClient # class Order < BaseObject -attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete -# attribute mapping from ruby-style variable name to JSON key -def self.attribute_map -{ - # - :'id' => :'id', - # - :'pet_id' => :'petId', - # - :'quantity' => :'quantity', - # - :'ship_date' => :'shipDate', - # Order Status - :'status' => :'status', - # - :'complete' => :'complete' -} -end + attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete + # attribute mapping from ruby-style variable name to JSON key + def self.attribute_map + { + + # + :'id' => :'id', + + # + :'pet_id' => :'petId', + + # + :'quantity' => :'quantity', + + # + :'ship_date' => :'shipDate', + + # Order Status + :'status' => :'status', + + # + :'complete' => :'complete' + + } + end -# attribute type -def self.swagger_types -{ -:'id' => :'int', -:'pet_id' => :'int', -:'quantity' => :'int', -:'ship_date' => :'DateTime', -:'status' => :'string', -:'complete' => :'boolean' -} -end + # attribute type + def self.swagger_types + { + :'id' => :'int', + :'pet_id' => :'int', + :'quantity' => :'int', + :'ship_date' => :'DateTime', + :'status' => :'string', + :'complete' => :'boolean' + + } + end -def initialize(attributes = {}) -return if !attributes.is_a?(Hash) || attributes.empty? + def initialize(attributes = {}) + return if !attributes.is_a?(Hash) || attributes.empty? -# convert string to symbol for hash key -attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'id'] - @id = attributes[:'id'] - end - if attributes[:'petId'] - @pet_id = attributes[:'petId'] - end - if attributes[:'quantity'] - @quantity = attributes[:'quantity'] - end - if attributes[:'shipDate'] - @ship_date = attributes[:'shipDate'] - end - if attributes[:'status'] - @status = attributes[:'status'] - end - if attributes[:'complete'] - @complete = attributes[:'complete'] + + if attributes[:'id'] + @id = attributes[:'id'] + end + + if attributes[:'petId'] + @pet_id = attributes[:'petId'] + end + + if attributes[:'quantity'] + @quantity = attributes[:'quantity'] + end + + if attributes[:'shipDate'] + @ship_date = attributes[:'shipDate'] + end + + if attributes[:'status'] + @status = attributes[:'status'] + end + + if attributes[:'complete'] + @complete = attributes[:'complete'] + end + end -end -end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb b/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb index 561f4a9ed7..32f95646c7 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb @@ -1,65 +1,80 @@ module SwaggerClient # class Pet < BaseObject -attr_accessor :id, :category, :name, :photo_urls, :tags, :status -# attribute mapping from ruby-style variable name to JSON key -def self.attribute_map -{ - # - :'id' => :'id', - # - :'category' => :'category', - # - :'name' => :'name', - # - :'photo_urls' => :'photoUrls', - # - :'tags' => :'tags', - # pet status in the store - :'status' => :'status' -} -end + attr_accessor :id, :category, :name, :photo_urls, :tags, :status + # attribute mapping from ruby-style variable name to JSON key + def self.attribute_map + { + + # + :'id' => :'id', + + # + :'category' => :'category', + + # + :'name' => :'name', + + # + :'photo_urls' => :'photoUrls', + + # + :'tags' => :'tags', + + # pet status in the store + :'status' => :'status' + + } + end -# attribute type -def self.swagger_types -{ -:'id' => :'int', -:'category' => :'Category', -:'name' => :'string', -:'photo_urls' => :'array[string]', -:'tags' => :'array[Tag]', -:'status' => :'string' -} -end + # attribute type + def self.swagger_types + { + :'id' => :'int', + :'category' => :'Category', + :'name' => :'string', + :'photo_urls' => :'array[string]', + :'tags' => :'array[Tag]', + :'status' => :'string' + + } + end -def initialize(attributes = {}) -return if !attributes.is_a?(Hash) || attributes.empty? + def initialize(attributes = {}) + return if !attributes.is_a?(Hash) || attributes.empty? -# convert string to symbol for hash key -attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'id'] - @id = attributes[:'id'] - end - if attributes[:'category'] - @category = attributes[:'category'] - end - if attributes[:'name'] - @name = attributes[:'name'] - end - if attributes[:'photoUrls'] - if (value = attributes[:'photoUrls']).is_a?(Array) - @photo_urls = value - end - end - if attributes[:'tags'] - if (value = attributes[:'tags']).is_a?(Array) - @tags = value - end - end - if attributes[:'status'] - @status = attributes[:'status'] + + if attributes[:'id'] + @id = attributes[:'id'] + end + + if attributes[:'category'] + @category = attributes[:'category'] + end + + if attributes[:'name'] + @name = attributes[:'name'] + end + + if attributes[:'photoUrls'] + if (value = attributes[:'photoUrls']).is_a?(Array) + @photo_urls = value + end + end + + if attributes[:'tags'] + if (value = attributes[:'tags']).is_a?(Array) + @tags = value + end + end + + if attributes[:'status'] + @status = attributes[:'status'] + end + end -end -end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb b/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb index 6c66fbe4dc..9c5cdde1af 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb @@ -1,37 +1,44 @@ module SwaggerClient # class Tag < BaseObject -attr_accessor :id, :name -# attribute mapping from ruby-style variable name to JSON key -def self.attribute_map -{ - # - :'id' => :'id', - # - :'name' => :'name' -} -end - -# attribute type -def self.swagger_types -{ -:'id' => :'int', -:'name' => :'string' -} -end - -def initialize(attributes = {}) -return if !attributes.is_a?(Hash) || attributes.empty? - -# convert string to symbol for hash key -attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - - if attributes[:'id'] - @id = attributes[:'id'] + attr_accessor :id, :name + # attribute mapping from ruby-style variable name to JSON key + def self.attribute_map + { + + # + :'id' => :'id', + + # + :'name' => :'name' + + } end - if attributes[:'name'] - @name = attributes[:'name'] + + # attribute type + def self.swagger_types + { + :'id' => :'int', + :'name' => :'string' + + } end -end -end + + def initialize(attributes = {}) + return if !attributes.is_a?(Hash) || attributes.empty? + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'id'] + @id = attributes[:'id'] + end + + if attributes[:'name'] + @name = attributes[:'name'] + end + + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb b/samples/client/petstore/ruby/lib/swagger_client/models/user.rb index 910bd70d72..2d723da54c 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/user.rb @@ -1,73 +1,92 @@ module SwaggerClient # class User < BaseObject -attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status -# attribute mapping from ruby-style variable name to JSON key -def self.attribute_map -{ - # - :'id' => :'id', - # - :'username' => :'username', - # - :'first_name' => :'firstName', - # - :'last_name' => :'lastName', - # - :'email' => :'email', - # - :'password' => :'password', - # - :'phone' => :'phone', - # User Status - :'user_status' => :'userStatus' -} -end + attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status + # attribute mapping from ruby-style variable name to JSON key + def self.attribute_map + { + + # + :'id' => :'id', + + # + :'username' => :'username', + + # + :'first_name' => :'firstName', + + # + :'last_name' => :'lastName', + + # + :'email' => :'email', + + # + :'password' => :'password', + + # + :'phone' => :'phone', + + # User Status + :'user_status' => :'userStatus' + + } + end -# attribute type -def self.swagger_types -{ -:'id' => :'int', -:'username' => :'string', -:'first_name' => :'string', -:'last_name' => :'string', -:'email' => :'string', -:'password' => :'string', -:'phone' => :'string', -:'user_status' => :'int' -} -end + # attribute type + def self.swagger_types + { + :'id' => :'int', + :'username' => :'string', + :'first_name' => :'string', + :'last_name' => :'string', + :'email' => :'string', + :'password' => :'string', + :'phone' => :'string', + :'user_status' => :'int' + + } + end -def initialize(attributes = {}) -return if !attributes.is_a?(Hash) || attributes.empty? + def initialize(attributes = {}) + return if !attributes.is_a?(Hash) || attributes.empty? -# convert string to symbol for hash key -attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'id'] - @id = attributes[:'id'] - end - if attributes[:'username'] - @username = attributes[:'username'] - end - if attributes[:'firstName'] - @first_name = attributes[:'firstName'] - end - if attributes[:'lastName'] - @last_name = attributes[:'lastName'] - end - if attributes[:'email'] - @email = attributes[:'email'] - end - if attributes[:'password'] - @password = attributes[:'password'] - end - if attributes[:'phone'] - @phone = attributes[:'phone'] - end - if attributes[:'userStatus'] - @user_status = attributes[:'userStatus'] + + if attributes[:'id'] + @id = attributes[:'id'] + end + + if attributes[:'username'] + @username = attributes[:'username'] + end + + if attributes[:'firstName'] + @first_name = attributes[:'firstName'] + end + + if attributes[:'lastName'] + @last_name = attributes[:'lastName'] + end + + if attributes[:'email'] + @email = attributes[:'email'] + end + + if attributes[:'password'] + @password = attributes[:'password'] + end + + if attributes[:'phone'] + @phone = attributes[:'phone'] + end + + if attributes[:'userStatus'] + @user_status = attributes[:'userStatus'] + end + end -end -end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/monkey.rb b/samples/client/petstore/ruby/lib/swagger_client/monkey.rb index f400813974..28932890af 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/monkey.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/monkey.rb @@ -1,90 +1,90 @@ # module Swagger -class Object + class Object + + unless Object.method_defined? :blank? + def blank? + respond_to?(:empty?) ? empty? : !self + end + end + + unless Object.method_defined? :present? + def present? + !blank? + end + end -unless Object.method_defined? :blank? -def blank? -respond_to?(:empty?) ? empty? : !self -end -end + end -unless Object.method_defined? :present? -def present? -!blank? -end -end + class String -end + unless String.method_defined? :underscore + def underscore + self.gsub(/::/, '/'). + gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). + gsub(/([a-z\d])([A-Z])/,'\1_\2'). + tr("-", "_"). + downcase + end + end + + unless String.method_defined? :camelize + def camelize(first_letter_in_uppercase = true) + if first_letter_in_uppercase != :lower + self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + else + self.to_s[0].chr.downcase + camelize(self)[1..-1] + end + end + end -class String + end -unless String.method_defined? :underscore -def underscore -self.gsub(/::/, '/'). -gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). -gsub(/([a-z\d])([A-Z])/,'\1_\2'). -tr("-", "_"). -downcase -end -end + class Hash -unless String.method_defined? :camelize -def camelize(first_letter_in_uppercase = true) -if first_letter_in_uppercase != :lower -self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } -else -self.to_s[0].chr.downcase + camelize(self)[1..-1] -end -end -end + unless Hash.method_defined? :stringify_keys + def stringify_keys + inject({}) do |options, (key, value)| + options[key.to_s] = value + options + end + end + end + + unless Hash.method_defined? :stringify_keys! + def stringify_keys! + self.replace(self.stringify_keys) + end + end -end + unless Hash.method_defined? :symbolize_keys + def symbolize_keys + inject({}) do |options, (key, value)| + options[(key.to_sym rescue key) || key] = value + options + end + end + end + + unless Hash.method_defined? :symbolize_keys! + def symbolize_keys! + self.replace(self.symbolize_keys) + end + end -class Hash + unless Hash.method_defined? :symbolize_and_underscore_keys + def symbolize_and_underscore_keys + inject({}) do |options, (key, value)| + options[(key.to_s.underscore.to_sym rescue key) || key] = value + options + end + end + end -unless Hash.method_defined? :stringify_keys -def stringify_keys -inject({}) do |options, (key, value)| -options[key.to_s] = value -options -end -end -end - -unless Hash.method_defined? :stringify_keys! -def stringify_keys! -self.replace(self.stringify_keys) -end -end - -unless Hash.method_defined? :symbolize_keys -def symbolize_keys -inject({}) do |options, (key, value)| -options[(key.to_sym rescue key) || key] = value -options -end -end -end - -unless Hash.method_defined? :symbolize_keys! -def symbolize_keys! -self.replace(self.symbolize_keys) -end -end - -unless Hash.method_defined? :symbolize_and_underscore_keys -def symbolize_and_underscore_keys -inject({}) do |options, (key, value)| -options[(key.to_s.underscore.to_sym rescue key) || key] = value -options -end -end -end - -unless Hash.method_defined? :symbolize_and_underscore_keys! -def symbolize_and_underscore_keys! -self.replace(self.symbolize_and_underscore_keys) -end -end - -end + unless Hash.method_defined? :symbolize_and_underscore_keys! + def symbolize_and_underscore_keys! + self.replace(self.symbolize_and_underscore_keys) + end + end + + end # end \ No newline at end of file diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger.rb index 1820bbfcc9..2e2632c169 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger.rb @@ -2,77 +2,77 @@ require 'logger' require 'json' module SwaggerClient -module Swagger -class << self -attr_accessor :logger + module Swagger + class << self + attr_accessor :logger -# A Swagger configuration object. Must act like a hash and return sensible -# values for all Swagger configuration options. See Swagger::Configuration. -attr_accessor :configuration + # A Swagger configuration object. Must act like a hash and return sensible + # values for all Swagger configuration options. See Swagger::Configuration. + attr_accessor :configuration -attr_accessor :resources + attr_accessor :resources -# Call this method to modify defaults in your initializers. -# -# @example -# Swagger.configure do |config| -# config.api_key['api_key'] = '1234567890abcdef' # api key authentication -# config.username = 'wordlover' # http basic authentication -# config.password = 'i<3words' # http basic authentication -# config.format = 'json' # optional, defaults to 'json' -# end -# -def configure -yield(configuration) if block_given? + # Call this method to modify defaults in your initializers. + # + # @example + # Swagger.configure do |config| + # config.api_key['api_key'] = '1234567890abcdef' # api key authentication + # config.username = 'wordlover' # http basic authentication + # config.password = 'i<3words' # http basic authentication + # config.format = 'json' # optional, defaults to 'json' + # end + # + def configure + yield(configuration) if block_given? -# Configure logger. Default to use Rails -self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT)) + # Configure logger. Default to use Rails + self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT)) -# remove :// from scheme -configuration.scheme.sub!(/:\/\//, '') + # remove :// from scheme + configuration.scheme.sub!(/:\/\//, '') -# remove http(s):// and anything after a slash -configuration.host.sub!(/https?:\/\//, '') -configuration.host = configuration.host.split('/').first + # remove http(s):// and anything after a slash + configuration.host.sub!(/https?:\/\//, '') + configuration.host = configuration.host.split('/').first -# Add leading and trailing slashes to base_path -configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/') -configuration.base_path = "" if configuration.base_path == "/" -end - -def authenticated? -Swagger.configuration.auth_token.present? -end - -def de_authenticate -Swagger.configuration.auth_token = nil -end - -def authenticate -return if Swagger.authenticated? - -if Swagger.configuration.username.blank? || Swagger.configuration.password.blank? -raise ClientError, "Username and password are required to authenticate." -end - -request = Swagger::Request.new( -:get, -"account/authenticate/{username}", -:params => { -:username => Swagger.configuration.username, -:password => Swagger.configuration.password -} -) - -response_body = request.response.body -Swagger.configuration.auth_token = response_body['token'] -end -end -end - -class ServerError < StandardError -end - -class ClientError < StandardError -end + # Add leading and trailing slashes to base_path + configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/') + configuration.base_path = "" if configuration.base_path == "/" + end + + def authenticated? + Swagger.configuration.auth_token.present? + end + + def de_authenticate + Swagger.configuration.auth_token = nil + end + + def authenticate + return if Swagger.authenticated? + + if Swagger.configuration.username.blank? || Swagger.configuration.password.blank? + raise ClientError, "Username and password are required to authenticate." + end + + request = Swagger::Request.new( + :get, + "account/authenticate/{username}", + :params => { + :username => Swagger.configuration.username, + :password => Swagger.configuration.password + } + ) + + response_body = request.response.body + Swagger.configuration.auth_token = response_body['token'] + end + end + end + + class ServerError < StandardError + end + + class ClientError < StandardError + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb index 023242c9cd..a2d4fe0e29 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/configuration.rb @@ -1,29 +1,29 @@ module SwaggerClient -module Swagger -class Configuration -attr_accessor :format, :api_key, :api_key_prefix, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent, :verify_ssl + module Swagger + class Configuration + attr_accessor :format, :api_key, :api_key_prefix, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params, :user_agent, :verify_ssl -# Defaults go in here.. -def initialize -@format = 'json' -@scheme = 'http' -@host = 'petstore.swagger.io' -@base_path = '/v2' -@user_agent = "ruby-swagger-#{Swagger::VERSION}" -@inject_format = false -@force_ending_format = false -@camelize_params = true + # Defaults go in here.. + def initialize + @format = 'json' + @scheme = 'http' + @host = 'petstore.swagger.io' + @base_path = '/v2' + @user_agent = "ruby-swagger-#{Swagger::VERSION}" + @inject_format = false + @force_ending_format = false + @camelize_params = true -# keys for API key authentication (param-name => api-key) -@api_key = {} -# api-key prefix for API key authentication, e.g. "Bearer" (param-name => api-key-prefix) -@api_key_prefix = {} + # keys for API key authentication (param-name => api-key) + @api_key = {} + # api-key prefix for API key authentication, e.g. "Bearer" (param-name => api-key-prefix) + @api_key_prefix = {} -# whether to verify SSL certificate, default to true -# Note: do NOT set it to false in production code, otherwise you would -# face multiple types of cryptographic attacks -@verify_ssl = true -end -end -end + # whether to verify SSL certificate, default to true + # Note: do NOT set it to false in production code, otherwise you would + # face multiple types of cryptographic attacks + @verify_ssl = true + end + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb index f3a1597168..4cd5d84b0b 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb @@ -1,270 +1,271 @@ module SwaggerClient -module Swagger -class Request -require 'uri' -require 'addressable/uri' -require 'typhoeus' + module Swagger + class Request + require 'uri' + require 'addressable/uri' + require 'typhoeus' -attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params, :auth_names + attr_accessor :host, :path, :format, :params, :body, :http_method, :headers, :form_params, :auth_names -# All requests must have an HTTP method and a path -# Optionals parameters are :params, :headers, :body, :format, :host -def initialize(http_method, path, attributes={}) -attributes[:format] ||= Swagger.configuration.format -attributes[:params] ||= {} + # All requests must have an HTTP method and a path + # Optionals parameters are :params, :headers, :body, :format, :host + def initialize(http_method, path, attributes={}) + attributes[:format] ||= Swagger.configuration.format + attributes[:params] ||= {} -# Set default headers -default_headers = { -'Content-Type' => "application/#{attributes[:format].downcase}", -'User-Agent' => Swagger.configuration.user_agent -} + # Set default headers + default_headers = { + 'Content-Type' => "application/#{attributes[:format].downcase}", + 'User-Agent' => Swagger.configuration.user_agent + } -# Merge argument headers into defaults -attributes[:headers] = default_headers.merge(attributes[:headers] || {}) + # Merge argument headers into defaults + attributes[:headers] = default_headers.merge(attributes[:headers] || {}) -# Stick in the auth token if there is one -if Swagger.authenticated? -attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token}) -end + # Stick in the auth token if there is one + if Swagger.authenticated? + attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token}) + end -self.http_method = http_method.to_sym -self.path = path -attributes.each do |name, value| -send("#{name.to_s.underscore.to_sym}=", value) -end + self.http_method = http_method.to_sym + self.path = path + attributes.each do |name, value| + send("#{name.to_s.underscore.to_sym}=", value) + end -update_params_for_auth! -end + update_params_for_auth! + end -# Update hearder and query params based on authentication settings. -def update_params_for_auth! -(@auth_names || []).each do |auth_name| -case auth_name -when 'api_key' -@headers ||= {} -@headers['api_key'] = get_api_key_with_prefix('api_key') -when 'petstore_auth' -# TODO: support oauth -end -end -end + # Update hearder and query params based on authentication settings. + def update_params_for_auth! + (@auth_names || []).each do |auth_name| + case auth_name + when 'api_key' + @headers ||= {} + @headers['api_key'] = get_api_key_with_prefix('api_key') + when 'petstore_auth' + # TODO: support oauth + + end + end + end -# Get API key (with prefix if set). -# @param [String] param_name the parameter name of API key auth -def get_api_key_with_prefix(param_name) -if Swagger.configuration.api_key_prefix[param_name].present? -"#{Swagger.configuration.api_key_prefix[param_name]} #{Swagger.configuration.api_key[param_name]}" -else -Swagger.configuration.api_key[param_name] -end -end + # Get API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def get_api_key_with_prefix(param_name) + if Swagger.configuration.api_key_prefix[param_name].present? + "#{Swagger.configuration.api_key_prefix[param_name]} #{Swagger.configuration.api_key[param_name]}" + else + Swagger.configuration.api_key[param_name] + end + end -# Construct a base URL -def url(options = {}) -u = Addressable::URI.new( -:scheme => Swagger.configuration.scheme, -:host => Swagger.configuration.host, -:path => self.interpreted_path, -:query => self.query_string.sub(/\?/, '') -).to_s + # Construct a base URL + def url(options = {}) + u = Addressable::URI.new( + :scheme => Swagger.configuration.scheme, + :host => Swagger.configuration.host, + :path => self.interpreted_path, + :query => self.query_string.sub(/\?/, '') + ).to_s -# Drop trailing question mark, if present -u.sub! /\?$/, '' + # Drop trailing question mark, if present + u.sub! /\?$/, '' -u -end + u + end -# Iterate over the params hash, injecting any path values into the path string -# e.g. /word.{format}/{word}/entries => /word.json/cat/entries -def interpreted_path -p = self.path.dup + # Iterate over the params hash, injecting any path values into the path string + # e.g. /word.{format}/{word}/entries => /word.json/cat/entries + def interpreted_path + p = self.path.dup -# Stick a .{format} placeholder into the path if there isn't -# one already or an actual format like json or xml -# e.g. /words/blah => /words.{format}/blah -if Swagger.configuration.inject_format -unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s } -p = p.sub(/^(\/?\w+)/, "\\1.#{format}") -end -end + # Stick a .{format} placeholder into the path if there isn't + # one already or an actual format like json or xml + # e.g. /words/blah => /words.{format}/blah + if Swagger.configuration.inject_format + unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s } + p = p.sub(/^(\/?\w+)/, "\\1.#{format}") + end + end -# Stick a .{format} placeholder on the end of the path if there isn't -# one already or an actual format like json or xml -# e.g. /words/blah => /words/blah.{format} -if Swagger.configuration.force_ending_format -unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s } -p = "#{p}.#{format}" -end -end + # Stick a .{format} placeholder on the end of the path if there isn't + # one already or an actual format like json or xml + # e.g. /words/blah => /words/blah.{format} + if Swagger.configuration.force_ending_format + unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s } + p = "#{p}.#{format}" + end + end -p = p.sub("{format}", self.format.to_s) + p = p.sub("{format}", self.format.to_s) -URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/') -end + URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/') + end -# Massage the request body into a state of readiness -# If body is a hash, camelize all keys then convert to a json string -def body=(value) -if value.is_a?(Hash) -value = value.inject({}) do |memo, (k,v)| -memo[k.to_s.camelize(:lower).to_sym] = v -memo -end -end -@body = value -end + # Massage the request body into a state of readiness + # If body is a hash, camelize all keys then convert to a json string + def body=(value) + if value.is_a?(Hash) + value = value.inject({}) do |memo, (k,v)| + memo[k.to_s.camelize(:lower).to_sym] = v + memo + end + end + @body = value + end -# If body is an object, JSONify it before making the actual request. -# For form parameters, remove empty value -def outgoing_body -# http form -if headers['Content-Type'] == 'application/x-www-form-urlencoded' -data = form_params.dup -data.each do |key, value| -data[key] = value.to_s if value && !value.is_a?(File) # remove emtpy form parameter -end -data -elsif @body # http body is JSON -@body.is_a?(String) ? @body : @body.to_json -else -nil -end -end + # If body is an object, JSONify it before making the actual request. + # For form parameters, remove empty value + def outgoing_body + # http form + if headers['Content-Type'] == 'application/x-www-form-urlencoded' + data = form_params.dup + data.each do |key, value| + data[key] = value.to_s if value && !value.is_a?(File) # remove emtpy form parameter + end + data + elsif @body # http body is JSON + @body.is_a?(String) ? @body : @body.to_json + else + nil + end + end -# Construct a query string from the query-string-type params -def query_string -# Iterate over all params, -# .. removing the ones that are part of the path itself. -# .. stringifying values so Addressable doesn't blow up. -query_values = {} -self.params.each_pair do |key, value| -next if self.path.include? "{#{key}}" # skip path params -next if value.blank? && value.class != FalseClass # skip empties -if Swagger.configuration.camelize_params -key = key.to_s.camelize(:lower).to_sym -end -query_values[key] = value.to_s -end + # Construct a query string from the query-string-type params + def query_string + # Iterate over all params, + # .. removing the ones that are part of the path itself. + # .. stringifying values so Addressable doesn't blow up. + query_values = {} + self.params.each_pair do |key, value| + next if self.path.include? "{#{key}}" # skip path params + next if value.blank? && value.class != FalseClass # skip empties + if Swagger.configuration.camelize_params + key = key.to_s.camelize(:lower).to_sym + end + query_values[key] = value.to_s + end -# We don't want to end up with '?' as our query string -# if there aren't really any params -return "" if query_values.blank? + # We don't want to end up with '?' as our query string + # if there aren't really any params + return "" if query_values.blank? -# Addressable requires query_values to be set after initialization.. -qs = Addressable::URI.new -qs.query_values = query_values -qs.to_s -end + # Addressable requires query_values to be set after initialization.. + qs = Addressable::URI.new + qs.query_values = query_values + qs.to_s + end -def make -#TODO use configuration setting to determine if debugging -#logger = Logger.new STDOUT -#logger.debug self.url + def make + #TODO use configuration setting to determine if debugging + #logger = Logger.new STDOUT + #logger.debug self.url -request_options = { -:ssl_verifypeer => Swagger.configuration.verify_ssl, -:headers => self.headers.stringify_keys -} -response = case self.http_method.to_sym -when :get,:GET -Typhoeus::Request.get( -self.url, -request_options -) + request_options = { + :ssl_verifypeer => Swagger.configuration.verify_ssl, + :headers => self.headers.stringify_keys + } + response = case self.http_method.to_sym + when :get,:GET + Typhoeus::Request.get( + self.url, + request_options + ) -when :post,:POST -Typhoeus::Request.post( -self.url, -request_options.merge(:body => self.outgoing_body) -) + when :post,:POST + Typhoeus::Request.post( + self.url, + request_options.merge(:body => self.outgoing_body) + ) -when :patch,:PATCH -Typhoeus::Request.patch( -self.url, -request_options.merge(:body => self.outgoing_body) -) + when :patch,:PATCH + Typhoeus::Request.patch( + self.url, + request_options.merge(:body => self.outgoing_body) + ) -when :put,:PUT -Typhoeus::Request.put( -self.url, -request_options.merge(:body => self.outgoing_body) -) + when :put,:PUT + Typhoeus::Request.put( + self.url, + request_options.merge(:body => self.outgoing_body) + ) -when :delete,:DELETE -Typhoeus::Request.delete( -self.url, -request_options.merge(:body => self.outgoing_body) -) -end -Response.new(response) -end + when :delete,:DELETE + Typhoeus::Request.delete( + self.url, + request_options.merge(:body => self.outgoing_body) + ) + end + Response.new(response) + end -def response -self.make -end + def response + self.make + end -def response_code_pretty -return unless @response.present? -@response.code.to_s -end + def response_code_pretty + return unless @response.present? + @response.code.to_s + end -def response_headers_pretty -return unless @response.present? -# JSON.pretty_generate(@response.headers).gsub(/\n/, '
') # <- This was for RestClient -@response.headers.gsub(/\n/, '
') # <- This is for Typhoeus -end + def response_headers_pretty + return unless @response.present? + # JSON.pretty_generate(@response.headers).gsub(/\n/, '
') # <- This was for RestClient + @response.headers.gsub(/\n/, '
') # <- This is for Typhoeus + end -# return 'Accept' based on an array of accept provided -# @param [Array] header_accept_array Array fo 'Accept' -# @return String Accept (e.g. application/json) -def self.select_header_accept header_accept_array -if header_accept_array.empty? -return -elsif header_accept_array.any?{ |s| s.casecmp('application/json')==0 } -'application/json' # look for json data by default -else -header_accept_array.join(',') -end -end + # return 'Accept' based on an array of accept provided + # @param [Array] header_accept_array Array fo 'Accept' + # @return String Accept (e.g. application/json) + def self.select_header_accept header_accept_array + if header_accept_array.empty? + return + elsif header_accept_array.any?{ |s| s.casecmp('application/json')==0 } + 'application/json' # look for json data by default + else + header_accept_array.join(',') + end + end -# return the content type based on an array of content-type provided -# @param [Array] content_type_array Array fo content-type -# @return String Content-Type (e.g. application/json) -def self.select_header_content_type content_type_array -if content_type_array.empty? -'application/json' # use application/json by default -elsif content_type_array.any?{ |s| s.casecmp('application/json')==0 } -'application/json' # use application/json if it's included -else -content_type_array[0]; # otherwise, use the first one -end -end + # return the content type based on an array of content-type provided + # @param [Array] content_type_array Array fo content-type + # @return String Content-Type (e.g. application/json) + def self.select_header_content_type content_type_array + if content_type_array.empty? + 'application/json' # use application/json by default + elsif content_type_array.any?{ |s| s.casecmp('application/json')==0 } + 'application/json' # use application/json if it's included + else + content_type_array[0]; # otherwise, use the first one + end + end -# static method to convert object (array, hash, object, etc) to JSON string -# @param model object to be converted into JSON string -# @return string JSON string representation of the object -def self.object_to_http_body model -return if model.nil? -_body = nil -if model.is_a?(Array) -_body = model.map{|m| object_to_hash(m) } -else -_body = object_to_hash(model) -end -_body.to_json -end + # static method to convert object (array, hash, object, etc) to JSON string + # @param model object to be converted into JSON string + # @return string JSON string representation of the object + def self.object_to_http_body model + return if model.nil? + _body = nil + if model.is_a?(Array) + _body = model.map{|m| object_to_hash(m) } + else + _body = object_to_hash(model) + end + _body.to_json + end -# static method to convert object(non-array) to hash -# @param obj object to be converted into JSON string -# @return string JSON string representation of the object -def self.object_to_hash obj -if obj.respond_to?(:to_hash) -obj.to_hash -else -obj -end -end + # static method to convert object(non-array) to hash + # @param obj object to be converted into JSON string + # @return string JSON string representation of the object + def self.object_to_hash obj + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj + end + end -end -end + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb index d5eaf2edac..538821bea6 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/response.rb @@ -1,70 +1,70 @@ module SwaggerClient -module Swagger -class Response -require 'json' + module Swagger + class Response + require 'json' -attr_accessor :raw + attr_accessor :raw -def initialize(raw) -self.raw = raw + def initialize(raw) + self.raw = raw -case self.code -when 500..510 then raise(ServerError, self.error_message) -when 299..426 then raise(ClientError, self.error_message) -end -end + case self.code + when 500..510 then raise(ServerError, self.error_message) + when 299..426 then raise(ClientError, self.error_message) + end + end -def code -raw.code -end + def code + raw.code + end -# Account for error messages that take different forms... -def error_message -body['message'] -rescue -body -end + # Account for error messages that take different forms... + def error_message + body['message'] + rescue + body + end -# If body is JSON, parse it -# Otherwise return raw string -def body -JSON.parse(raw.body, :symbolize_names => true) -rescue -raw.body -end + # If body is JSON, parse it + # Otherwise return raw string + def body + JSON.parse(raw.body, :symbolize_names => true) + rescue + raw.body + end -# `headers_hash` is a Typhoeus-specific extension of Hash, -# so simplify it back into a regular old Hash. -def headers -h = {} -raw.headers_hash.each {|k,v| h[k] = v } -h -end + # `headers_hash` is a Typhoeus-specific extension of Hash, + # so simplify it back into a regular old Hash. + def headers + h = {} + raw.headers_hash.each {|k,v| h[k] = v } + h + end -# Extract the response format from the header hash -# e.g. {'Content-Type' => 'application/json'} -def format -headers['Content-Type'].split("/").last.downcase -end + # Extract the response format from the header hash + # e.g. {'Content-Type' => 'application/json'} + def format + headers['Content-Type'].split("/").last.downcase + end -def json? -format == 'json' -end + def json? + format == 'json' + end -def xml? -format == 'xml' -end + def xml? + format == 'xml' + end -def pretty_body -return unless body.present? -case format -when 'json' then JSON.pretty_generate(body).gsub(/\n/, '
') -end -end + def pretty_body + return unless body.present? + case format + when 'json' then JSON.pretty_generate(body).gsub(/\n/, '
') + end + end -def pretty_headers -JSON.pretty_generate(headers).gsub(/\n/, '
') -end -end -end + def pretty_headers + JSON.pretty_generate(headers).gsub(/\n/, '
') + end + end + end end diff --git a/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb b/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb index e869b16a80..c6e8d5aee5 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/version.rb @@ -1,5 +1,5 @@ module SwaggerClient -module Swagger -VERSION = "1.0.0" -end + module Swagger + VERSION = "1.0.0" + end end diff --git a/samples/client/petstore/ruby/swagger_client.gemspec b/samples/client/petstore/ruby/swagger_client.gemspec index 0b58b59776..c0d507b3c5 100644 --- a/samples/client/petstore/ruby/swagger_client.gemspec +++ b/samples/client/petstore/ruby/swagger_client.gemspec @@ -3,30 +3,30 @@ $:.push File.expand_path("../lib", __FILE__) require "swagger_client/swagger/version" Gem::Specification.new do |s| -s.name = "swagger_client" -s.version = SwaggerClient::Swagger::VERSION -s.platform = Gem::Platform::RUBY -s.authors = ["Zeke Sikelianos", "Tony Tam"] -s.email = ["zeke@wordnik.com", "fehguy@gmail.com"] -s.homepage = "http://swagger.io" -s.summary = %q{A ruby wrapper for the swagger APIs} -s.description = %q{This gem maps to a swagger API} -s.license = "Apache-2.0" + s.name = "swagger_client" + s.version = SwaggerClient::Swagger::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["Zeke Sikelianos", "Tony Tam"] + s.email = ["zeke@wordnik.com", "fehguy@gmail.com"] + s.homepage = "http://swagger.io" + s.summary = %q{A ruby wrapper for the swagger APIs} + s.description = %q{This gem maps to a swagger API} + s.license = "Apache-2.0" -s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1' -s.add_runtime_dependency 'addressable', '~> 2.2', '>= 2.2.4' -s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6' + s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1' + s.add_runtime_dependency 'addressable', '~> 2.2', '>= 2.2.4' + s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6' -s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0' -s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3' -s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2' -s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' -s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2' -s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' -s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.10' + s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0' + s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3' + s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2' + s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' + s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2' + s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' + s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.10' -s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? } -s.test_files = `find spec/*`.split("\n") -s.executables = [] -s.require_paths = ["lib"] + s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? } + s.test_files = `find spec/*`.split("\n") + s.executables = [] + s.require_paths = ["lib"] end