From 64ea3f8177c102d09115d0af20a4d12776548c8d Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 7 Jun 2015 20:50:35 -0700 Subject: [PATCH] rebuilt --- .../src/main/csharp/io/swagger/Api/PetApi.cs | 1506 +++++++------ .../main/csharp/io/swagger/Api/StoreApi.cs | 772 ++++--- .../src/main/csharp/io/swagger/Api/UserApi.cs | 1468 +++++++------ .../main/csharp/io/swagger/Model/Category.cs | 96 +- .../src/main/csharp/io/swagger/Model/Order.cs | 144 +- .../src/main/csharp/io/swagger/Model/Pet.cs | 144 +- .../src/main/csharp/io/swagger/Model/Tag.cs | 96 +- .../src/main/csharp/io/swagger/Model/User.cs | 168 +- .../csharp/io/swagger/client/ApiClient.cs | 452 ++-- .../csharp/io/swagger/client/ApiException.cs | 81 +- .../csharp/io/swagger/client/Configuration.cs | 75 +- .../client/petstore/objc/client/SWGCategory.h | 24 +- .../client/petstore/objc/client/SWGCategory.m | 38 +- .../petstore/objc/client/SWGConfiguration.h | 47 +- .../petstore/objc/client/SWGConfiguration.m | 82 +- .../client/petstore/objc/client/SWGOrder.h | 46 +- .../client/petstore/objc/client/SWGOrder.m | 38 +- samples/client/petstore/objc/client/SWGPet.h | 46 +- samples/client/petstore/objc/client/SWGPet.m | 38 +- .../client/petstore/objc/client/SWGPetApi.h | 254 +-- .../client/petstore/objc/client/SWGPetApi.m | 1374 ++++++------ .../client/petstore/objc/client/SWGStoreApi.h | 122 +- .../client/petstore/objc/client/SWGStoreApi.m | 704 +++--- samples/client/petstore/objc/client/SWGTag.h | 24 +- samples/client/petstore/objc/client/SWGTag.m | 38 +- samples/client/petstore/objc/client/SWGUser.h | 56 +- samples/client/petstore/objc/client/SWGUser.m | 38 +- .../client/petstore/objc/client/SWGUserApi.h | 238 +- .../client/petstore/objc/client/SWGUserApi.m | 1319 +++++------ .../php/SwaggerClient-php/composer.json | 62 +- .../php/SwaggerClient-php/lib/APIClient.php | 725 ++++--- .../SwaggerClient-php/lib/ApiException.php | 36 +- .../php/SwaggerClient-php/lib/PetApi.php | 901 ++++---- .../php/SwaggerClient-php/lib/StoreApi.php | 459 ++-- .../php/SwaggerClient-php/lib/UserApi.php | 855 ++++---- .../SwaggerClient-php/lib/models/Category.php | 42 +- .../SwaggerClient-php/lib/models/Order.php | 72 +- .../php/SwaggerClient-php/lib/models/Pet.php | 72 +- .../php/SwaggerClient-php/lib/models/Tag.php | 42 +- .../php/SwaggerClient-php/lib/models/User.php | 84 +- .../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/qt5cpp/client/SWGCategory.cpp | 151 +- .../petstore/qt5cpp/client/SWGCategory.h | 43 +- .../petstore/qt5cpp/client/SWGHelpers.cpp | 305 +-- .../petstore/qt5cpp/client/SWGHelpers.h | 13 +- .../petstore/qt5cpp/client/SWGModelFactory.h | 71 +- .../client/petstore/qt5cpp/client/SWGObject.h | 21 +- .../petstore/qt5cpp/client/SWGOrder.cpp | 231 +- .../client/petstore/qt5cpp/client/SWGOrder.h | 51 +- .../client/petstore/qt5cpp/client/SWGPet.cpp | 285 +-- .../client/petstore/qt5cpp/client/SWGPet.h | 51 +- .../petstore/qt5cpp/client/SWGPetApi.cpp | 1053 ++++----- .../client/petstore/qt5cpp/client/SWGPetApi.h | 30 +- .../petstore/qt5cpp/client/SWGStoreApi.cpp | 363 ++-- .../petstore/qt5cpp/client/SWGStoreApi.h | 19 +- .../client/petstore/qt5cpp/client/SWGTag.cpp | 151 +- .../client/petstore/qt5cpp/client/SWGTag.h | 43 +- .../client/petstore/qt5cpp/client/SWGUser.cpp | 313 +-- .../client/petstore/qt5cpp/client/SWGUser.h | 55 +- .../petstore/qt5cpp/client/SWGUserApi.cpp | 861 ++++---- .../petstore/qt5cpp/client/SWGUserApi.h | 25 +- samples/client/petstore/retrofit/pom.xml | 11 +- .../io/swagger/client/ServiceGenerator.java | 25 +- .../java/io/swagger/client/api/PetApi.java | 222 +- .../java/io/swagger/client/api/StoreApi.java | 106 +- .../java/io/swagger/client/api/UserApi.java | 208 +- .../io/swagger/client/model/Category.java | 60 +- .../java/io/swagger/client/model/Order.java | 138 +- .../java/io/swagger/client/model/Pet.java | 142 +- .../java/io/swagger/client/model/Tag.java | 60 +- .../java/io/swagger/client/model/User.java | 164 +- .../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 | 160 +- .../lib/swagger_client/models/category.rb | 73 +- .../ruby/lib/swagger_client/models/order.rb | 129 +- .../ruby/lib/swagger_client/models/pet.rb | 137 +- .../ruby/lib/swagger_client/models/tag.rb | 73 +- .../ruby/lib/swagger_client/models/user.rb | 157 +- .../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 | 527 +++-- .../lib/swagger_client/swagger/response.rb | 130 +- .../lib/swagger_client/swagger/version.rb | 6 +- .../petstore/ruby/swagger_client.gemspec | 46 +- .../petstore/tizen/client/SamiApiClient.cpp | 178 +- .../petstore/tizen/client/SamiApiClient.h | 102 +- .../petstore/tizen/client/SamiCategory.cpp | 266 +-- .../petstore/tizen/client/SamiCategory.h | 60 +- .../petstore/tizen/client/SamiError.cpp | 30 +- .../client/petstore/tizen/client/SamiError.h | 23 +- .../petstore/tizen/client/SamiHelpers.cpp | 488 ++--- .../petstore/tizen/client/SamiHelpers.h | 69 +- .../petstore/tizen/client/SamiModelFactory.h | 74 +- .../client/petstore/tizen/client/SamiObject.h | 43 +- .../petstore/tizen/client/SamiOrder.cpp | 422 ++-- .../client/petstore/tizen/client/SamiOrder.h | 76 +- .../client/petstore/tizen/client/SamiPet.cpp | 422 ++-- .../client/petstore/tizen/client/SamiPet.h | 76 +- .../petstore/tizen/client/SamiPetApi.cpp | 765 +++---- .../client/petstore/tizen/client/SamiPetApi.h | 104 +- .../petstore/tizen/client/SamiStoreApi.cpp | 443 ++-- .../petstore/tizen/client/SamiStoreApi.h | 73 +- .../client/petstore/tizen/client/SamiTag.cpp | 266 +-- .../client/petstore/tizen/client/SamiTag.h | 60 +- .../client/petstore/tizen/client/SamiUser.cpp | 500 ++--- .../client/petstore/tizen/client/SamiUser.h | 84 +- .../petstore/tizen/client/SamiUserApi.cpp | 763 +++---- .../petstore/tizen/client/SamiUserApi.h | 98 +- samples/dynamic-html/docs/index.html | 152 +- .../dynamic-html/docs/models/Category.html | 29 +- samples/dynamic-html/docs/models/Order.html | 77 +- samples/dynamic-html/docs/models/Pet.html | 77 +- samples/dynamic-html/docs/models/Tag.html | 29 +- samples/dynamic-html/docs/models/User.html | 101 +- .../dynamic-html/docs/operations/PetApi.html | 610 +++--- .../docs/operations/StoreApi.html | 206 +- .../dynamic-html/docs/operations/UserApi.html | 519 +++-- samples/dynamic-html/package.json | 20 +- samples/html/index.html | 1925 ++++++++--------- samples/server/petstore/jaxrs/README.md | 2 +- samples/server/petstore/jaxrs/pom.xml | 5 +- .../gen/java/io/swagger/api/ApiException.java | 13 +- .../java/io/swagger/api/ApiOriginFilter.java | 34 +- .../io/swagger/api/ApiResponseMessage.java | 117 +- .../io/swagger/api/NotFoundException.java | 11 +- .../src/gen/java/io/swagger/api/PetApi.java | 238 +- .../java/io/swagger/api/PetApiService.java | 70 +- .../src/gen/java/io/swagger/api/StoreApi.java | 116 +- .../java/io/swagger/api/StoreApiService.java | 44 +- .../src/gen/java/io/swagger/api/UserApi.java | 215 +- .../java/io/swagger/api/UserApiService.java | 69 +- .../gen/java/io/swagger/model/Category.java | 71 +- .../src/gen/java/io/swagger/model/Order.java | 170 +- .../src/gen/java/io/swagger/model/Pet.java | 173 +- .../src/gen/java/io/swagger/model/Tag.java | 71 +- .../src/gen/java/io/swagger/model/User.java | 211 +- .../jaxrs/src/main/webapp/WEB-INF/web.xml | 6 +- samples/server/petstore/spring-mvc/pom.xml | 2 +- .../java/io/swagger/api/ApiException.java | 13 +- .../java/io/swagger/api/ApiOriginFilter.java | 34 +- .../io/swagger/api/ApiResponseMessage.java | 117 +- .../io/swagger/api/NotFoundException.java | 11 +- .../src/main/java/io/swagger/api/PetApi.java | 234 +- .../main/java/io/swagger/api/StoreApi.java | 115 +- .../src/main/java/io/swagger/api/UserApi.java | 214 +- .../swagger/configuration/SwaggerConfig.java | 34 +- .../configuration/SwaggerUiConfiguration.java | 59 +- .../swagger/configuration/WebApplication.java | 28 +- .../configuration/WebMvcConfiguration.java | 8 +- .../main/java/io/swagger/model/Category.java | 71 +- .../src/main/java/io/swagger/model/Order.java | 170 +- .../src/main/java/io/swagger/model/Pet.java | 173 +- .../src/main/java/io/swagger/model/Tag.java | 71 +- .../src/main/java/io/swagger/model/User.java | 211 +- 170 files changed, 18425 insertions(+), 17288 deletions(-) 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 8596800f536..4d99ab9e531 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,803 +6,1035 @@ 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 { - - /// - /// 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; - } } - /// - /// Initializes a new instance of the class. - /// - /// + /// + + /// 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) + /// + + public PetApi(ApiClient apiClient = null) { + if (apiClient == null) { // use the default one in Configuration + this.apiClient = Configuration.apiClient; + } else { + this.apiClient = apiClient; + } + } + + /// + + /// 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) { + } + + 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; + var path = "/pet"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { "petstore_auth" }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + return; + } - /// - /// Add a new pet to the store - /// - /// Pet object that needs to be added to the store - /// - public void AddPet (Pet Body) { + /// + + /// 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 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.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 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) { + } + + 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; + var path = "/pet"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { "petstore_auth" }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + 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) { + /// + + /// 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 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; + 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 - - - - + if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query 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.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 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) { + } + 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; + var path = "/pet/findByStatus"; + path = path.Replace("{format}", "json"); + - if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter - - - - + 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[] { "petstore_auth" }; + if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter + + + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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)); - } + } + 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) { + /// + + /// 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 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; + 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 - - - - + if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query 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.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 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) { + } + 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; + var path = "/pet/findByTags"; + path = path.Replace("{format}", "json"); + - if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter - - - - + 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[] { "petstore_auth" }; + if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter + + + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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)); - } + } + 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) { + /// + + /// 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"); - + + // 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 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; + 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" }; + // 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); + // 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 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) { + } + return (Pet) apiClient.Deserialize(response.Content, typeof(Pet)); + } - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); - + /// + + /// 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) { - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + 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) { + // 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)); - } + } + 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) { + /// + + /// 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"); - + + // 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 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; + 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 - - + + + 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" }; + // 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); + // 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 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) { + } + + return; + } - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); - + /// + + /// 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) { - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + - - - if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter - if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter - - + 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[] { "petstore_auth" }; + + + if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter + if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + return; + } - /// - /// Deletes a pet - /// - /// /// Pet id to delete - /// - public void DeletePet (string ApiKey, long? PetId) { + /// + + /// 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"); - + + // 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 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; + 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 - - - + + if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header 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.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + 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) { + } + + return; + } - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); - + /// + + /// Deletes a pet + /// + + /// + /// + Pet id to delete + /// + + public async Task DeletePetAsync (string ApiKey, long? PetId) { - var path = "/pet/{petId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + - - if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter - - - + 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[] { "petstore_auth" }; + + if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter + + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + 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) { + /// + + /// 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"); - + + // 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 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; + 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); - - + + + 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" }; + // 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); + // 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 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) { + } + + return; + } - - // verify the required parameter 'PetId' is set - if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); - + /// + + /// 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) { - var path = "/pet/{petId}/uploadImage"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); - + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + var path = "/pet/{petId}/uploadImage"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + - - - if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter - if (File != null) fileParams.Add("file", File); - - + 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[] { "petstore_auth" }; + + + if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter + if (File != null) fileParams.Add("file", File); + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; + } - } - + } } 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 8cd175a6227..f77decdf5f9 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,423 +6,535 @@ 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 + Dictionary GetInventory (); - /// - /// Returns pet inventories by status Returns a map of status codes to quantities - /// + /// + + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + + /// + Dictionary + Task> GetInventoryAsync (); - /// Dictionary - Task> GetInventoryAsync (); + /// + + /// Place an order for a pet + /// + + /// + order placed for purchasing the pet + /// + Order + Order PlaceOrder (Order Body); + + /// + + /// Place an order for a pet + /// + + /// + order placed for purchasing the pet + /// + Order + Task PlaceOrderAsync (Order Body); - /// - /// Place an order for a pet - /// - /// order placed for purchasing the pet - /// Order - Order PlaceOrder (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); - /// - /// 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 + Task GetOrderByIdAsync (string OrderId); - /// - /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// - /// ID of pet that needs to be fetched - /// Order - Order GetOrderById (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); - /// - /// 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 + /// + + Task DeleteOrderAsync (string OrderId); - /// - /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// ID of the order that needs to be deleted - /// - void DeleteOrder (string OrderId); - - /// - /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// ID of the order that needs to be deleted - /// - Task 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; - } } - /// - /// Initializes a new instance of the class. - /// - /// + /// + + /// 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; + } + } + + /// + + /// 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 () { + } + 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; + 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) { + // 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)); - } + } + 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) { + /// + + /// 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 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; + 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 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) { + } + 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; + var path = "/store/order"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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)); - } + } + 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) { + /// + + /// 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"); - + + // 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 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; + 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[] { }; + // 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); + // 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 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) { + } + return (Order) apiClient.Deserialize(response.Content, typeof(Order)); + } - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); - + /// + + /// 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) { - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + 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) { + // 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)); - } + } + 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) { + /// + + /// 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"); - + + // 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 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; + 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[] { }; + // 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); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + 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) { + } + + return; + } - - // verify the required parameter 'OrderId' is set - if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); - + /// + + /// 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) { - var path = "/store/order/{orderId}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); - + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + 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) { + // 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; + } - } - + } } 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 154ad67240c..608ac49ab02 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,791 +6,1007 @@ 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 + /// + + + /// + + void LogoutUser (); - /// - /// Logs out current logged in user session - /// + /// + + /// Logs out current logged in user session + /// + + + /// + + Task LogoutUserAsync (); - /// - Task LogoutUserAsync (); + /// + + /// Get user by user name + /// + + /// + The name that needs to be fetched. Use user1 for testing. + /// + User + User GetUserByName (string Username); + + /// + + /// Get user by user name + /// + + /// + The name that needs to be fetched. Use user1 for testing. + /// + User + Task GetUserByNameAsync (string Username); - /// - /// Get user by user name - /// - /// The name that needs to be fetched. Use user1 for testing. - /// User - User GetUserByName (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); - /// - /// 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 + /// + + Task UpdateUserAsync (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 - /// - void UpdateUser (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); - /// - /// 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 + /// + + Task DeleteUserAsync (string Username); - /// - /// Delete user This can only be done by the logged in user. - /// - /// The name that needs to be deleted - /// - void DeleteUser (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); - - } - - /// - /// 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; - } } - /// - /// Initializes a new instance of the class. - /// - /// + /// + + /// 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; + } + } + + /// + + /// 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) { + } + + 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; + var path = "/user"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + return; + } - /// - /// Creates list of users with given input array - /// - /// List of user object - /// - public void CreateUsersWithArrayInput (List Body) { + /// + + /// 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 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; + 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 CreateUsersWithArrayInput: " + response.Content, response.Content); - } - - return; - } - - /// - /// Creates list of users with given input array - /// - /// List of user object - /// - public async Task CreateUsersWithArrayInputAsync (List Body) { + } + + 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; + var path = "/user/createWithArray"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + return; + } - /// - /// Creates list of users with given input array - /// - /// List of user object - /// - public void CreateUsersWithListInput (List Body) { + /// + + /// 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 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; + 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 CreateUsersWithListInput: " + response.Content, response.Content); - } - - return; - } - - /// - /// Creates list of users with given input array - /// - /// List of user object - /// - public async Task CreateUsersWithListInputAsync (List Body) { + } + + 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; + var path = "/user/createWithList"; + path = path.Replace("{format}", "json"); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + 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) { + /// + + /// 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 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; + 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 - - - - + 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[] { }; + // 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); + // 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 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) { + } + 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; + var path = "/user/login"; + path = path.Replace("{format}", "json"); + - if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter - if (Password != null) queryParams.Add("password", apiClient.ParameterToString(Password)); // query parameter - - - - + 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[] { }; + if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter + if (Password != null) queryParams.Add("password", apiClient.ParameterToString(Password)); // query parameter + + + + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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)); - } + } + return (string) ApiInvoker.Deserialize(response.Content, typeof(string)); + } - /// - /// Logs out current logged in user session - /// - - /// - public void LogoutUser () { + /// + + /// Logs out current logged in user session + /// + + + /// + + public void LogoutUser () { - + - var path = "/user/logout"; - path = path.Replace("{format}", "json"); - + 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; + 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[] { }; + // 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); + // 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 LogoutUser: " + response.Content, response.Content); - } - - return; - } - - /// - /// Logs out current logged in user session - /// - - /// - public async Task LogoutUserAsync () { + } + + 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; + 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) { + // 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; - } + } + + return; + } - /// - /// Get user by user name - /// - /// The name that needs to be fetched. Use user1 for testing. - /// User - public User GetUserByName (string Username) { + /// + + /// 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"); - + + // 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 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; + 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[] { }; + // 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); + // 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 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) { + } + return (User) apiClient.Deserialize(response.Content, typeof(User)); + } - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); - + /// + + /// Get user by user name + /// + + /// + The name that needs to be fetched. Use user1 for testing. + /// + User + public async Task GetUserByNameAsync (string Username) { - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + 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) { + // 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)); - } + } + 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) { + /// + + /// 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"); - + + // 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 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; + 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.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 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) { + } + + return; + } - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); - + /// + + /// 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) { - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + - - - - postBody = apiClient.Serialize(Body); // http body (model) parameter - + 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[] { }; + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + - // make the HTTP request - IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + // 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; - } + } + + 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) { + /// + + /// 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"); - + + // 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 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; + 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[] { }; + // 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); + // make the HTTP request + IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); - if (((int)response.StatusCode) >= 400) { + 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) { + } + + return; + } - - // verify the required parameter 'Username' is set - if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); - + /// + + /// 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) { - var path = "/user/{username}"; - path = path.Replace("{format}", "json"); - path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); - + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); + - var queryParams = new Dictionary(); - var headerParams = new Dictionary(); - var formParams = new Dictionary(); - var fileParams = new Dictionary(); - String postBody = null; + 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) { + // 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; + } - } - + } } 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 74121762af9..df423c7ac41 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,50 +5,58 @@ 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 7451619050c..71c11fe7d63 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,78 +5,86 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; -namespace IO.Swagger.Model { + + namespace IO.Swagger.Model { - /// - /// - /// - [DataContract] - public class Order { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } + /// + + /// + /// + + [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="petId", EmitDefaultValue=false)] + public long? PetId { get; set; } - - - [DataMember(Name="quantity", EmitDefaultValue=false)] - public int? Quantity { get; set; } + + + [DataMember(Name="quantity", EmitDefaultValue=false)] + public int? Quantity { get; set; } - - - [DataMember(Name="shipDate", EmitDefaultValue=false)] - public DateTime? ShipDate { 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); + } + + } - /* 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 0bfba35b1e3..28285ece28f 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,78 +5,86 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; -namespace IO.Swagger.Model { + + namespace IO.Swagger.Model { - /// - /// - /// - [DataContract] - public class Pet { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } + /// + + /// + /// + + [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="category", EmitDefaultValue=false)] + public Category Category { get; set; } - - - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } + + + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } - - - [DataMember(Name="photoUrls", EmitDefaultValue=false)] - public List PhotoUrls { 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="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 53901491a47..c802c95946c 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,50 +5,58 @@ 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 e58d0296a06..b8aa21481b9 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,92 +5,100 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; -namespace IO.Swagger.Model { + + namespace IO.Swagger.Model { - /// - /// - /// - [DataContract] - public class User { - - - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } + /// + + /// + /// + + [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="username", EmitDefaultValue=false)] + public string Username { get; set; } - - - [DataMember(Name="firstName", EmitDefaultValue=false)] - public string FirstName { get; set; } + + + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } - - - [DataMember(Name="lastName", EmitDefaultValue=false)] - public string LastName { get; set; } + + + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } - - - [DataMember(Name="email", EmitDefaultValue=false)] - public string Email { get; set; } + + + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } - - - [DataMember(Name="password", EmitDefaultValue=false)] - public string Password { 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="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 b001a38845c..9c0a4190675 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,214 +9,310 @@ 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 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 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); + 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) { - - case "api_key": - HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key"); + /// + + /// 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) { - break; - - case "petstore_auth": + case "api_key": + HeaderParams["api_key"] = GetApiKeyWithPrefix("api_key + "); + + break; - //TODO support oauth - break; - - default: + case "petstore_auth": + + //TODO support oauth + break; + + default: //TODO show warning about security definition not found - break; - } - } + 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 f9cf380e683..d668e0b3a69 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,42 +1,61 @@ 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 4e7975e3ad0..7e412727408 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,41 +7,62 @@ 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/objc/client/SWGCategory.h b/samples/client/petstore/objc/client/SWGCategory.h index a2fed79b4a3..a46376c4f8b 100644 --- a/samples/client/petstore/objc/client/SWGCategory.h +++ b/samples/client/petstore/objc/client/SWGCategory.h @@ -1,15 +1,21 @@ -#import +#import + #import "SWGObject.h" + -@protocol SWGCategory -@end - -@interface SWGCategory : SWGObject + @protocol SWGCategory + @end + @interface SWGCategory : SWGObject -@property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSString* name; + -@property(nonatomic) NSString* name; - -@end + @end + diff --git a/samples/client/petstore/objc/client/SWGCategory.m b/samples/client/petstore/objc/client/SWGCategory.m index c41f76a5247..7ea47e56bb8 100644 --- a/samples/client/petstore/objc/client/SWGCategory.m +++ b/samples/client/petstore/objc/client/SWGCategory.m @@ -1,22 +1,24 @@ -#import "SWGCategory.h" + + #import "SWGCategory.h" -@implementation SWGCategory - -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; -} + @implementation SWGCategory -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_id", @"name"]; + + (JSONKeyMapper *)keyMapper + { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; + } - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} + + (BOOL)propertyIsOptional:(NSString *)propertyName + { + NSArray *optionalProperties = @[@"_id", @"name"]; -@end + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } + } + + + @end diff --git a/samples/client/petstore/objc/client/SWGConfiguration.h b/samples/client/petstore/objc/client/SWGConfiguration.h index 33023ca3c6f..529e07aa81c 100644 --- a/samples/client/petstore/objc/client/SWGConfiguration.h +++ b/samples/client/petstore/objc/client/SWGConfiguration.h @@ -1,56 +1,57 @@ -#import +#import + @interface SWGConfiguration : NSObject /** - * Api key values for Api Key type Authentication - * - * To add or remove api key, use `setValue:forApiKeyField:`. - */ +* Api key values for Api Key type Authentication +* +* To add or remove api key, use `setValue:forApiKeyField:`. +*/ @property (readonly, nonatomic, strong) NSDictionary *apiKey; /** - * Api key prefix values to be prepend to the respective api key - * - * To add or remove prefix, use `setValue:forApiKeyPrefixField:`. - */ +* Api key prefix values to be prepend to the respective api key +* +* To add or remove prefix, use `setValue:forApiKeyPrefixField:`. +*/ @property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; /** - * Usename and Password for Basic type Authentication - */ +* Usename and Password for Basic type Authentication +*/ @property (nonatomic) NSString *username; @property (nonatomic) NSString *password; /** - * Get configuration singleton instance - */ +* Get configuration singleton instance +*/ + (instancetype) sharedConfig; /** - * Sets field in `apiKey` - */ +* Sets field in `apiKey` +*/ - (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; /** - * Sets field in `apiKeyPrefix` - */ +* Sets field in `apiKeyPrefix` +*/ - (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; /** - * Get API key (with prefix if set) - */ +* Get API key (with prefix if set) +*/ - (NSString *) getApiKeyWithPrefix:(NSString *) key; /** - * Get Basic Auth token - */ +* Get Basic Auth token +*/ - (NSString *) getBasicAuthToken; /** - * Get Authentication Setings - */ +* Get Authentication Setings +*/ - (NSDictionary *) authSettings; @end diff --git a/samples/client/petstore/objc/client/SWGConfiguration.m b/samples/client/petstore/objc/client/SWGConfiguration.m index 89d5a597946..dc0bdb44d42 100644 --- a/samples/client/petstore/objc/client/SWGConfiguration.m +++ b/samples/client/petstore/objc/client/SWGConfiguration.m @@ -12,81 +12,81 @@ #pragma mark - Singletion Methods + (instancetype) sharedConfig { - static SWGConfiguration *shardConfig = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - shardConfig = [[self alloc] init]; - }); - return shardConfig; +static SWGConfiguration *shardConfig = nil; +static dispatch_once_t onceToken; +dispatch_once(&onceToken, ^{ +shardConfig = [[self alloc] init]; +}); +return shardConfig; } #pragma mark - Initialize Methods - (instancetype) init { - self = [super init]; - if (self) { - self.username = @""; - self.password = @""; - self.mutableApiKey = [NSMutableDictionary dictionary]; - self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; - } - return self; +self = [super init]; +if (self) { +self.username = @""; +self.password = @""; +self.mutableApiKey = [NSMutableDictionary dictionary]; +self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; +} +return self; } #pragma mark - Instance Methods - (NSString *) getApiKeyWithPrefix:(NSString *)key { - if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { - return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; - } - else if ([self.apiKey objectForKey:key]) { - return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; - } - else { - return @""; - } +if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { +return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; +} +else if ([self.apiKey objectForKey:key]) { +return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; +} +else { +return @""; +} } - (NSString *) getBasicAuthToken { - NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; - NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; - basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; - - return basicAuthCredentials; +NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; +NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; +basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; + +return basicAuthCredentials; } #pragma mark - Setter Methods - (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { - [self.mutableApiKey setValue:value forKey:field]; +[self.mutableApiKey setValue:value forKey:field]; } - (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { - [self.mutableApiKeyPrefix setValue:value forKey:field]; +[self.mutableApiKeyPrefix setValue:value forKey:field]; } #pragma mark - Getter Methods - (NSDictionary *) apiKey { - return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; +return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; } - (NSDictionary *) apiKeyPrefix { - return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; +return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; } #pragma mark - - (NSDictionary *) authSettings { - return @{ - @"api_key": @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"api_key", - @"value": [self getApiKeyWithPrefix:@"api_key"] - }, - - }; +return @{ + @"api_key": @{ + @"type": @"api_key", + @"in": @"header", + @"key": @"api_key", + @"value": [self getApiKeyWithPrefix:@"api_key"] + }, + +}; } @end diff --git a/samples/client/petstore/objc/client/SWGOrder.h b/samples/client/petstore/objc/client/SWGOrder.h index c4f4f6e81ad..397158e4e7e 100644 --- a/samples/client/petstore/objc/client/SWGOrder.h +++ b/samples/client/petstore/objc/client/SWGOrder.h @@ -1,24 +1,34 @@ -#import +#import + #import "SWGObject.h" + -@protocol SWGOrder -@end - -@interface SWGOrder : SWGObject + @protocol SWGOrder + @end + @interface SWGOrder : SWGObject -@property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* petId; + + + @property(nonatomic) NSNumber* quantity; + + + @property(nonatomic) NSDate* shipDate; + + /* Order Status [optional] + */ + @property(nonatomic) NSString* status; + + + @property(nonatomic) BOOL complete; + -@property(nonatomic) NSNumber* petId; - -@property(nonatomic) NSNumber* quantity; - -@property(nonatomic) NSDate* shipDate; -/* Order Status [optional] - */ -@property(nonatomic) NSString* status; - -@property(nonatomic) BOOL complete; - -@end + @end + diff --git a/samples/client/petstore/objc/client/SWGOrder.m b/samples/client/petstore/objc/client/SWGOrder.m index 5d3179446ed..19da01c2ad4 100644 --- a/samples/client/petstore/objc/client/SWGOrder.m +++ b/samples/client/petstore/objc/client/SWGOrder.m @@ -1,22 +1,24 @@ -#import "SWGOrder.h" + + #import "SWGOrder.h" -@implementation SWGOrder - -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; -} + @implementation SWGOrder -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; + + (JSONKeyMapper *)keyMapper + { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; + } - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} + + (BOOL)propertyIsOptional:(NSString *)propertyName + { + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; -@end + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } + } + + + @end diff --git a/samples/client/petstore/objc/client/SWGPet.h b/samples/client/petstore/objc/client/SWGPet.h index edd54e9f31a..d979eaa3845 100644 --- a/samples/client/petstore/objc/client/SWGPet.h +++ b/samples/client/petstore/objc/client/SWGPet.h @@ -1,26 +1,36 @@ -#import +#import + #import "SWGObject.h" #import "SWGTag.h" #import "SWGCategory.h" + -@protocol SWGPet -@end - -@interface SWGPet : SWGObject + @protocol SWGPet + @end + @interface SWGPet : SWGObject -@property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* _id; + + + @property(nonatomic) SWGCategory* category; + + + @property(nonatomic) NSString* name; + + + @property(nonatomic) NSArray* photoUrls; + + + @property(nonatomic) NSArray* tags; + + /* pet status in the store [optional] + */ + @property(nonatomic) NSString* status; + -@property(nonatomic) SWGCategory* category; - -@property(nonatomic) NSString* name; - -@property(nonatomic) NSArray* photoUrls; - -@property(nonatomic) NSArray* tags; -/* pet status in the store [optional] - */ -@property(nonatomic) NSString* status; - -@end + @end + diff --git a/samples/client/petstore/objc/client/SWGPet.m b/samples/client/petstore/objc/client/SWGPet.m index d5559aa6f72..07acd4087bc 100644 --- a/samples/client/petstore/objc/client/SWGPet.m +++ b/samples/client/petstore/objc/client/SWGPet.m @@ -1,22 +1,24 @@ -#import "SWGPet.h" + + #import "SWGPet.h" -@implementation SWGPet - -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; -} + @implementation SWGPet -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; + + (JSONKeyMapper *)keyMapper + { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; + } - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} + + (BOOL)propertyIsOptional:(NSString *)propertyName + { + NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; -@end + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } + } + + + @end diff --git a/samples/client/petstore/objc/client/SWGPetApi.h b/samples/client/petstore/objc/client/SWGPetApi.h index aa255cd144e..a164578f6be 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.h +++ b/samples/client/petstore/objc/client/SWGPetApi.h @@ -1,157 +1,167 @@ -#import +#import + #import "SWGPet.h" #import "SWGFile.h" #import "SWGObject.h" #import "SWGApiClient.h" -@interface SWGPetApi: NSObject + @interface SWGPetApi: NSObject -@property(nonatomic, assign)SWGApiClient *apiClient; + @property(nonatomic, assign)SWGApiClient *apiClient; --(instancetype) initWithApiClient:(SWGApiClient *)apiClient; --(void) addHeader:(NSString*)value forKey:(NSString*)key; --(unsigned long) requestQueueSize; -+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; -+(void) setBasePath:(NSString*)basePath; -+(NSString*) getBasePath; -/** - - Update an existing pet - - - @param body Pet object that needs to be added to the store - - - return type: - */ --(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body + -(instancetype) initWithApiClient:(SWGApiClient *)apiClient; + -(void) addHeader:(NSString*)value forKey:(NSString*)key; + -(unsigned long) requestQueueSize; + +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; + +(void) setBasePath:(NSString*)basePath; + +(NSString*) getBasePath; + /** + + Update an existing pet + + + @param body Pet object that needs to be added to the store + + + return type: + */ + -(NSNumber*) updatePetWithCompletionBlock :(SWGPet*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; + + - completionHandler: (void (^)(NSError* error))completionBlock; + /** + Add a new pet to the store + -/** + @param body Pet object that needs to be added to the store + - Add a new pet to the store - + return type: + */ + -(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; - @param body Pet object that needs to be added to the store - - - return type: - */ --(NSNumber*) addPetWithCompletionBlock :(SWGPet*) body + + /** + + Finds Pets by status + Multiple status values can be provided with comma seperated strings + + @param status Status values that need to be considered for filter + + + return type: NSArray* + */ + -(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status + + completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock; + + + - completionHandler: (void (^)(NSError* error))completionBlock; + /** + Finds Pets by tags + Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. -/** + @param tags Tags to filter by + - Finds Pets by status - Multiple status values can be provided with comma seperated strings + return type: NSArray* + */ + -(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags + + completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock; + - @param status Status values that need to be considered for filter - - - return type: NSArray* - */ --(NSNumber*) findPetsByStatusWithCompletionBlock :(NSArray*) status + - completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock; + /** + + Find pet by ID + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + + @param petId ID of pet that needs to be fetched + + + return type: SWGPet* + */ + -(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId + + completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock; + + + + /** + Updates a pet in the store with form data + -/** + @param petId ID of pet that needs to be updated + @param name Updated name of the pet + @param status Updated status of the pet + - Finds Pets by tags - Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + return type: + */ + -(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId + name:(NSString*) name + status:(NSString*) status + + + completionHandler: (void (^)(NSError* error))completionBlock; - @param tags Tags to filter by - - - return type: NSArray* - */ --(NSNumber*) findPetsByTagsWithCompletionBlock :(NSArray*) tags + - completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock; + /** + + Deletes a pet + + + @param apiKey + @param petId Pet id to delete + + + return type: + */ + -(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey + petId:(NSNumber*) petId + + + completionHandler: (void (^)(NSError* error))completionBlock; + + + /** + uploads an image + -/** + @param petId ID of pet to update + @param additionalMetadata Additional data to pass to server + @param file file to upload + - Find pet by ID - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + return type: + */ + -(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId + additionalMetadata:(NSString*) additionalMetadata + file:(SWGFile*) file + + + completionHandler: (void (^)(NSError* error))completionBlock; - @param petId ID of pet that needs to be fetched - - - return type: SWGPet* - */ --(NSNumber*) getPetByIdWithCompletionBlock :(NSNumber*) petId + - completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock; - - - -/** - - Updates a pet in the store with form data - - - @param petId ID of pet that needs to be updated - @param name Updated name of the pet - @param status Updated status of the pet - - - return type: - */ --(NSNumber*) updatePetWithFormWithCompletionBlock :(NSString*) petId - name:(NSString*) name - status:(NSString*) status - - - completionHandler: (void (^)(NSError* error))completionBlock; - - -/** - - Deletes a pet - - - @param apiKey - @param petId Pet id to delete - - - return type: - */ --(NSNumber*) deletePetWithCompletionBlock :(NSString*) apiKey - petId:(NSNumber*) petId - - - completionHandler: (void (^)(NSError* error))completionBlock; - - -/** - - uploads an image - - - @param petId ID of pet to update - @param additionalMetadata Additional data to pass to server - @param file file to upload - - - return type: - */ --(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId - additionalMetadata:(NSString*) additionalMetadata - file:(SWGFile*) file - - - completionHandler: (void (^)(NSError* error))completionBlock; - - @end diff --git a/samples/client/petstore/objc/client/SWGPetApi.m b/samples/client/petstore/objc/client/SWGPetApi.m index c14da125af5..64349d7dcc0 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.m +++ b/samples/client/petstore/objc/client/SWGPetApi.m @@ -1,918 +1,924 @@ -#import "SWGPetApi.h" -#import "SWGFile.h" -#import "SWGQueryParamCollection.h" -#import "SWGPet.h" -#import "SWGFile.h" + #import "SWGPetApi.h" + #import "SWGFile.h" + #import "SWGQueryParamCollection.h" + #import "SWGPet.h" + #import "SWGFile.h" + + - -@interface SWGPetApi () + @interface SWGPetApi () @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; -@end + @end -@implementation SWGPetApi + @implementation SWGPetApi -static NSString * basePath = @"http://petstore.swagger.io/v2"; + static NSString * basePath = @"http://petstore.swagger.io/v2"; -#pragma mark - Initialize methods + #pragma mark - Initialize methods -- (id) init { + - (id) init { self = [super init]; if (self) { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - self.defaultHeaders = [NSMutableDictionary dictionary]; + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -- (id) initWithApiClient:(SWGApiClient *)apiClient { + - (id) initWithApiClient:(SWGApiClient *)apiClient { self = [super init]; if (self) { - if (apiClient) { - self.apiClient = apiClient; - } - else { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - } - self.defaultHeaders = [NSMutableDictionary dictionary]; + if (apiClient) { + self.apiClient = apiClient; + } + else { + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + } + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -#pragma mark - + #pragma mark - -+(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { + +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGPetApi* singletonAPI = nil; if (singletonAPI == nil) { - singletonAPI = [[SWGPetApi alloc] init]; - [singletonAPI addHeader:headerValue forKey:key]; + singletonAPI = [[SWGPetApi alloc] init]; + [singletonAPI addHeader:headerValue forKey:key]; } return singletonAPI; -} + } -+(void) setBasePath:(NSString*)path { + +(void) setBasePath:(NSString*)path { basePath = path; -} + } -+(NSString*) getBasePath { + +(NSString*) getBasePath { return basePath; -} + } --(void) addHeader:(NSString*)value forKey:(NSString*)key { + -(void) addHeader:(NSString*)value forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(void) setHeaderValue:(NSString*) value - forKey:(NSString*)key { + -(void) setHeaderValue:(NSString*) value + forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(unsigned long) requestQueueSize { + -(unsigned long) requestQueueSize { return [SWGApiClient requestQueueSize]; -} + } -/*! - * Update an existing pet - * - * \param body Pet object that needs to be added to the store - * \returns void - */ --(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body + + /*! + * Update an existing pet + * + * \param body Pet object that needs to be added to the store + * \returns void + */ + -(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body completionHandler: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"PUT" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"PUT" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Add a new pet to the store - * - * \param body Pet object that needs to be added to the store - * \returns void - */ --(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body + + } + + + /*! + * Add a new pet to the store + * + * \param body Pet object that needs to be added to the store + * \returns void + */ + -(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body completionHandler: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * \param status Status values that need to be considered for filter - * \returns NSArray* - */ --(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status + + } + + + /*! + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * \param status Status values that need to be considered for filter + * \returns NSArray* + */ + -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByStatus", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByStatus", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(status != nil) { + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(status != nil) { - queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; + queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; - } - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + } + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - - // response is in a container - // array container response type - return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - return; - } - - if([data isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; - for (NSDictionary* dict in (NSArray*)data) { - - - SWGPet* d = [[SWGPet alloc] initWithDictionary:dict error:nil]; - - [objs addObject:d]; - } - completionBlock((NSArray*)objs, nil); - } - - - }]; - + - - - - + + // response is in a container + // array container response type +return [self.apiClient dictionary: requestUrl +method: @"GET" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSDictionary *data, NSError *error) { +if (error) { +completionBlock(nil, error); +return; } -/*! - * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * \param tags Tags to filter by - * \returns NSArray* - */ --(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags + if([data isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; + for (NSDictionary* dict in (NSArray*)data) { + + + SWGPet* d = [[SWGPet alloc] initWithDictionary:dict error:nil]; + + [objs addObject:d]; + } + completionBlock((NSArray*)objs, nil); + } + +}]; + + + + + + + } + + + /*! + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * \param tags Tags to filter by + * \returns NSArray* + */ + -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags completionHandler: (void (^)(NSArray* output, NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByTags", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/findByTags", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(tags != nil) { + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(tags != nil) { - queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; + queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; - } - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + } + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - - // response is in a container - // array container response type - return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - return; - } - - if([data isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; - for (NSDictionary* dict in (NSArray*)data) { - - - SWGPet* d = [[SWGPet alloc] initWithDictionary:dict error:nil]; - - [objs addObject:d]; - } - completionBlock((NSArray*)objs, nil); - } - - - }]; - + - - - - + + // response is in a container + // array container response type +return [self.apiClient dictionary: requestUrl +method: @"GET" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSDictionary *data, NSError *error) { +if (error) { +completionBlock(nil, error); +return; } -/*! - * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * \param petId ID of pet that needs to be fetched - * \returns SWGPet* - */ --(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId + if([data isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]]; + for (NSDictionary* dict in (NSArray*)data) { + + + SWGPet* d = [[SWGPet alloc] initWithDictionary:dict error:nil]; + + [objs addObject:d]; + } + completionBlock((NSArray*)objs, nil); + } + +}]; + + + + + + + } + + + /*! + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * \param petId ID of pet that needs to be fetched + * \returns SWGPet* + */ + -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId completionHandler: (void (^)(SWGPet* output, NSError* error))completionBlock { - - // verify the required parameter 'petId' is set - NSAssert(petId != nil, @"Missing the required parameter `petId` when calling getPetById"); - + + // verify the required parameter 'petId' is set + NSAssert(petId != nil, @"Missing the required parameter `petId` when calling getPetById"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; - - id bodyDictionary = nil; - - - - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - - - // non container response - - - - - // complex response + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; - // comples response type + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + + id bodyDictionary = nil; + + + + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + + + + + + + + + + // non container response + + + + + // complex response + // comples response type return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - - return; - } - SWGPet* result = nil; - if (data) { - result = [[SWGPet alloc] initWithDictionary:data error:nil]; - } - completionBlock(result , nil); - - }]; + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + completionBlock: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error); + return; + } + SWGPet* result = nil; + if (data) { + result = [[SWGPet alloc] initWithDictionary:data error:nil]; + } + completionBlock(result , nil); + + }]; + + + + + } - - -} - -/*! - * Updates a pet in the store with form data - * - * \param petId ID of pet that needs to be updated - * \param name Updated name of the pet - * \param status Updated status of the pet - * \returns void - */ --(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId + /*! + * Updates a pet in the store with form data + * + * \param petId ID of pet that needs to be updated + * \param name Updated name of the pet + * \param status Updated status of the pet + * \returns void + */ + -(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId name: (NSString*) name status: (NSString*) status completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'petId' is set - NSAssert(petId != nil, @"Missing the required parameter `petId` when calling updatePetWithForm"); - + + // verify the required parameter 'petId' is set + NSAssert(petId != nil, @"Missing the required parameter `petId` when calling updatePetWithForm"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - - formParams[@"name"] = name; - - if(bodyDictionary == nil) { - bodyDictionary = [[NSMutableArray alloc] init]; - } - [bodyDictionary addObject:formParams]; - - - formParams[@"status"] = status; - - if(bodyDictionary == nil) { - bodyDictionary = [[NSMutableArray alloc] init]; - } - [bodyDictionary addObject:formParams]; - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; + + + formParams[@"name"] = name; + + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; } - completionBlock(nil); - }]; + [bodyDictionary addObject:formParams]; + + + formParams[@"status"] = status; + + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; + } + [bodyDictionary addObject:formParams]; + + + + + + + + + + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; +} +completionBlock(nil); +}]; + + + } -} - -/*! - * Deletes a pet - * - * \param apiKey - * \param petId Pet id to delete - * \returns void - */ --(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey + /*! + * Deletes a pet + * + * \param apiKey + * \param petId Pet id to delete + * \returns void + */ + -(NSNumber*) deletePetWithCompletionBlock: (NSString*) apiKey petId: (NSNumber*) petId completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'petId' is set - NSAssert(petId != nil, @"Missing the required parameter `petId` when calling deletePet"); - + + // verify the required parameter 'petId' is set + NSAssert(petId != nil, @"Missing the required parameter `petId` when calling deletePet"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - if(apiKey != nil) + if(apiKey != nil) headerParams[@"api_key"] = apiKey; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"DELETE" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; + - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"DELETE" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * uploads an image - * - * \param petId ID of pet to update - * \param additionalMetadata Additional data to pass to server - * \param file file to upload - * \returns void - */ --(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId + + } + + + /*! + * uploads an image + * + * \param petId ID of pet to update + * \param additionalMetadata Additional data to pass to server + * \param file file to upload + * \returns void + */ + -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId additionalMetadata: (NSString*) additionalMetadata file: (SWGFile*) file completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'petId' is set - NSAssert(petId != nil, @"Missing the required parameter `petId` when calling uploadFile"); - + + // verify the required parameter 'petId' is set + NSAssert(petId != nil, @"Missing the required parameter `petId` when calling uploadFile"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}/uploadImage", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}/uploadImage", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - - formParams[@"additionalMetadata"] = additionalMetadata; - - if(bodyDictionary == nil) { - bodyDictionary = [[NSMutableArray alloc] init]; - } - [bodyDictionary addObject:formParams]; - - - requestContentType = @"multipart/form-data"; - if(bodyDictionary == nil) { - bodyDictionary = [[NSMutableArray alloc] init]; - } - if(file != nil) { - [bodyDictionary addObject:file]; - file.paramName = @"file"; - } - - if(bodyDictionary == nil) { - bodyDictionary = [[NSMutableArray alloc] init]; - } - [bodyDictionary addObject:formParams]; - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; + + + formParams[@"additionalMetadata"] = additionalMetadata; + + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; } - completionBlock(nil); - }]; + [bodyDictionary addObject:formParams]; + + + requestContentType = @"multipart/form-data"; + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; + } + if(file != nil) { + [bodyDictionary addObject:file]; + file.paramName = @"file"; + } + + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; + } + [bodyDictionary addObject:formParams]; + + + + + + + + + + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; +} +completionBlock(nil); +}]; + + + } -} - - + @end diff --git a/samples/client/petstore/objc/client/SWGStoreApi.h b/samples/client/petstore/objc/client/SWGStoreApi.h index 49d8db806c8..b24b00aea7a 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.h +++ b/samples/client/petstore/objc/client/SWGStoreApi.h @@ -1,80 +1,86 @@ -#import +#import + #import "SWGOrder.h" #import "SWGObject.h" #import "SWGApiClient.h" -@interface SWGStoreApi: NSObject + @interface SWGStoreApi: NSObject -@property(nonatomic, assign)SWGApiClient *apiClient; + @property(nonatomic, assign)SWGApiClient *apiClient; --(instancetype) initWithApiClient:(SWGApiClient *)apiClient; --(void) addHeader:(NSString*)value forKey:(NSString*)key; --(unsigned long) requestQueueSize; -+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; -+(void) setBasePath:(NSString*)basePath; -+(NSString*) getBasePath; -/** - - Returns pet inventories by status - Returns a map of status codes to quantities - - - - return type: NSDictionary* - */ --(NSNumber*) getInventoryWithCompletionBlock : - (void (^)(NSDictionary* output, NSError* error))completionBlock; + -(instancetype) initWithApiClient:(SWGApiClient *)apiClient; + -(void) addHeader:(NSString*)value forKey:(NSString*)key; + -(unsigned long) requestQueueSize; + +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; + +(void) setBasePath:(NSString*)basePath; + +(NSString*) getBasePath; + /** + Returns pet inventories by status + Returns a map of status codes to quantities -/** + - Place an order for a pet - + return type: NSDictionary* + */ + -(NSNumber*) getInventoryWithCompletionBlock : + (void (^)(NSDictionary* output, NSError* error))completionBlock; + - @param body order placed for purchasing the pet - - - return type: SWGOrder* - */ --(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body + - completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; + /** + + Place an order for a pet + + + @param body order placed for purchasing the pet + + + return type: SWGOrder* + */ + -(NSNumber*) placeOrderWithCompletionBlock :(SWGOrder*) body + + completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; + + + + /** + Find purchase order by ID + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -/** + @param orderId ID of pet that needs to be fetched + - Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + return type: SWGOrder* + */ + -(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId + + completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; + - @param orderId ID of pet that needs to be fetched - - - return type: SWGOrder* - */ --(NSNumber*) getOrderByIdWithCompletionBlock :(NSString*) orderId + - completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock; + /** + + Delete purchase order by ID + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + @param orderId ID of the order that needs to be deleted + + + return type: + */ + -(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId + + + completionHandler: (void (^)(NSError* error))completionBlock; + + - -/** - - Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - - @param orderId ID of the order that needs to be deleted - - - return type: - */ --(NSNumber*) deleteOrderWithCompletionBlock :(NSString*) orderId - - - completionHandler: (void (^)(NSError* error))completionBlock; - - - @end diff --git a/samples/client/petstore/objc/client/SWGStoreApi.m b/samples/client/petstore/objc/client/SWGStoreApi.m index a112db6d639..6f548410dc8 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.m +++ b/samples/client/petstore/objc/client/SWGStoreApi.m @@ -1,478 +1,478 @@ -#import "SWGStoreApi.h" -#import "SWGFile.h" -#import "SWGQueryParamCollection.h" -#import "SWGOrder.h" + #import "SWGStoreApi.h" + #import "SWGFile.h" + #import "SWGQueryParamCollection.h" + #import "SWGOrder.h" + + - -@interface SWGStoreApi () + @interface SWGStoreApi () @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; -@end + @end -@implementation SWGStoreApi + @implementation SWGStoreApi -static NSString * basePath = @"http://petstore.swagger.io/v2"; + static NSString * basePath = @"http://petstore.swagger.io/v2"; -#pragma mark - Initialize methods + #pragma mark - Initialize methods -- (id) init { + - (id) init { self = [super init]; if (self) { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - self.defaultHeaders = [NSMutableDictionary dictionary]; + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -- (id) initWithApiClient:(SWGApiClient *)apiClient { + - (id) initWithApiClient:(SWGApiClient *)apiClient { self = [super init]; if (self) { - if (apiClient) { - self.apiClient = apiClient; - } - else { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - } - self.defaultHeaders = [NSMutableDictionary dictionary]; + if (apiClient) { + self.apiClient = apiClient; + } + else { + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + } + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -#pragma mark - + #pragma mark - -+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { + +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGStoreApi* singletonAPI = nil; if (singletonAPI == nil) { - singletonAPI = [[SWGStoreApi alloc] init]; - [singletonAPI addHeader:headerValue forKey:key]; + singletonAPI = [[SWGStoreApi alloc] init]; + [singletonAPI addHeader:headerValue forKey:key]; } return singletonAPI; -} + } -+(void) setBasePath:(NSString*)path { + +(void) setBasePath:(NSString*)path { basePath = path; -} + } -+(NSString*) getBasePath { + +(NSString*) getBasePath { return basePath; -} + } --(void) addHeader:(NSString*)value forKey:(NSString*)key { + -(void) addHeader:(NSString*)value forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(void) setHeaderValue:(NSString*) value - forKey:(NSString*)key { + -(void) setHeaderValue:(NSString*) value + forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(unsigned long) requestQueueSize { + -(unsigned long) requestQueueSize { return [SWGApiClient requestQueueSize]; -} + } -/*! - * Returns pet inventories by status - * Returns a map of status codes to quantities - * \returns NSDictionary* - */ --(NSNumber*) getInventoryWithCompletionBlock: + + /*! + * Returns pet inventories by status + * Returns a map of status codes to quantities + * \returns NSDictionary* + */ + -(NSNumber*) getInventoryWithCompletionBlock: (void (^)(NSDictionary* output, NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/inventory", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/inventory", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[@"api_key"]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[@"api_key"]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - - // response is in a container - // map container response type - return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - return; - } - - NSDictionary *result = nil; - if (data) { - result = [[NSDictionary alloc]initWithDictionary: data]; - } - completionBlock(data, nil); - - }]; - + - - - - + + // response is in a container + // map container response type +return [self.apiClient dictionary: requestUrl +method: @"GET" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSDictionary *data, NSError *error) { +if (error) { +completionBlock(nil, error); +return; } + NSDictionary *result = nil; + if (data) { + result = [[NSDictionary alloc]initWithDictionary: data]; + } + completionBlock(data, nil); +}]; + -/*! - * Place an order for a pet - * - * \param body order placed for purchasing the pet - * \returns SWGOrder* - */ --(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body + + + + + } + + + /*! + * Place an order for a pet + * + * \param body order placed for purchasing the pet + * \returns SWGOrder* + */ + -(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - - - - - - - - // non container response - - - - - // complex response + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } - // comples response type + + + + + + + + // non container response + + + + + // complex response + // comples response type return [self.apiClient dictionary: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - - return; - } - SWGOrder* result = nil; - if (data) { - result = [[SWGOrder alloc] initWithDictionary:data error:nil]; - } - completionBlock(result , nil); - - }]; + method: @"POST" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + completionBlock: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error); + return; + } + SWGOrder* result = nil; + if (data) { + result = [[SWGOrder alloc] initWithDictionary:data error:nil]; + } + completionBlock(result , nil); + + }]; + + + + + } - - -} - -/*! - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * \param orderId ID of pet that needs to be fetched - * \returns SWGOrder* - */ --(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId + /*! + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * \param orderId ID of pet that needs to be fetched + * \returns SWGOrder* + */ + -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId completionHandler: (void (^)(SWGOrder* output, NSError* error))completionBlock { - - // verify the required parameter 'orderId' is set - NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling getOrderById"); - + + // verify the required parameter 'orderId' is set + NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling getOrderById"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - - - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - - - // non container response - - - - - // complex response + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; - // comples response type + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyDictionary = nil; + + + + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + + + + + + + + + + // non container response + + + + + // complex response + // comples response type return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - - return; - } - SWGOrder* result = nil; - if (data) { - result = [[SWGOrder alloc] initWithDictionary:data error:nil]; - } - completionBlock(result , nil); - - }]; + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + completionBlock: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error); + return; + } + SWGOrder* result = nil; + if (data) { + result = [[SWGOrder alloc] initWithDictionary:data error:nil]; + } + completionBlock(result , nil); + + }]; + + + + + } - - -} - -/*! - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * \param orderId ID of the order that needs to be deleted - * \returns void - */ --(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId + /*! + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * \param orderId ID of the order that needs to be deleted + * \returns void + */ + -(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'orderId' is set - NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling deleteOrder"); - + + // verify the required parameter 'orderId' is set + NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling deleteOrder"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"DELETE" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; + - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"DELETE" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; + + } + + @end diff --git a/samples/client/petstore/objc/client/SWGTag.h b/samples/client/petstore/objc/client/SWGTag.h index d9cc84be270..0938ab30905 100644 --- a/samples/client/petstore/objc/client/SWGTag.h +++ b/samples/client/petstore/objc/client/SWGTag.h @@ -1,15 +1,21 @@ -#import +#import + #import "SWGObject.h" + -@protocol SWGTag -@end - -@interface SWGTag : SWGObject + @protocol SWGTag + @end + @interface SWGTag : SWGObject -@property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSString* name; + -@property(nonatomic) NSString* name; - -@end + @end + diff --git a/samples/client/petstore/objc/client/SWGTag.m b/samples/client/petstore/objc/client/SWGTag.m index 5d48a099070..8425464dbd5 100644 --- a/samples/client/petstore/objc/client/SWGTag.m +++ b/samples/client/petstore/objc/client/SWGTag.m @@ -1,22 +1,24 @@ -#import "SWGTag.h" + + #import "SWGTag.h" -@implementation SWGTag - -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; -} + @implementation SWGTag -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_id", @"name"]; + + (JSONKeyMapper *)keyMapper + { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; + } - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} + + (BOOL)propertyIsOptional:(NSString *)propertyName + { + NSArray *optionalProperties = @[@"_id", @"name"]; -@end + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } + } + + + @end diff --git a/samples/client/petstore/objc/client/SWGUser.h b/samples/client/petstore/objc/client/SWGUser.h index f505ca2c041..a4ffaf6ae72 100644 --- a/samples/client/petstore/objc/client/SWGUser.h +++ b/samples/client/petstore/objc/client/SWGUser.h @@ -1,28 +1,40 @@ -#import +#import + #import "SWGObject.h" + -@protocol SWGUser -@end - -@interface SWGUser : SWGObject + @protocol SWGUser + @end + @interface SWGUser : SWGObject -@property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSNumber* _id; + + + @property(nonatomic) NSString* username; + + + @property(nonatomic) NSString* firstName; + + + @property(nonatomic) NSString* lastName; + + + @property(nonatomic) NSString* email; + + + @property(nonatomic) NSString* password; + + + @property(nonatomic) NSString* phone; + + /* User Status [optional] + */ + @property(nonatomic) NSNumber* userStatus; + -@property(nonatomic) NSString* username; - -@property(nonatomic) NSString* firstName; - -@property(nonatomic) NSString* lastName; - -@property(nonatomic) NSString* email; - -@property(nonatomic) NSString* password; - -@property(nonatomic) NSString* phone; -/* User Status [optional] - */ -@property(nonatomic) NSNumber* userStatus; - -@end + @end + diff --git a/samples/client/petstore/objc/client/SWGUser.m b/samples/client/petstore/objc/client/SWGUser.m index 060b65ffa12..4fd1dbdbe28 100644 --- a/samples/client/petstore/objc/client/SWGUser.m +++ b/samples/client/petstore/objc/client/SWGUser.m @@ -1,22 +1,24 @@ -#import "SWGUser.h" + + #import "SWGUser.h" -@implementation SWGUser - -+ (JSONKeyMapper *)keyMapper -{ - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; -} + @implementation SWGUser -+ (BOOL)propertyIsOptional:(NSString *)propertyName -{ - NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; + + (JSONKeyMapper *)keyMapper + { + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; + } - if ([optionalProperties containsObject:propertyName]) { - return YES; - } - else { - return NO; - } -} + + (BOOL)propertyIsOptional:(NSString *)propertyName + { + NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; -@end + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } + } + + + @end diff --git a/samples/client/petstore/objc/client/SWGUserApi.h b/samples/client/petstore/objc/client/SWGUserApi.h index e6e73ddfba6..acaa861a536 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.h +++ b/samples/client/petstore/objc/client/SWGUserApi.h @@ -1,148 +1,158 @@ -#import +#import + #import "SWGUser.h" #import "SWGObject.h" #import "SWGApiClient.h" -@interface SWGUserApi: NSObject + @interface SWGUserApi: NSObject -@property(nonatomic, assign)SWGApiClient *apiClient; + @property(nonatomic, assign)SWGApiClient *apiClient; --(instancetype) initWithApiClient:(SWGApiClient *)apiClient; --(void) addHeader:(NSString*)value forKey:(NSString*)key; --(unsigned long) requestQueueSize; -+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; -+(void) setBasePath:(NSString*)basePath; -+(NSString*) getBasePath; -/** - - Create user - This can only be done by the logged in user. - - @param body Created user object - - - return type: - */ --(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body + -(instancetype) initWithApiClient:(SWGApiClient *)apiClient; + -(void) addHeader:(NSString*)value forKey:(NSString*)key; + -(unsigned long) requestQueueSize; + +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; + +(void) setBasePath:(NSString*)basePath; + +(NSString*) getBasePath; + /** + + Create user + This can only be done by the logged in user. + + @param body Created user object + + + return type: + */ + -(NSNumber*) createUserWithCompletionBlock :(SWGUser*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; + + - completionHandler: (void (^)(NSError* error))completionBlock; + /** + Creates list of users with given input array + -/** + @param body List of user object + - Creates list of users with given input array - + return type: + */ + -(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; - @param body List of user object - - - return type: - */ --(NSNumber*) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body + + /** + + Creates list of users with given input array + + + @param body List of user object + + + return type: + */ + -(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; + + - completionHandler: (void (^)(NSError* error))completionBlock; + /** + Logs user into the system + -/** + @param username The user name for login + @param password The password for login in clear text + - Creates list of users with given input array - + return type: NSString* + */ + -(NSNumber*) loginUserWithCompletionBlock :(NSString*) username + password:(NSString*) password + + completionHandler: (void (^)(NSString* output, NSError* error))completionBlock; + - @param body List of user object - - - return type: - */ --(NSNumber*) createUsersWithListInputWithCompletionBlock :(NSArray*) body + + /** + + Logs out current logged in user session + + + + + return type: + */ + -(NSNumber*) logoutUserWithCompletionBlock : + + (void (^)(NSError* error))completionBlock; + + - completionHandler: (void (^)(NSError* error))completionBlock; + /** + Get user by user name + -/** + @param username The name that needs to be fetched. Use user1 for testing. + - Logs user into the system - + return type: SWGUser* + */ + -(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username + + completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock; + - @param username The user name for login - @param password The password for login in clear text - - - return type: NSString* - */ --(NSNumber*) loginUserWithCompletionBlock :(NSString*) username - password:(NSString*) password + - completionHandler: (void (^)(NSString* output, NSError* error))completionBlock; + /** + + Updated user + This can only be done by the logged in user. + + @param username name that need to be deleted + @param body Updated user object + + + return type: + */ + -(NSNumber*) updateUserWithCompletionBlock :(NSString*) username + body:(SWGUser*) body + + + completionHandler: (void (^)(NSError* error))completionBlock; + + + /** + Delete user + This can only be done by the logged in user. -/** + @param username The name that needs to be deleted + - Logs out current logged in user session - + return type: + */ + -(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username + + + completionHandler: (void (^)(NSError* error))completionBlock; - - - return type: - */ --(NSNumber*) logoutUserWithCompletionBlock : + - (void (^)(NSError* error))completionBlock; - - -/** - - Get user by user name - - - @param username The name that needs to be fetched. Use user1 for testing. - - - return type: SWGUser* - */ --(NSNumber*) getUserByNameWithCompletionBlock :(NSString*) username - - completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock; - - - -/** - - Updated user - This can only be done by the logged in user. - - @param username name that need to be deleted - @param body Updated user object - - - return type: - */ --(NSNumber*) updateUserWithCompletionBlock :(NSString*) username - body:(SWGUser*) body - - - completionHandler: (void (^)(NSError* error))completionBlock; - - -/** - - Delete user - This can only be done by the logged in user. - - @param username The name that needs to be deleted - - - return type: - */ --(NSNumber*) deleteUserWithCompletionBlock :(NSString*) username - - - completionHandler: (void (^)(NSError* error))completionBlock; - - @end diff --git a/samples/client/petstore/objc/client/SWGUserApi.m b/samples/client/petstore/objc/client/SWGUserApi.m index e2fe69aca8d..7c861609f36 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.m +++ b/samples/client/petstore/objc/client/SWGUserApi.m @@ -1,891 +1,896 @@ -#import "SWGUserApi.h" -#import "SWGFile.h" -#import "SWGQueryParamCollection.h" -#import "SWGUser.h" + #import "SWGUserApi.h" + #import "SWGFile.h" + #import "SWGQueryParamCollection.h" + #import "SWGUser.h" + + - -@interface SWGUserApi () + @interface SWGUserApi () @property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; -@end + @end -@implementation SWGUserApi + @implementation SWGUserApi -static NSString * basePath = @"http://petstore.swagger.io/v2"; + static NSString * basePath = @"http://petstore.swagger.io/v2"; -#pragma mark - Initialize methods + #pragma mark - Initialize methods -- (id) init { + - (id) init { self = [super init]; if (self) { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - self.defaultHeaders = [NSMutableDictionary dictionary]; + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -- (id) initWithApiClient:(SWGApiClient *)apiClient { + - (id) initWithApiClient:(SWGApiClient *)apiClient { self = [super init]; if (self) { - if (apiClient) { - self.apiClient = apiClient; - } - else { - self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; - } - self.defaultHeaders = [NSMutableDictionary dictionary]; + if (apiClient) { + self.apiClient = apiClient; + } + else { + self.apiClient = [SWGApiClient sharedClientFromPool:basePath]; + } + self.defaultHeaders = [NSMutableDictionary dictionary]; } return self; -} + } -#pragma mark - + #pragma mark - -+(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { + +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGUserApi* singletonAPI = nil; if (singletonAPI == nil) { - singletonAPI = [[SWGUserApi alloc] init]; - [singletonAPI addHeader:headerValue forKey:key]; + singletonAPI = [[SWGUserApi alloc] init]; + [singletonAPI addHeader:headerValue forKey:key]; } return singletonAPI; -} + } -+(void) setBasePath:(NSString*)path { + +(void) setBasePath:(NSString*)path { basePath = path; -} + } -+(NSString*) getBasePath { + +(NSString*) getBasePath { return basePath; -} + } --(void) addHeader:(NSString*)value forKey:(NSString*)key { + -(void) addHeader:(NSString*)value forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(void) setHeaderValue:(NSString*) value - forKey:(NSString*)key { + -(void) setHeaderValue:(NSString*) value + forKey:(NSString*)key { [self.defaultHeaders setValue:value forKey:key]; -} + } --(unsigned long) requestQueueSize { + -(unsigned long) requestQueueSize { return [SWGApiClient requestQueueSize]; -} + } -/*! - * Create user - * This can only be done by the logged in user. - * \param body Created user object - * \returns void - */ --(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body + + /*! + * Create user + * This can only be done by the logged in user. + * \param body Created user object + * \returns void + */ + -(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body completionHandler: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Creates list of users with given input array - * - * \param body List of user object - * \returns void - */ --(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body + + } + + + /*! + * Creates list of users with given input array + * + * \param body List of user object + * \returns void + */ + -(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body completionHandler: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithArray", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Creates list of users with given input array - * - * \param body List of user object - * \returns void - */ --(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body + + } + + + /*! + * Creates list of users with given input array + * + * \param body List of user object + * \returns void + */ + -(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body completionHandler: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/createWithList", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"POST" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"POST" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Logs user into the system - * - * \param username The user name for login - * \param password The password for login in clear text - * \returns NSString* - */ --(NSNumber*) loginUserWithCompletionBlock: (NSString*) username + + } + + + /*! + * Logs user into the system + * + * \param username The user name for login + * \param password The password for login in clear text + * \returns NSString* + */ + -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username password: (NSString*) password completionHandler: (void (^)(NSString* output, NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/login", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/login", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(username != nil) { + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + if(username != nil) { queryParams[@"username"] = username; - } - if(password != nil) { + } + if(password != nil) { queryParams[@"password"] = password; - } - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + } + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - - - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - - - // non container response - - - // primitive response - // primitive response type - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(nil, error); - return; - } - NSString *result = data ? [[NSString alloc]initWithString: data] : nil; - completionBlock(result, nil); - }]; - - - - - - - // complex response - + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } - + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyDictionary = nil; + + + + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + + + + + + + + + + // non container response + + + // primitive response + // primitive response type +return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"GET" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(nil, error); +return; } +NSString *result = data ? [[NSString alloc]initWithString: data] : nil; +completionBlock(result, nil); +}]; + -/*! - * Logs out current logged in user session - * - * \returns void - */ --(NSNumber*) logoutUserWithCompletionBlock: + + + // complex response + + + + + } + + + /*! + * Logs out current logged in user session + * + * \returns void + */ + -(NSNumber*) logoutUserWithCompletionBlock: (void (^)(NSError* error))completionBlock { - + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/logout", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/logout", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; + - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"GET" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Get user by user name - * - * \param username The name that needs to be fetched. Use user1 for testing. - * \returns SWGUser* - */ --(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username + + } + + + /*! + * Get user by user name + * + * \param username The name that needs to be fetched. Use user1 for testing. + * \returns SWGUser* + */ + -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username completionHandler: (void (^)(SWGUser* output, NSError* error))completionBlock { - - // verify the required parameter 'username' is set - NSAssert(username != nil, @"Missing the required parameter `username` when calling getUserByName"); - + + // verify the required parameter 'username' is set + NSAssert(username != nil, @"Missing the required parameter `username` when calling getUserByName"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - - - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - - - - - - - - - - // non container response - - - - - // complex response + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; - // comples response type + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyDictionary = nil; + + + + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + + + + + + + + + + // non container response + + + + + // complex response + // comples response type return [self.apiClient dictionary: requestUrl - method: @"GET" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSDictionary *data, NSError *error) { - if (error) { - completionBlock(nil, error); - - return; - } - SWGUser* result = nil; - if (data) { - result = [[SWGUser alloc] initWithDictionary:data error:nil]; - } - completionBlock(result , nil); - - }]; + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + completionBlock: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error); + return; + } + SWGUser* result = nil; + if (data) { + result = [[SWGUser alloc] initWithDictionary:data error:nil]; + } + completionBlock(result , nil); + + }]; + + + + + } - - -} - -/*! - * Updated user - * This can only be done by the logged in user. - * \param username name that need to be deleted - * \param body Updated user object - * \returns void - */ --(NSNumber*) updateUserWithCompletionBlock: (NSString*) username + /*! + * Updated user + * This can only be done by the logged in user. + * \param username name that need to be deleted + * \param body Updated user object + * \returns void + */ + -(NSNumber*) updateUserWithCompletionBlock: (NSString*) username body: (SWGUser*) body completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'username' is set - NSAssert(username != nil, @"Missing the required parameter `username` when calling updateUser"); - + + // verify the required parameter 'username' is set + NSAssert(username != nil, @"Missing the required parameter `username` when calling updateUser"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - id __body = body; + // Authentication setting + NSArray *authSettings = @[]; - if(__body != nil && [__body isKindOfClass:[NSArray class]]){ - NSMutableArray * objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)__body) { + id bodyDictionary = nil; + + id __body = body; + + if(__body != nil && [__body isKindOfClass:[NSArray class]]){ + NSMutableArray * objs = [[NSMutableArray alloc] init]; + for (id dict in (NSArray*)__body) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[(SWGObject*)dict toDictionary]]; } else{ - [objs addObject:dict]; + [objs addObject:dict]; } - } - bodyDictionary = objs; - } - else if([__body respondsToSelector:@selector(toDictionary)]) { - bodyDictionary = [(SWGObject*)__body toDictionary]; - } - else if([__body isKindOfClass:[NSString class]]) { - // convert it to a dictionary - NSError * error; - NSString * str = (NSString*)__body; - NSDictionary *JSON = + } + bodyDictionary = objs; + } + else if([__body respondsToSelector:@selector(toDictionary)]) { + bodyDictionary = [(SWGObject*)__body toDictionary]; + } + else if([__body isKindOfClass:[NSString class]]) { + // convert it to a dictionary + NSError * error; + NSString * str = (NSString*)__body; + NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding] - options: NSJSONReadingMutableContainers - error: &error]; - bodyDictionary = JSON; - } - - + options: NSJSONReadingMutableContainers + error: &error]; + bodyDictionary = JSON; + } + + - + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"PUT" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; - - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"PUT" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; -/*! - * Delete user - * This can only be done by the logged in user. - * \param username The name that needs to be deleted - * \returns void - */ --(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username + + } + + + /*! + * Delete user + * This can only be done by the logged in user. + * \param username The name that needs to be deleted + * \returns void + */ + -(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username completionHandler: (void (^)(NSError* error))completionBlock { - - // verify the required parameter 'username' is set - NSAssert(username != nil, @"Missing the required parameter `username` when calling deleteUser"); - + + // verify the required parameter 'username' is set + NSAssert(username != nil, @"Missing the required parameter `username` when calling deleteUser"); + - NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; + NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath]; - // remove format in URL if needed - if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) + // remove format in URL if needed + if ([requestUrl rangeOfString:@".{format}"].location != NSNotFound) [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:@".{format}"] withString:@".json"]; - [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; - + [requestUrl replaceCharactersInRange: [requestUrl rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; - } + } - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { + } + else { responseContentType = @""; - } + } - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - // Authentication setting - NSArray *authSettings = @[]; - - id bodyDictionary = nil; - - + // Authentication setting + NSArray *authSettings = @[]; - NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; + id bodyDictionary = nil; + + - - + NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - + + - + - + - - // it's void - return [self.apiClient stringWithCompletionBlock: requestUrl - method: @"DELETE" - queryParams: queryParams - body: bodyDictionary - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - completionBlock: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error); - return; - } - completionBlock(nil); - }]; + - + + // it's void + return [self.apiClient stringWithCompletionBlock: requestUrl +method: @"DELETE" +queryParams: queryParams +body: bodyDictionary +headerParams: headerParams +authSettings: authSettings +requestContentType: requestContentType +responseContentType: responseContentType +completionBlock: ^(NSString *data, NSError *error) { +if (error) { +completionBlock(error); +return; } +completionBlock(nil); +}]; + + } + + @end diff --git a/samples/client/petstore/php/SwaggerClient-php/composer.json b/samples/client/petstore/php/SwaggerClient-php/composer.json index ed6fb2804b2..a097d929c62 100644 --- a/samples/client/petstore/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore/php/SwaggerClient-php/composer.json @@ -1,34 +1,32 @@ { - "name": "SwaggerClient/SwaggerClient-php", - "description": "", - "keywords": [ - "swagger", - "php", - "sdk", - "api" - ], - "homepage": "http://swagger.io", - "license": "Apache v2", - "authors": [ - { - "name": "Swagger and contributors", - "homepage": "https://github.com/swagger-api/swagger-codegen" - } - ], - "require": { - "php": ">=5.3.3", - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "~0.6.1", - "squizlabs/php_codesniffer": "~2.0" - }, - "autoload": { - "psr-4": { - "SwaggerClient\\": "lib/" - } - } +"name": "SwaggerClient/SwaggerClient-php", +"description": "", +"keywords": [ +"swagger", +"php", +"sdk", +"api" +], +"homepage": "http://swagger.io", +"license": "Apache v2", +"authors": [ +{ +"name": "Swagger and contributors", +"homepage": "https://github.com/swagger-api/swagger-codegen" +} +], +"require": { +"php": ">=5.3.3", +"ext-curl": "*", +"ext-json": "*", +"ext-mbstring": "*" +}, +"require-dev": { +"phpunit/phpunit": "~4.0", +"satooshi/php-coveralls": "~0.6.1", +"squizlabs/php_codesniffer": "~2.0" +}, +"autoload": { +"psr-4": { "SwaggerClient\\" : "lib/" } +} } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php index b8357f9b479..dd4c3c1f1b1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php @@ -43,412 +43,409 @@ class ApiClient { function __construct($host = null) { if ($host === null) { $this->host = 'http://petstore.swagger.io/v2'; - } else { - $this->host = $host; - } - } +} else { +$this->host = $host; +} +} - /** - * add default header - * - * @param string $header_name header name (e.g. Token) - * @param string $header_value header value (e.g. 1z8wp3) - */ - public function addDefaultHeader($header_name, $header_value) { - if (!is_string($header_name)) - throw new \InvalidArgumentException('Header name must be a string.'); +/** +* add default header +* +* @param string $header_name header name (e.g. Token) +* @param string $header_value header value (e.g. 1z8wp3) +*/ +public function addDefaultHeader($header_name, $header_value) { +if (!is_string($header_name)) +throw new \InvalidArgumentException('Header name must be a string.'); - self::$default_header[$header_name] = $header_value; - } +self::$default_header[$header_name] = $header_value; +} - /** - * get the default header - * - * @return array default header - */ - public function getDefaultHeader() { - return self::$default_header; - } +/** +* get the default header +* +* @return array default header +*/ +public function getDefaultHeader() { +return self::$default_header; +} - /** - * delete the default header based on header name - * - * @param string $header_name header name (e.g. Token) - */ - public function deleteDefaultHeader($header_name) { - unset(self::$default_header[$header_name]); - } +/** +* delete the default header based on header name +* +* @param string $header_name header name (e.g. Token) +*/ +public function deleteDefaultHeader($header_name) { +unset(self::$default_header[$header_name]); +} - /** - * set the user agent of the api client - * - * @param string $user_agent the user agent of the api client - */ - public function setUserAgent($user_agent) { - if (!is_string($user_agent)) - throw new \InvalidArgumentException('User-agent must be a string.'); +/** +* set the user agent of the api client +* +* @param string $user_agent the user agent of the api client +*/ +public function setUserAgent($user_agent) { +if (!is_string($user_agent)) +throw new \InvalidArgumentException('User-agent must be a string.'); - $this->user_agent= $user_agent; - } +$this->user_agent= $user_agent; +} - /** - * get the user agent of the api client - * - * @return string user agent - */ - public function getUserAgent($user_agent) { - return $this->user_agent; - } +/** +* get the user agent of the api client +* +* @return string user agent +*/ +public function getUserAgent($user_agent) { +return $this->user_agent; +} - /** - * set the HTTP timeout value - * - * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] - */ - public function setTimeout($seconds) { - if (!is_numeric($seconds) || $seconds < 0) - throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); +/** +* set the HTTP timeout value +* +* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] +*/ +public function setTimeout($seconds) { +if (!is_numeric($seconds) || $seconds < 0) +throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); - $this->curl_timeout = $seconds; - } +$this->curl_timeout = $seconds; +} - /** - * get the HTTP timeout value - * - * @return string HTTP timeout value - */ - public function getTimeout() { - return $this->curl_timeout; - } +/** +* get the HTTP timeout value +* +* @return string HTTP timeout value +*/ +public function getTimeout() { +return $this->curl_timeout; +} - /** - * Get API key (with prefix if set) - * @param string key name - * @return string API key with the prefix - */ - public function getApiKeyWithPrefix($apiKey) { - if (isset(Configuration::$apiKeyPrefix[$apiKey])) { - return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; - } else if (isset(Configuration::$apiKey[$apiKey])) { - return Configuration::$apiKey[$apiKey]; - } else { - return; - } - } +/** +* Get API key (with prefix if set) +* @param string key name +* @return string API key with the prefix +*/ +public function getApiKeyWithPrefix($apiKey) { +if (isset(Configuration::$apiKeyPrefix[$apiKey])) { +return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; +} else if (isset(Configuration::$apiKey[$apiKey])) { +return Configuration::$apiKey[$apiKey]; +} else { +return; +} +} - /** - * update hearder and query param based on authentication setting - * - * @param array $headerParams header parameters (by ref) - * @param array $queryParams query parameters (by ref) - * @param array $authSettings array of authentication scheme (e.g ['api_key']) - */ - public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) - { - if (count($authSettings) == 0) - return; +/** +* update hearder and query param based on authentication setting +* +* @param array $headerParams header parameters (by ref) +* @param array $queryParams query parameters (by ref) +* @param array $authSettings array of authentication scheme (e.g ['api_key']) +*/ +public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) +{ +if (count($authSettings) == 0) +return; - // one endpoint can have more than 1 auth settings - foreach($authSettings as $auth) { - // determine which one to use - switch($auth) { - - case 'api_key': - $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); - - break; - - case 'petstore_auth': - - //TODO support oauth - break; - - default: - //TODO show warning about security definition not found - } - } - } - - /** - * @param string $resourcePath path to method endpoint - * @param string $method method to call - * @param array $queryParams parameters to be place in query URL - * @param array $postData parameters to be placed in POST body - * @param array $headerParams parameters to be place in request header - * @return mixed - */ - public function callApi($resourcePath, $method, $queryParams, $postData, - $headerParams, $authSettings) { +// one endpoint can have more than 1 auth settings +foreach($authSettings as $auth) { +// determine which one to use +switch($auth) { + case 'api_key': + $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); + + break; + case 'petstore_auth': + + //TODO support oauth + break; +default: +//TODO show warning about security definition not found +} +} +} - $headers = array(); +/** +* @param string $resourcePath path to method endpoint +* @param string $method method to call +* @param array $queryParams parameters to be place in query URL +* @param array $postData parameters to be placed in POST body +* @param array $headerParams parameters to be place in request header +* @return mixed +*/ +public function callApi($resourcePath, $method, $queryParams, $postData, +$headerParams, $authSettings) { - # determine authentication setting - $this->updateParamsForAuth($headerParams, $queryParams, $authSettings); +$headers = array(); - # construct the http header - $headerParams = array_merge((array)self::$default_header, (array)$headerParams); +# determine authentication setting +$this->updateParamsForAuth($headerParams, $queryParams, $authSettings); - foreach ($headerParams as $key => $val) { - $headers[] = "$key: $val"; - } +# construct the http header +$headerParams = array_merge((array)self::$default_header, (array)$headerParams); - // form data - if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { - $postData = http_build_query($postData); - } - else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model - $postData = json_encode($this->sanitizeForSerialization($postData)); - } +foreach ($headerParams as $key => $val) { +$headers[] = "$key: $val"; +} - $url = $this->host . $resourcePath; +// form data +if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { +$postData = http_build_query($postData); +} +else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model +$postData = json_encode($this->sanitizeForSerialization($postData)); +} - $curl = curl_init(); - // set timeout, if needed - if ($this->curl_timeout != 0) { - curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout); - } - // return the result on success, rather than just TRUE - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); +$url = $this->host . $resourcePath; - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); +$curl = curl_init(); +// set timeout, if needed +if ($this->curl_timeout != 0) { +curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout); +} +// return the result on success, rather than just TRUE +curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - if (! empty($queryParams)) { - $url = ($url . '?' . http_build_query($queryParams)); - } +curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - if ($method == self::$POST) { - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PATCH) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method != self::$GET) { - throw new ApiException('Method ' . $method . ' is not recognized.'); - } - curl_setopt($curl, CURLOPT_URL, $url); +if (! empty($queryParams)) { +$url = ($url . '?' . http_build_query($queryParams)); +} - // Set user agent - curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); +if ($method == self::$POST) { +curl_setopt($curl, CURLOPT_POST, true); +curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); +} else if ($method == self::$PATCH) { +curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); +curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); +} else if ($method == self::$PUT) { +curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); +curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); +} else if ($method == self::$DELETE) { +curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); +curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); +} else if ($method != self::$GET) { +throw new ApiException('Method ' . $method . ' is not recognized.'); +} +curl_setopt($curl, CURLOPT_URL, $url); - // debugging for curl - if (Configuration::$debug) { - error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file); +// Set user agent +curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); - curl_setopt($curl, CURLOPT_VERBOSE, 1); - curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); - } else { - curl_setopt($curl, CURLOPT_VERBOSE, 0); - } +// debugging for curl +if (Configuration::$debug) { +error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file); - // obtain the HTTP response headers - curl_setopt($curl, CURLOPT_HEADER, 1); +curl_setopt($curl, CURLOPT_VERBOSE, 1); +curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); +} else { +curl_setopt($curl, CURLOPT_VERBOSE, 0); +} - // Make the request - $response = curl_exec($curl); - $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); - $http_header = substr($response, 0, $http_header_size); - $http_body = substr($response, $http_header_size); - $response_info = curl_getinfo($curl); +// obtain the HTTP response headers +curl_setopt($curl, CURLOPT_HEADER, 1); - // debug HTTP response body - if (Configuration::$debug) { - error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); - } +// Make the request +$response = curl_exec($curl); +$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); +$http_header = substr($response, 0, $http_header_size); +$http_body = substr($response, $http_header_size); +$response_info = curl_getinfo($curl); - // Handle the response - if ($response_info['http_code'] == 0) { - throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); - } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { - $data = json_decode($http_body); - if (json_last_error() > 0) { // if response is a string - $data = $http_body; - } - } else { - throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)", - $response_info['http_code'], $http_header, $http_body); - } - return $data; - } +// debug HTTP response body +if (Configuration::$debug) { +error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); +} - /** - * Build a JSON POST object - */ - protected function sanitizeForSerialization($data) - { - if (is_scalar($data) || null === $data) { - $sanitized = $data; - } else if ($data instanceof \DateTime) { - $sanitized = $data->format(\DateTime::ISO8601); - } else if (is_array($data)) { - foreach ($data as $property => $value) { - $data[$property] = $this->sanitizeForSerialization($value); - } - $sanitized = $data; - } else if (is_object($data)) { - $values = array(); - foreach (array_keys($data::$swaggerTypes) as $property) { - if ($data->$property !== null) { - $values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property); - } - } - $sanitized = $values; - } else { - $sanitized = (string)$data; - } +// Handle the response +if ($response_info['http_code'] == 0) { +throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); +} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { +$data = json_decode($http_body); +if (json_last_error() > 0) { // if response is a string +$data = $http_body; +} +} else { +throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)", +$response_info['http_code'], $http_header, $http_body); +} +return $data; +} - return $sanitized; - } +/** +* Build a JSON POST object +*/ +protected function sanitizeForSerialization($data) +{ +if (is_scalar($data) || null === $data) { +$sanitized = $data; +} else if ($data instanceof \DateTime) { +$sanitized = $data->format(\DateTime::ISO8601); +} else if (is_array($data)) { +foreach ($data as $property => $value) { +$data[$property] = $this->sanitizeForSerialization($value); +} +$sanitized = $data; +} else if (is_object($data)) { +$values = array(); +foreach (array_keys($data::$swaggerTypes) as $property) { +if ($data->$property !== null) { +$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property); +} +} +$sanitized = $values; +} else { +$sanitized = (string)$data; +} - /** - * Take value and turn it into a string suitable for inclusion in - * the path, by url-encoding. - * @param string $value a string which will be part of the path - * @return string the serialized object - */ - public static function toPathValue($value) { - return rawurlencode(self::toString($value)); - } +return $sanitized; +} - /** - * Take value and turn it into a string suitable for inclusion in - * the query, by imploding comma-separated if it's an object. - * If it's a string, pass through unchanged. It will be url-encoded - * later. - * @param object $object an object to be serialized to a string - * @return string the serialized object - */ - public static function toQueryValue($object) { - if (is_array($object)) { - return implode(',', $object); - } else { - return self::toString($object); - } - } +/** +* Take value and turn it into a string suitable for inclusion in +* the path, by url-encoding. +* @param string $value a string which will be part of the path +* @return string the serialized object +*/ +public static function toPathValue($value) { +return rawurlencode(self::toString($value)); +} - /** - * Take value and turn it into a string suitable for inclusion in - * the header. If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * @param string $value a string which will be part of the header - * @return string the header string - */ - public static function toHeaderValue($value) { - return self::toString($value); - } +/** +* Take value and turn it into a string suitable for inclusion in +* the query, by imploding comma-separated if it's an object. +* If it's a string, pass through unchanged. It will be url-encoded +* later. +* @param object $object an object to be serialized to a string +* @return string the serialized object +*/ +public static function toQueryValue($object) { +if (is_array($object)) { +return implode(',', $object); +} else { +return self::toString($object); +} +} - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * @param string $value the value of the form parameter - * @return string the form string - */ - public static function toFormValue($value) { - return self::toString($value); - } +/** +* Take value and turn it into a string suitable for inclusion in +* the header. If it's a string, pass through unchanged +* If it's a datetime object, format it in ISO8601 +* @param string $value a string which will be part of the header +* @return string the header string +*/ +public static function toHeaderValue($value) { +return self::toString($value); +} - /** - * Take value and turn it into a string suitable for inclusion in - * the parameter. If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * @param string $value the value of the parameter - * @return string the header string - */ - public static function toString($value) { - if ($value instanceof \DateTime) { // datetime in ISO8601 format - return $value->format(\DateTime::ISO8601); - } - else { - return $value; - } - } +/** +* Take value and turn it into a string suitable for inclusion in +* the http body (form parameter). If it's a string, pass through unchanged +* If it's a datetime object, format it in ISO8601 +* @param string $value the value of the form parameter +* @return string the form string +*/ +public static function toFormValue($value) { +return self::toString($value); +} - /** - * Deserialize a JSON string into an object - * - * @param object $object object or primitive to be deserialized - * @param string $class class name is passed as a string - * @return object an instance of $class - */ - public static function deserialize($data, $class) - { - if (null === $data) { - $deserialized = null; - } elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int] - $inner = substr($class, 4, -1); - $deserialized = array(); - if(strrpos($inner, ",") !== false) { - $subClass_array = explode(',', $inner, 2); - $subClass = $subClass_array[1]; - foreach ($data as $key => $value) { - $deserialized[$key] = self::deserialize($value, $subClass); - } - } - } elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) { - $subClass = substr($class, 6, -1); - $values = array(); - foreach ($data as $key => $value) { - $values[] = self::deserialize($value, $subClass); - } - $deserialized = $values; - } elseif ($class == 'DateTime') { - $deserialized = new \DateTime($data); - } elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { - settype($data, $class); - $deserialized = $data; - } else { - $class = "SwaggerClient\\models\\".$class; - $instance = new $class(); - foreach ($instance::$swaggerTypes as $property => $type) { - $original_property_name = $instance::$attributeMap[$property]; - if (isset($original_property_name) && isset($data->$original_property_name)) { - $instance->$property = self::deserialize($data->$original_property_name, $type); - } - } - $deserialized = $instance; - } +/** +* Take value and turn it into a string suitable for inclusion in +* the parameter. If it's a string, pass through unchanged +* If it's a datetime object, format it in ISO8601 +* @param string $value the value of the parameter +* @return string the header string +*/ +public static function toString($value) { +if ($value instanceof \DateTime) { // datetime in ISO8601 format +return $value->format(\DateTime::ISO8601); +} +else { +return $value; +} +} - return $deserialized; - } +/** +* Deserialize a JSON string into an object +* +* @param object $object object or primitive to be deserialized +* @param string $class class name is passed as a string +* @return object an instance of $class +*/ +public static function deserialize($data, $class) +{ +if (null === $data) { +$deserialized = null; +} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int] +$inner = substr($class, 4, -1); +$deserialized = array(); +if(strrpos($inner, ",") !== false) { +$subClass_array = explode(',', $inner, 2); +$subClass = $subClass_array[1]; +foreach ($data as $key => $value) { +$deserialized[$key] = self::deserialize($value, $subClass); +} +} +} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) { +$subClass = substr($class, 6, -1); +$values = array(); +foreach ($data as $key => $value) { +$values[] = self::deserialize($value, $subClass); +} +$deserialized = $values; +} elseif ($class == 'DateTime') { +$deserialized = new \DateTime($data); +} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { +settype($data, $class); +$deserialized = $data; +} else { +$class = "SwaggerClient\\models\\".$class; +$instance = new $class(); +foreach ($instance::$swaggerTypes as $property => $type) { +$original_property_name = $instance::$attributeMap[$property]; +if (isset($original_property_name) && isset($data->$original_property_name)) { +$instance->$property = self::deserialize($data->$original_property_name, $type); +} +} +$deserialized = $instance; +} - /* - * return the header 'Accept' based on an array of Accept provided - * - * @param array[string] $accept Array of header - * @return string Accept (e.g. application/json) - */ - public static function selectHeaderAccept($accept) { - if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { - return NULL; - } elseif (preg_grep("/application\/json/i", $accept)) { - return 'application/json'; - } else { - return implode(',', $accept); - } - } +return $deserialized; +} - /* - * return the content type based on an array of content-type provided - * - * @param array[string] content_type_array Array fo content-type - * @return string Content-Type (e.g. application/json) - */ - public static function selectHeaderContentType($content_type) { - if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { - return 'application/json'; - } elseif (preg_grep("/application\/json/i", $content_type)) { - return 'application/json'; - } else { - return implode(',', $content_type); - } - } +/* +* return the header 'Accept' based on an array of Accept provided +* +* @param array[string] $accept Array of header +* @return string Accept (e.g. application/json) +*/ +public static function selectHeaderAccept($accept) { +if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { +return NULL; +} elseif (preg_grep("/application\/json/i", $accept)) { +return 'application/json'; +} else { +return implode(',', $accept); +} +} + +/* +* return the content type based on an array of content-type provided +* +* @param array[string] content_type_array Array fo content-type +* @return string Content-Type (e.g. application/json) +*/ +public static function selectHeaderContentType($content_type) { +if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { +return 'application/json'; +} elseif (preg_grep("/application\/json/i", $content_type)) { +return 'application/json'; +} else { +return implode(',', $content_type); +} +} } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php index 51f2c4b877e..f11b319a4ce 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php @@ -34,25 +34,25 @@ class ApiException extends Exception { public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) { parent::__construct($message, $code); $this->response_headers = $responseHeaders; - $this->response_body = $responseBody; - } +$this->response_body = $responseBody; +} - /** - * Get the HTTP response header - * - * @return string HTTP response header - */ - public function getResponseHeaders() { - return $this->response_headers; - } +/** +* Get the HTTP response header +* +* @return string HTTP response header +*/ +public function getResponseHeaders() { +return $this->response_headers; +} - /** - * Get the HTTP response body - * - * @return string HTTP response body - */ - public function getResponseBody() { - return $this->response_body; - } +/** +* Get the HTTP response body +* +* @return string HTTP response body +*/ +public function getResponseBody() { +return $this->response_body; +} } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php index a022430b9cd..f1bec027d3d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php @@ -29,515 +29,506 @@ class PetApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; - } - else - $this->apiClient = Configuration::$apiClient; // use the default one - } else { - $this->apiClient = $apiClient; // use the one provided by the user +} +else +$this->apiClient = Configuration::$apiClient; // use the default one +} else { +$this->apiClient = $apiClient; // use the one provided by the user +} +} + +private $apiClient; // instance of the ApiClient + +/** +* get the API client +*/ +public function getApiClient() { +return $this->apiClient; +} + +/** +* set the API client +*/ +public function setApiClient($apiClient) { +$this->apiClient = $apiClient; +} + + /** + * updatePet + * + * Update an existing pet + * + * @param Pet $body Pet object that needs to be added to the store (required) + * @return void + */ + public function updatePet($body) { + + + // parse inputs + $resourcePath = "/pet"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "PUT"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } - } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); - private $apiClient; // instance of the ApiClient + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - /** - * get the API client - */ - public function getApiClient() { - return $this->apiClient; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - /** - * set the API client - */ - public function setApiClient($apiClient) { - $this->apiClient = $apiClient; - } + // authentication setting, if any + $authSettings = array('petstore_auth'); - - /** - * updatePet - * - * Update an existing pet - * - * @param Pet $body Pet object that needs to be added to the store (required) - * @return void - */ - public function updatePet($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/pet"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "PUT"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); + + } + /** + * addPet + * + * Add a new pet to the store + * + * @param Pet $body Pet object that needs to be added to the store (required) + * @return void + */ + public function addPet($body) { + - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // parse inputs + $resourcePath = "/pet"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // authentication setting, if any + $authSettings = array('petstore_auth'); - - } - - /** - * addPet - * - * Add a new pet to the store - * - * @param Pet $body Pet object that needs to be added to the store (required) - * @return void - */ - public function addPet($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/pet"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); + + } + /** + * findPetsByStatus + * + * Finds Pets by status + * + * @param array[string] $status Status values that need to be considered for filter (required) + * @return array[Pet] + */ + public function findPetsByStatus($status) { + - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // parse inputs + $resourcePath = "/pet/findByStatus"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // query params + if($status !== null) { + $queryParams['status'] = $this->apiClient->toQueryValue($status); + } + + + + - // authentication setting, if any - $authSettings = array('petstore_auth'); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // authentication setting, if any + $authSettings = array('petstore_auth'); - - } - - /** - * findPetsByStatus - * - * Finds Pets by status - * - * @param array[string] $status Status values that need to be considered for filter (required) - * @return array[Pet] - */ - public function findPetsByStatus($status) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/pet/findByStatus"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + if(! $response) { + return null; + } - // query params - if($status !== null) { - $queryParams['status'] = $this->apiClient->toQueryValue($status); - } - - - - + $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); + return $responseObject; + } + /** + * findPetsByTags + * + * Finds Pets by tags + * + * @param array[string] $tags Tags to filter by (required) + * @return array[Pet] + */ + public function findPetsByTags($tags) { + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // parse inputs + $resourcePath = "/pet/findByTags"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // authentication setting, if any - $authSettings = array('petstore_auth'); + // query params + if($tags !== null) { + $queryParams['tags'] = $this->apiClient->toQueryValue($tags); + } + + + + - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - if(! $response) { - return null; - } + // authentication setting, if any + $authSettings = array('petstore_auth'); - $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); - return $responseObject; - } - - /** - * findPetsByTags - * - * Finds Pets by tags - * - * @param array[string] $tags Tags to filter by (required) - * @return array[Pet] - */ - public function findPetsByTags($tags) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/pet/findByTags"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + if(! $response) { + return null; + } - // query params - if($tags !== null) { - $queryParams['tags'] = $this->apiClient->toQueryValue($tags); - } - - - - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } - - // authentication setting, if any - $authSettings = array('petstore_auth'); - - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); - - if(! $response) { - return null; - } - - $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); - return $responseObject; - } - - /** - * getPetById - * - * Find pet by ID - * - * @param int $pet_id ID of pet that needs to be fetched (required) - * @return Pet - */ - public function getPetById($pet_id) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); + return $responseObject; + } + /** + * getPetById + * + * Find pet by ID + * + * @param int $pet_id ID of pet that needs to be fetched (required) + * @return Pet + */ + public function getPetById($pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('api_key', 'petstore_auth'); + // authentication setting, if any + $authSettings = array('api_key', 'petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'Pet'); - return $responseObject; - } - - /** - * updatePetWithForm - * - * Updates a pet in the store with form data - * - * @param string $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (required) - * @param string $status Updated status of the pet (required) - * @return void - */ - public function updatePetWithForm($pet_id, $name, $status) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + $responseObject = $this->apiClient->deserialize($response,'Pet'); + return $responseObject; + } + /** + * updatePetWithForm + * + * Updates a pet in the store with form data + * + * @param string $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (required) + * @param string $status Updated status of the pet (required) + * @return void + */ + public function updatePetWithForm($pet_id, $name, $status) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - // form params - if ($name !== null) { - $formParams['name'] = $this->apiClient->toFormValue($name); - }// form params - if ($status !== null) { - $formParams['status'] = $this->apiClient->toFormValue($status); - } - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + // form params + if ($name !== null) { + $formParams['name'] = $this->apiClient->toFormValue($name); + }// form params + if ($status !== null) { + $formParams['status'] = $this->apiClient->toFormValue($status); + } + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - - /** - * deletePet - * - * Deletes a pet - * - * @param string $api_key (required) - * @param int $pet_id Pet id to delete (required) - * @return void - */ - public function deletePet($api_key, $pet_id) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + + } + /** + * deletePet + * + * Deletes a pet + * + * @param string $api_key (required) + * @param int $pet_id Pet id to delete (required) + * @return void + */ + public function deletePet($api_key, $pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - // header params - if($api_key !== null) { - $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); - } - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - - + + // header params + if($api_key !== null) { + $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); + } + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - - /** - * uploadFile - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (required) - * @param string $file file to upload (required) - * @return void - */ - public function uploadFile($pet_id, $additional_metadata, $file) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + + } + /** + * uploadFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (required) + * @param string $file file to upload (required) + * @return void + */ + public function uploadFile($pet_id, $additional_metadata, $file) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}/uploadImage"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); + // parse inputs + $resourcePath = "/pet/{petId}/uploadImage"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - // form params - if ($additional_metadata !== null) { - $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata); - }// form params - if ($file !== null) { - $formParams['file'] = '@' . $this->apiClient->toFormValue($file); - } - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + // form params + if ($additional_metadata !== null) { + $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata); + }// form params + if ($file !== null) { + $formParams['file'] = '@' . $this->apiClient->toFormValue($file); + } + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - + + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php index 87937a60283..c4a5dd98127 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php @@ -29,266 +29,261 @@ class StoreApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; - } - else - $this->apiClient = Configuration::$apiClient; // use the default one - } else { - $this->apiClient = $apiClient; // use the one provided by the user +} +else +$this->apiClient = Configuration::$apiClient; // use the default one +} else { +$this->apiClient = $apiClient; // use the one provided by the user +} +} + +private $apiClient; // instance of the ApiClient + +/** +* get the API client +*/ +public function getApiClient() { +return $this->apiClient; +} + +/** +* set the API client +*/ +public function setApiClient($apiClient) { +$this->apiClient = $apiClient; +} + + /** + * getInventory + * + * Returns pet inventories by status + * + * @return map[string,int] + */ + public function getInventory() { + + + // parse inputs + $resourcePath = "/store/inventory"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } - } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - private $apiClient; // instance of the ApiClient + + + + + - /** - * get the API client - */ - public function getApiClient() { - return $this->apiClient; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - /** - * set the API client - */ - public function setApiClient($apiClient) { - $this->apiClient = $apiClient; - } + // authentication setting, if any + $authSettings = array('api_key'); - - /** - * getInventory - * - * Returns pet inventories by status - * - * @return map[string,int] - */ - public function getInventory() { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/store/inventory"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + if(! $response) { + return null; + } - - - - - + $responseObject = $this->apiClient->deserialize($response,'map[string,int]'); + return $responseObject; + } + /** + * placeOrder + * + * Place an order for a pet + * + * @param Order $body order placed for purchasing the pet (required) + * @return Order + */ + public function placeOrder($body) { + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // parse inputs + $resourcePath = "/store/order"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // authentication setting, if any - $authSettings = array('api_key'); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - if(! $response) { - return null; - } + // authentication setting, if any + $authSettings = array(); - $responseObject = $this->apiClient->deserialize($response,'map[string,int]'); - return $responseObject; - } - - /** - * placeOrder - * - * Place an order for a pet - * - * @param Order $body order placed for purchasing the pet (required) - * @return Order - */ - public function placeOrder($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/store/order"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + if(! $response) { + return null; + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } - - // authentication setting, if any - $authSettings = array(); - - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); - - if(! $response) { - return null; - } - - $responseObject = $this->apiClient->deserialize($response,'Order'); - return $responseObject; - } - - /** - * getOrderById - * - * Find purchase order by ID - * - * @param string $order_id ID of pet that needs to be fetched (required) - * @return Order - */ - public function getOrderById($order_id) { - - // verify the required parameter 'order_id' is set - if ($order_id === null) { + $responseObject = $this->apiClient->deserialize($response,'Order'); + return $responseObject; + } + /** + * getOrderById + * + * Find purchase order by ID + * + * @param string $order_id ID of pet that needs to be fetched (required) + * @return Order + */ + public function getOrderById($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById'); - } - + } + - // parse inputs - $resourcePath = "/store/order/{orderId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/store/order/{orderId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($order_id !== null) { - $resourcePath = str_replace("{" . "orderId" . "}", - $this->apiClient->toPathValue($order_id), $resourcePath); - } - - + + + // path params + if($order_id !== null) { + $resourcePath = str_replace("{" . "orderId" . "}", + $this->apiClient->toPathValue($order_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'Order'); - return $responseObject; - } - - /** - * deleteOrder - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @return void - */ - public function deleteOrder($order_id) { - - // verify the required parameter 'order_id' is set - if ($order_id === null) { + $responseObject = $this->apiClient->deserialize($response,'Order'); + return $responseObject; + } + /** + * deleteOrder + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * @return void + */ + public function deleteOrder($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); - } - + } + - // parse inputs - $resourcePath = "/store/order/{orderId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/store/order/{orderId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($order_id !== null) { - $resourcePath = str_replace("{" . "orderId" . "}", - $this->apiClient->toPathValue($order_id), $resourcePath); - } - - + + + // path params + if($order_id !== null) { + $resourcePath = str_replace("{" . "orderId" . "}", + $this->apiClient->toPathValue($order_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - + + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php index 2e16022f25a..7063d11353f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php @@ -29,490 +29,481 @@ class UserApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; - } - else - $this->apiClient = Configuration::$apiClient; // use the default one - } else { - $this->apiClient = $apiClient; // use the one provided by the user +} +else +$this->apiClient = Configuration::$apiClient; // use the default one +} else { +$this->apiClient = $apiClient; // use the one provided by the user +} +} + +private $apiClient; // instance of the ApiClient + +/** +* get the API client +*/ +public function getApiClient() { +return $this->apiClient; +} + +/** +* set the API client +*/ +public function setApiClient($apiClient) { +$this->apiClient = $apiClient; +} + + /** + * createUser + * + * Create user + * + * @param User $body Created user object (required) + * @return void + */ + public function createUser($body) { + + + // parse inputs + $resourcePath = "/user"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; } - } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - private $apiClient; // instance of the ApiClient + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - /** - * get the API client - */ - public function getApiClient() { - return $this->apiClient; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - /** - * set the API client - */ - public function setApiClient($apiClient) { - $this->apiClient = $apiClient; - } + // authentication setting, if any + $authSettings = array(); - - /** - * createUser - * - * Create user - * - * @param User $body Created user object (required) - * @return void - */ - public function createUser($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/user"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + } + /** + * createUsersWithArrayInput + * + * Creates list of users with given input array + * + * @param array[User] $body List of user object (required) + * @return void + */ + public function createUsersWithArrayInput($body) { + - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // parse inputs + $resourcePath = "/user/createWithArray"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // authentication setting, if any - $authSettings = array(); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // authentication setting, if any + $authSettings = array(); - - } - - /** - * createUsersWithArrayInput - * - * Creates list of users with given input array - * - * @param array[User] $body List of user object (required) - * @return void - */ - public function createUsersWithArrayInput($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/user/createWithArray"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + } + /** + * createUsersWithListInput + * + * Creates list of users with given input array + * + * @param array[User] $body List of user object (required) + * @return void + */ + public function createUsersWithListInput($body) { + - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // parse inputs + $resourcePath = "/user/createWithList"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // authentication setting, if any - $authSettings = array(); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // authentication setting, if any + $authSettings = array(); - - } - - /** - * createUsersWithListInput - * - * Creates list of users with given input array - * - * @param array[User] $body List of user object (required) - * @return void - */ - public function createUsersWithListInput($body) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/user/createWithList"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + } + /** + * loginUser + * + * Logs user into the system + * + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * @return string + */ + public function loginUser($username, $password) { + - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // parse inputs + $resourcePath = "/user/login"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // query params + if($username !== null) { + $queryParams['username'] = $this->apiClient->toQueryValue($username); + }// query params + if($password !== null) { + $queryParams['password'] = $this->apiClient->toQueryValue($password); + } + + + + - // authentication setting, if any - $authSettings = array(); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // authentication setting, if any + $authSettings = array(); - - } - - /** - * loginUser - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @return string - */ - public function loginUser($username, $password) { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/user/login"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + if(! $response) { + return null; + } - // query params - if($username !== null) { - $queryParams['username'] = $this->apiClient->toQueryValue($username); - }// query params - if($password !== null) { - $queryParams['password'] = $this->apiClient->toQueryValue($password); - } - - - - + $responseObject = $this->apiClient->deserialize($response,'string'); + return $responseObject; + } + /** + * logoutUser + * + * Logs out current logged in user session + * + * @return void + */ + public function logoutUser() { + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // parse inputs + $resourcePath = "/user/logout"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // authentication setting, if any - $authSettings = array(); + + + + + - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - if(! $response) { - return null; - } + // authentication setting, if any + $authSettings = array(); - $responseObject = $this->apiClient->deserialize($response,'string'); - return $responseObject; - } - - /** - * logoutUser - * - * Logs out current logged in user session - * - * @return void - */ - public function logoutUser() { - + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // parse inputs - $resourcePath = "/user/logout"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - - - - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } - - // authentication setting, if any - $authSettings = array(); - - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); - - - } - - /** - * getUserByName - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @return User - */ - public function getUserByName($username) { - - // verify the required parameter 'username' is set - if ($username === null) { + + } + /** + * getUserByName + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + */ + public function getUserByName($username) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'User'); - return $responseObject; - } - - /** - * updateUser - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param User $body Updated user object (required) - * @return void - */ - public function updateUser($username, $body) { - - // verify the required parameter 'username' is set - if ($username === null) { + $responseObject = $this->apiClient->deserialize($response,'User'); + return $responseObject; + } + /** + * updateUser + * + * Updated user + * + * @param string $username name that need to be deleted (required) + * @param User $body Updated user object (required) + * @return void + */ + public function updateUser($username, $body) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "PUT"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "PUT"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - - /** - * deleteUser - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @return void - */ - public function deleteUser($username) { - - // verify the required parameter 'username' is set - if ($username === null) { + + } + /** + * deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * @return void + */ + public function deleteUser($username) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - + + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php index 7512921b898..bd7d6e9a8d0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php @@ -15,6 +15,7 @@ * limitations under the License. */ + /** * * @@ -29,36 +30,37 @@ use \ArrayAccess; class Category implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'name' => 'string' - ); + 'name' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'name' => 'name' - ); + static $attributeMap = array( + 'id' => 'id', + 'name' => 'name' + ); - - public $id; /* int */ - public $name; /* string */ + + public $id; /* int */ + public $name; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->name = $data["name"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } -} + } + } + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php index 4314d0df6f3..8f25f8da3c5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php @@ -15,6 +15,7 @@ * limitations under the License. */ + /** * * @@ -29,55 +30,56 @@ use \ArrayAccess; class Order implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'pet_id' => 'int', - 'quantity' => 'int', - 'ship_date' => 'DateTime', - 'status' => 'string', - 'complete' => 'boolean' - ); + 'pet_id' => 'int', + 'quantity' => 'int', + 'ship_date' => 'DateTime', + 'status' => 'string', + 'complete' => 'boolean' + ); - static $attributeMap = array( - 'id' => 'id', - 'pet_id' => 'petId', - 'quantity' => 'quantity', - 'ship_date' => 'shipDate', - 'status' => 'status', - 'complete' => 'complete' - ); + static $attributeMap = array( + 'id' => 'id', + 'pet_id' => 'petId', + 'quantity' => 'quantity', + 'ship_date' => 'shipDate', + 'status' => 'status', + 'complete' => 'complete' + ); - - public $id; /* int */ - public $pet_id; /* int */ - public $quantity; /* int */ - public $ship_date; /* DateTime */ - /** - * Order Status - */ - public $status; /* string */ - public $complete; /* boolean */ + + public $id; /* int */ + public $pet_id; /* int */ + public $quantity; /* int */ + public $ship_date; /* DateTime */ + /** + * Order Status + */ + public $status; /* string */ + public $complete; /* boolean */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->pet_id = $data["pet_id"]; $this->quantity = $data["quantity"]; $this->ship_date = $data["ship_date"]; $this->status = $data["status"]; $this->complete = $data["complete"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } -} + } + } + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php index f74c9a88315..918b39b9adf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php @@ -15,6 +15,7 @@ * limitations under the License. */ + /** * * @@ -29,55 +30,56 @@ use \ArrayAccess; class Pet implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'category' => 'Category', - 'name' => 'string', - 'photo_urls' => 'array[string]', - 'tags' => 'array[Tag]', - 'status' => 'string' - ); + 'category' => 'Category', + 'name' => 'string', + 'photo_urls' => 'array[string]', + 'tags' => 'array[Tag]', + 'status' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'category' => 'category', - 'name' => 'name', - 'photo_urls' => 'photoUrls', - 'tags' => 'tags', - 'status' => 'status' - ); + static $attributeMap = array( + 'id' => 'id', + 'category' => 'category', + 'name' => 'name', + 'photo_urls' => 'photoUrls', + 'tags' => 'tags', + 'status' => 'status' + ); - - public $id; /* int */ - public $category; /* Category */ - public $name; /* string */ - public $photo_urls; /* array[string] */ - public $tags; /* array[Tag] */ - /** - * pet status in the store - */ - public $status; /* string */ + + public $id; /* int */ + public $category; /* Category */ + public $name; /* string */ + public $photo_urls; /* array[string] */ + public $tags; /* array[Tag] */ + /** + * pet status in the store + */ + public $status; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->category = $data["category"]; $this->name = $data["name"]; $this->photo_urls = $data["photo_urls"]; $this->tags = $data["tags"]; $this->status = $data["status"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } -} + } + } + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php index 309d4087088..7ae6cc68a3c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php @@ -15,6 +15,7 @@ * limitations under the License. */ + /** * * @@ -29,36 +30,37 @@ use \ArrayAccess; class Tag implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'name' => 'string' - ); + 'name' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'name' => 'name' - ); + static $attributeMap = array( + 'id' => 'id', + 'name' => 'name' + ); - - public $id; /* int */ - public $name; /* string */ + + public $id; /* int */ + public $name; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->name = $data["name"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } -} + } + } + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php index bbdaa1082b4..a705c55af74 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php @@ -15,6 +15,7 @@ * limitations under the License. */ + /** * * @@ -29,40 +30,40 @@ use \ArrayAccess; class User implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'username' => 'string', - 'first_name' => 'string', - 'last_name' => 'string', - 'email' => 'string', - 'password' => 'string', - 'phone' => 'string', - 'user_status' => 'int' - ); + 'username' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'email' => 'string', + 'password' => 'string', + 'phone' => 'string', + 'user_status' => 'int' + ); - static $attributeMap = array( - 'id' => 'id', - 'username' => 'username', - 'first_name' => 'firstName', - 'last_name' => 'lastName', - 'email' => 'email', - 'password' => 'password', - 'phone' => 'phone', - 'user_status' => 'userStatus' - ); + static $attributeMap = array( + 'id' => 'id', + 'username' => 'username', + 'first_name' => 'firstName', + 'last_name' => 'lastName', + 'email' => 'email', + 'password' => 'password', + 'phone' => 'phone', + 'user_status' => 'userStatus' + ); - - public $id; /* int */ - public $username; /* string */ - public $first_name; /* string */ - public $last_name; /* string */ - public $email; /* string */ - public $password; /* string */ - public $phone; /* string */ - /** - * User Status - */ - public $user_status; /* int */ + + public $id; /* int */ + public $username; /* string */ + public $first_name; /* string */ + public $last_name; /* string */ + public $email; /* string */ + public $password; /* string */ + public $phone; /* string */ + /** + * User Status + */ + public $user_status; /* int */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->username = $data["username"]; $this->first_name = $data["first_name"]; @@ -71,21 +72,22 @@ class User implements ArrayAccess { $this->password = $data["password"]; $this->phone = $data["phone"]; $this->user_status = $data["user_status"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } -} + } + } + diff --git a/samples/client/petstore/python/SwaggerPetstore-python/README.md b/samples/client/petstore/python/SwaggerPetstore-python/README.md index 9c590a9a508..f4e99c9fbc9 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 b8cc4cc2a84..fc0e7c60549 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 5f5c2fe81fa..cb262e45343 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): query_params = {} - if 'status' in params: + if 'status' in params: query_params['status'] = params['status'] header_params = {} @@ -182,7 +182,7 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): query_params = {} - if 'tags' in params: + if 'tags' in params: query_params['tags'] = params['tags'] header_params = {} @@ -235,7 +235,7 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 @@ class PetApi(object): :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 @@ class PetApi(object): 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 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 @@ class PetApi(object): :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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 @@ class PetApi(object): :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 @@ class PetApi(object): 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 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 @@ class PetApi(object): :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 @@ class PetApi(object): 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 @@ class PetApi(object): 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 @@ class PetApi(object): # 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 @@ class PetApi(object): 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 1523e3b4be4..4483ea01bd5 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): # 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): :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 @@ class StoreApi(object): 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 @@ class StoreApi(object): # 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 @@ class StoreApi(object): 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 @@ class StoreApi(object): :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 @@ class StoreApi(object): 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 @@ class StoreApi(object): # 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 @@ class StoreApi(object): 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 84a40b06579..893e5e3a5c7 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): # 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): # 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 @@ class UserApi(object): 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 @@ class UserApi(object): :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 @@ class UserApi(object): 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 @@ class UserApi(object): # 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 @@ class UserApi(object): 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 @@ class UserApi(object): :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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): 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 @@ class UserApi(object): :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 @@ class UserApi(object): 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 @@ class UserApi(object): # 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 @@ class UserApi(object): 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 b5bd0a64e0a..c7b3d5af141 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 cfd69ee955c..ada2f33efd3 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/category.py @@ -4,26 +4,27 @@ """ 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 @@ -31,28 +32,29 @@ class Category(object): :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.id = None # int - - - self.name = None # str + + 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 e364ba5b155..02f3d75bb90 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/order.py @@ -4,26 +4,27 @@ """ 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 @@ -31,48 +32,49 @@ class Order(object): :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.id = None # int + + self.pet_id = None # int + + self.quantity = None # int - self.pet_id = None # int + + self.ship_date = None # DateTime + # Order Status + self.status = None # str - self.quantity = None # int - - - self.ship_date = None # DateTime - - # Order Status - self.status = None # str - - - self.complete = None # bool + + 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 a943b639663..dedde9a455a 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/pet.py @@ -4,26 +4,27 @@ """ 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 @@ -31,48 +32,49 @@ class Pet(object): :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.id = None # int + + self.category = None # Category + + self.name = None # str - self.category = None # Category + + self.photo_urls = None # list[str] + + self.tags = None # list[Tag] - self.name = None # str - - - self.photo_urls = None # list[str] - - - self.tags = None # list[Tag] - - # pet status in the store - self.status = None # str + # 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 6347352eba7..fdf647a6e26 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/tag.py @@ -4,26 +4,27 @@ """ 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 @@ -31,28 +32,29 @@ class Tag(object): :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.id = None # int - - - self.name = None # str + + 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 83efcd9ee2b..b6c2eb930d2 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/models/user.py @@ -4,26 +4,27 @@ """ 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 @@ -31,58 +32,59 @@ class User(object): :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.id = None # int + + self.username = None # str + + self.first_name = None # str - self.username = None # str + + self.last_name = None # str + + self.email = None # str - self.first_name = None # str + + self.password = None # str + + self.phone = None # str - self.last_name = None # str - - - self.email = None # str - - - self.password = None # str - - - self.phone = None # str - - # User Status - self.user_status = None # int + # 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 508f3d6693a..d5c79d8395a 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 - - try: - self.body = json.loads(data) - except ValueError: - self.body = data +# 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 - 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) +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) 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 fbd738be680..4a1985d4715 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 @@ setup( 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/qt5cpp/client/SWGCategory.cpp b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp index 9a5aaa14af7..5676a27b0dd 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp @@ -1,105 +1,112 @@ -#include "SWGCategory.h" + #include "SWGCategory.h" -#include "SWGHelpers.h" + #include "SWGHelpers.h" -#include -#include -#include -#include + #include + + #include + + #include + + #include + -namespace Swagger { + namespace Swagger { -SWGCategory::SWGCategory(QString* json) { - init(); - this->fromJson(*json); -} + SWGCategory::SWGCategory(QString* json) { + init(); + this->fromJson(*json); + } -SWGCategory::SWGCategory() { - init(); -} + SWGCategory::SWGCategory() { + init(); + } -SWGCategory::~SWGCategory() { - this->cleanup(); -} + SWGCategory::~SWGCategory() { + this->cleanup(); + } -void -SWGCategory::init() { + void + SWGCategory::init() { id = 0L; name = new QString(""); -} + } -void -SWGCategory::cleanup() { + void + SWGCategory::cleanup() { if(name != NULL) { - delete name; - } + delete name; + } -} + } -SWGCategory* -SWGCategory::fromJson(QString &json) { - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); - return this; -} + SWGCategory* + SWGCategory::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; + } -void -SWGCategory::fromJsonObject(QJsonObject &pJson) { + void + SWGCategory::fromJsonObject(QJsonObject &pJson) { setValue(&id, pJson["id"], "qint64", ""); setValue(&name, pJson["name"], "QString", "QString"); -} + } -QString -SWGCategory::asJson () -{ - QJsonObject* obj = this->asJsonObject(); - - QJsonDocument doc(*obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} + QString + SWGCategory::asJson () + { + QJsonObject* obj = this->asJsonObject(); -QJsonObject* -SWGCategory::asJsonObject() { - QJsonObject* obj = new QJsonObject(); + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); + } + + QJsonObject* + SWGCategory::asJsonObject() { + QJsonObject* obj = new QJsonObject(); obj->insert("id", QJsonValue(id)); - - toJsonValue(QString("name"), name, obj, QString("QString")); - - + + toJsonValue(QString("name"), name, obj, QString("QString")); + + - return obj; -} + return obj; + } -qint64 -SWGCategory::getId() { - return id; -} -void -SWGCategory::setId(qint64 id) { - this->id = id; -} + + qint64 + SWGCategory::getId() { + return id; + } + void + SWGCategory::setId(qint64 id) { + this->id = id; + } -QString* -SWGCategory::getName() { - return name; -} -void -SWGCategory::setName(QString* name) { - this->name = name; -} + + QString* + SWGCategory::getName() { + return name; + } + void + SWGCategory::setName(QString* name) { + this->name = name; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.h b/samples/client/petstore/qt5cpp/client/SWGCategory.h index b1d5b65538f..2e7072f9111 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.h +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.h @@ -1,47 +1,48 @@ /* - * SWGCategory.h - * - * - */ +* SWGCategory.h +* +* +*/ #ifndef SWGCategory_H_ #define SWGCategory_H_ -#include +#include + #include -#include "SWGObject.h" + #include "SWGObject.h" -namespace Swagger { + namespace Swagger { -class SWGCategory: public SWGObject { -public: + class SWGCategory: public SWGObject { + public: SWGCategory(); SWGCategory(QString* json); - virtual ~SWGCategory(); - void init(); - void cleanup(); + virtual ~SWGCategory(); + void init(); + void cleanup(); - QString asJson (); - QJsonObject* asJsonObject(); - void fromJsonObject(QJsonObject &json); + QString asJson (); + QJsonObject* asJsonObject(); + void fromJsonObject(QJsonObject &json); SWGCategory* fromJson(QString &jsonString); qint64 getId(); - void setId(qint64 id); + void setId(qint64 id); QString* getName(); - void setName(QString* name); + void setName(QString* name); -private: + private: qint64 id; QString* name; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SWGCategory_H_ */ + #endif /* SWGCategory_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp index 7f4d748c2dc..0cc60d91b90 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp @@ -1,166 +1,201 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" -#import -#import -#import +#import + + #import + + #import + -namespace Swagger { + namespace Swagger { -void -setValue(void* value, QJsonValue obj, QString type, QString complexType) { - if(value == NULL) { - // can't set value with a null pointer - return; - } - if(QStringLiteral("bool").compare(type) == 0) { - bool * val = static_cast(value); - *val = obj.toBool(); - } - else if(QStringLiteral("qint32").compare(type) == 0) { - qint32 *val = static_cast(value); - *val = obj.toInt(); - } - else if(QStringLiteral("qint64").compare(type) == 0) { - qint64 *val = static_cast(value); - *val = obj.toVariant().toLongLong(); - } - else if (QStringLiteral("QString").compare(type) == 0) { - QString **val = static_cast(value); + void + setValue(void* value, QJsonValue obj, QString type, QString complexType) { + if(value == NULL) { + // can't set value with a null pointer + return; + } + if(QStringLiteral("bool").compare(type) == 0) { + bool * val = static_cast + (value); + *val = obj.toBool(); + } + else if(QStringLiteral("qint32").compare(type) == 0) { + qint32 *val = static_cast + (value); + *val = obj.toInt(); + } + else if(QStringLiteral("qint64").compare(type) == 0) { + qint64 *val = static_cast + (value); + *val = obj.toVariant().toLongLong(); + } + else if (QStringLiteral("QString").compare(type) == 0) { + QString **val = static_cast + (value); - if(val != NULL) { + if(val != NULL) { if(!obj.isNull()) { - // create a new value and return - delete *val; - *val = new QString(obj.toString()); - return; + // create a new value and return + delete *val; + *val = new QString(obj.toString()); + return; } else { - // set target to NULL - delete *val; - *val = NULL; + // set target to NULL + delete *val; + *val = NULL; } - } - else { + } + else { qDebug() << "Can't set value because the target pointer is NULL"; - } - } - else if(type.startsWith("SWG") && obj.isObject()) { - // complex type - QJsonObject jsonObj = obj.toObject(); - SWGObject * so = (SWGObject*)Swagger::create(type); - if(so != NULL) { + } + } + else if(type.startsWith("SWG") && obj.isObject()) { + // complex type + QJsonObject jsonObj = obj.toObject(); + SWGObject * so = (SWGObject*)Swagger::create(type); + if(so != NULL) { so->fromJsonObject(jsonObj); - SWGObject **val = static_cast(value); + SWGObject **val = static_cast + (value); delete *val; *val = so; - } - } - else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) { - // list of values - QList* output = new QList(); - QJsonArray arr = obj.toArray(); - foreach (const QJsonValue & jval, arr) { + } + } + else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) { + // list of values + QList + * output = new QList + (); + QJsonArray arr = obj.toArray(); + foreach (const QJsonValue & jval, arr) { if(complexType.startsWith("SWG")) { - // it's an object - SWGObject * val = (SWGObject*)create(complexType); - QJsonObject t = jval.toObject(); + // it's an object + SWGObject * val = (SWGObject*)create(complexType); + QJsonObject t = jval.toObject(); - val->fromJsonObject(t); - output->append(val); + val->fromJsonObject(t); + output->append(val); } else { - // primitives - if(QStringLiteral("qint32").compare(complexType) == 0) { - qint32 val; - setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral("")); - output->append((void*)&val); - } - else if(QStringLiteral("qint64").compare(complexType) == 0) { - qint64 val; - setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral("")); - output->append((void*)&val); - } - else if(QStringLiteral("bool").compare(complexType) == 0) { - bool val; - setValue(&val, jval, QStringLiteral("bool"), QStringLiteral("")); - output->append((void*)&val); - } + // primitives + if(QStringLiteral("qint32").compare(complexType) == 0) { + qint32 val; + setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("qint64").compare(complexType) == 0) { + qint64 val; + setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("bool").compare(complexType) == 0) { + bool val; + setValue(&val, jval, QStringLiteral("bool"), QStringLiteral("")); + output->append((void*)&val); + } + } + } + QList + **val = static_cast + **>(value); + delete *val; + *val = output; + } } - } - QList **val = static_cast**>(value); - delete *val; - *val = output; - } -} -void -toJsonValue(QString name, void* value, QJsonObject* output, QString type) { - if(value == NULL) { - return; - } - if(type.startsWith("SWG")) { - SWGObject *swgObject = reinterpret_cast(value); - if(swgObject != NULL) { - QJsonObject* o = (*swgObject).asJsonObject(); - if(name != NULL) { + void + toJsonValue(QString name, void* value, QJsonObject* output, QString type) { + if(value == NULL) { + return; + } + if(type.startsWith("SWG")) { + SWGObject *swgObject = reinterpret_cast + (value); + if(swgObject != NULL) { + QJsonObject* o = (*swgObject).asJsonObject(); + if(name != NULL) { output->insert(name, *o); delete o; - } - else { + } + else { output->empty(); foreach(QString key, o->keys()) { - output->insert(key, o->value(key)); + output->insert(key, o->value(key)); + } + } + } + } + else if(QStringLiteral("QString").compare(type) == 0) { + QString* str = static_cast + (value); + output->insert(name, QJsonValue(*str)); + } + else if(QStringLiteral("qint32").compare(type) == 0) { + qint32* str = static_cast + (value); + output->insert(name, QJsonValue(*str)); + } + else if(QStringLiteral("qint64").compare(type) == 0) { + qint64* str = static_cast + (value); + output->insert(name, QJsonValue(*str)); + } + else if(QStringLiteral("bool").compare(type) == 0) { + bool* str = static_cast + (value); + output->insert(name, QJsonValue(*str)); + } } - } - } - } - else if(QStringLiteral("QString").compare(type) == 0) { - QString* str = static_cast(value); - output->insert(name, QJsonValue(*str)); - } - else if(QStringLiteral("qint32").compare(type) == 0) { - qint32* str = static_cast(value); - output->insert(name, QJsonValue(*str)); - } - else if(QStringLiteral("qint64").compare(type) == 0) { - qint64* str = static_cast(value); - output->insert(name, QJsonValue(*str)); - } - else if(QStringLiteral("bool").compare(type) == 0) { - bool* str = static_cast(value); - output->insert(name, QJsonValue(*str)); - } -} -void -toJsonArray(QList* value, QJsonArray* output, QString innerName, QString innerType) { - foreach(void* obj, *value) { - QJsonObject element; + void + toJsonArray(QList + * value, QJsonArray* output, QString innerName, QString innerType) { + foreach(void* obj, *value) { + QJsonObject element; - toJsonValue(NULL, obj, &element, innerType); - output->append(element); - } -} + toJsonValue(NULL, obj, &element, innerType); + output->append(element); + } + } -QString -stringValue(QString* value) { - QString* str = static_cast(value); - return QString(*str); -} + QString + stringValue(QString* value) { + QString* str = static_cast + (value); + return QString(*str); + } -QString -stringValue(qint32 value) { - return QString::number(value); -} + QString + stringValue(qint32 value) { + return QString::number(value); + } -QString -stringValue(qint64 value) { - return QString::number(value); -} + QString + stringValue(qint64 value) { + return QString::number(value); + } -QString -stringValue(bool value) { - return QString(value ? "true" : "false"); -} -} /* namespace Swagger */ + QString + stringValue(bool value) { + return QString(value ? "true" : "false"); + } + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.h b/samples/client/petstore/qt5cpp/client/SWGHelpers.h index 3a02c0952d5..52bba0455bc 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.h +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.h @@ -1,17 +1,20 @@ #ifndef SWGHELPERS_H #define SWGHELPERS_H -#include +#include + -namespace Swagger { + namespace Swagger { void setValue(void* value, QJsonValue obj, QString type, QString complexType); - void toJsonArray(QList* value, QJsonArray* output, QString innerName, QString innerType); + void toJsonArray(QList + * value, QJsonArray* output, QString innerName, QString innerType); void toJsonValue(QString name, void* value, QJsonObject* output, QString type); bool isCompatibleJsonValue(QString type); QString stringValue(QString* value); QString stringValue(qint32 value); QString stringValue(qint64 value); QString stringValue(bool value); -} + } -#endif // SWGHELPERS_H + #endif // SWGHELPERS_H diff --git a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h index 588a7ad952b..cdcfc123ee3 100644 --- a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h +++ b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h @@ -2,44 +2,45 @@ #define ModelFactory_H_ -#include "SWGUser.h" -#include "SWGCategory.h" -#include "SWGPet.h" -#include "SWGTag.h" -#include "SWGOrder.h" + #include "SWGUser.h" + #include "SWGCategory.h" + #include "SWGPet.h" + #include "SWGTag.h" + #include "SWGOrder.h" namespace Swagger { - inline void* create(QString type) { - if(QString("SWGUser").compare(type) == 0) { - return new SWGUser(); - } - if(QString("SWGCategory").compare(type) == 0) { - return new SWGCategory(); - } - if(QString("SWGPet").compare(type) == 0) { - return new SWGPet(); - } - if(QString("SWGTag").compare(type) == 0) { - return new SWGTag(); - } - if(QString("SWGOrder").compare(type) == 0) { - return new SWGOrder(); - } - - return NULL; - } +inline void* create(QString type) { +if(QString("SWGUser").compare(type) == 0) { +return new SWGUser(); +} +if(QString("SWGCategory").compare(type) == 0) { +return new SWGCategory(); +} +if(QString("SWGPet").compare(type) == 0) { +return new SWGPet(); +} +if(QString("SWGTag").compare(type) == 0) { +return new SWGTag(); +} +if(QString("SWGOrder").compare(type) == 0) { +return new SWGOrder(); +} - inline void* create(QString json, QString type) { - void* val = create(type); - if(val != NULL) { - SWGObject* obj = static_cast(val); - return obj->fromJson(json); - } - if(type.startsWith("QString")) { - return new QString(); - } - return NULL; - } +return NULL; +} + +inline void* create(QString json, QString type) { +void* val = create(type); +if(val != NULL) { +SWGObject* obj = static_cast +(val); +return obj->fromJson(json); +} +if(type.startsWith("QString")) { +return new QString(); +} +return NULL; +} } /* namespace Swagger */ #endif /* ModelFactory_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGObject.h b/samples/client/petstore/qt5cpp/client/SWGObject.h index 6cb5c042772..f9ccab6ac1d 100644 --- a/samples/client/petstore/qt5cpp/client/SWGObject.h +++ b/samples/client/petstore/qt5cpp/client/SWGObject.h @@ -1,24 +1,25 @@ #ifndef _SWG_OBJECT_H_ #define _SWG_OBJECT_H_ -#include +#include + -class SWGObject { - public: + class SWGObject { + public: virtual QJsonObject* asJsonObject() { - return NULL; + return NULL; } virtual ~SWGObject() {} virtual SWGObject* fromJson(QString &jsonString) { - Q_UNUSED(jsonString); - return NULL; + Q_UNUSED(jsonString); + return NULL; } virtual void fromJsonObject(QJsonObject &json) { - Q_UNUSED(json); + Q_UNUSED(json); } virtual QString asJson() { - return QString(""); + return QString(""); } -}; + }; -#endif /* _SWG_OBJECT_H_ */ + #endif /* _SWG_OBJECT_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp index 3e34f2669c7..67cc01ad614 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp @@ -1,31 +1,35 @@ -#include "SWGOrder.h" + #include "SWGOrder.h" -#include "SWGHelpers.h" + #include "SWGHelpers.h" -#include -#include -#include -#include + #include + + #include + + #include + + #include + -namespace Swagger { + namespace Swagger { -SWGOrder::SWGOrder(QString* json) { - init(); - this->fromJson(*json); -} + SWGOrder::SWGOrder(QString* json) { + init(); + this->fromJson(*json); + } -SWGOrder::SWGOrder() { - init(); -} + SWGOrder::SWGOrder() { + init(); + } -SWGOrder::~SWGOrder() { - this->cleanup(); -} + SWGOrder::~SWGOrder() { + this->cleanup(); + } -void -SWGOrder::init() { + void + SWGOrder::init() { id = 0L; petId = 0L; quantity = 0; @@ -33,34 +37,34 @@ SWGOrder::init() { status = new QString(""); complete = false; -} + } -void -SWGOrder::cleanup() { + void + SWGOrder::cleanup() { if(shipDate != NULL) { - delete shipDate; - } + delete shipDate; + } if(status != NULL) { - delete status; - } + delete status; + } -} + } -SWGOrder* -SWGOrder::fromJson(QString &json) { - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); - return this; -} + SWGOrder* + SWGOrder::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; + } -void -SWGOrder::fromJsonObject(QJsonObject &pJson) { + void + SWGOrder::fromJsonObject(QJsonObject &pJson) { setValue(&id, pJson["id"], "qint64", ""); setValue(&petId, pJson["petId"], "qint64", ""); setValue(&quantity, pJson["quantity"], "qint32", ""); @@ -68,97 +72,104 @@ SWGOrder::fromJsonObject(QJsonObject &pJson) { setValue(&status, pJson["status"], "QString", "QString"); setValue(&complete, pJson["complete"], "bool", ""); -} + } -QString -SWGOrder::asJson () -{ - QJsonObject* obj = this->asJsonObject(); - - QJsonDocument doc(*obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} + QString + SWGOrder::asJson () + { + QJsonObject* obj = this->asJsonObject(); -QJsonObject* -SWGOrder::asJsonObject() { - QJsonObject* obj = new QJsonObject(); + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); + } + + QJsonObject* + SWGOrder::asJsonObject() { + QJsonObject* obj = new QJsonObject(); obj->insert("id", QJsonValue(id)); obj->insert("petId", QJsonValue(petId)); obj->insert("quantity", QJsonValue(quantity)); - - toJsonValue(QString("shipDate"), shipDate, obj, QString("QDateTime")); - - - - - - toJsonValue(QString("status"), status, obj, QString("QString")); + + toJsonValue(QString("shipDate"), shipDate, obj, QString("QDateTime")); + + + + toJsonValue(QString("status"), status, obj, QString("QString")); + + obj->insert("complete", QJsonValue(complete)); - return obj; -} + return obj; + } -qint64 -SWGOrder::getId() { - return id; -} -void -SWGOrder::setId(qint64 id) { - this->id = id; -} + + qint64 + SWGOrder::getId() { + return id; + } + void + SWGOrder::setId(qint64 id) { + this->id = id; + } -qint64 -SWGOrder::getPetId() { - return petId; -} -void -SWGOrder::setPetId(qint64 petId) { - this->petId = petId; -} + + qint64 + SWGOrder::getPetId() { + return petId; + } + void + SWGOrder::setPetId(qint64 petId) { + this->petId = petId; + } -qint32 -SWGOrder::getQuantity() { - return quantity; -} -void -SWGOrder::setQuantity(qint32 quantity) { - this->quantity = quantity; -} + + qint32 + SWGOrder::getQuantity() { + return quantity; + } + void + SWGOrder::setQuantity(qint32 quantity) { + this->quantity = quantity; + } -QDateTime* -SWGOrder::getShipDate() { - return shipDate; -} -void -SWGOrder::setShipDate(QDateTime* shipDate) { - this->shipDate = shipDate; -} + + QDateTime* + SWGOrder::getShipDate() { + return shipDate; + } + void + SWGOrder::setShipDate(QDateTime* shipDate) { + this->shipDate = shipDate; + } -QString* -SWGOrder::getStatus() { - return status; -} -void -SWGOrder::setStatus(QString* status) { - this->status = status; -} + + QString* + SWGOrder::getStatus() { + return status; + } + void + SWGOrder::setStatus(QString* status) { + this->status = status; + } -bool -SWGOrder::getComplete() { - return complete; -} -void -SWGOrder::setComplete(bool complete) { - this->complete = complete; -} + + bool + SWGOrder::getComplete() { + return complete; + } + void + SWGOrder::setComplete(bool complete) { + this->complete = complete; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.h b/samples/client/petstore/qt5cpp/client/SWGOrder.h index d17713afe78..1127afa9fce 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.h +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.h @@ -1,51 +1,52 @@ /* - * SWGOrder.h - * - * - */ +* SWGOrder.h +* +* +*/ #ifndef SWGOrder_H_ #define SWGOrder_H_ -#include +#include + #include "QDateTime.h" #include -#include "SWGObject.h" + #include "SWGObject.h" -namespace Swagger { + namespace Swagger { -class SWGOrder: public SWGObject { -public: + class SWGOrder: public SWGObject { + public: SWGOrder(); SWGOrder(QString* json); - virtual ~SWGOrder(); - void init(); - void cleanup(); + virtual ~SWGOrder(); + void init(); + void cleanup(); - QString asJson (); - QJsonObject* asJsonObject(); - void fromJsonObject(QJsonObject &json); + QString asJson (); + QJsonObject* asJsonObject(); + void fromJsonObject(QJsonObject &json); SWGOrder* fromJson(QString &jsonString); qint64 getId(); - void setId(qint64 id); + void setId(qint64 id); qint64 getPetId(); - void setPetId(qint64 petId); + void setPetId(qint64 petId); qint32 getQuantity(); - void setQuantity(qint32 quantity); + void setQuantity(qint32 quantity); QDateTime* getShipDate(); - void setShipDate(QDateTime* shipDate); + void setShipDate(QDateTime* shipDate); QString* getStatus(); - void setStatus(QString* status); + void setStatus(QString* status); bool getComplete(); - void setComplete(bool complete); + void setComplete(bool complete); -private: + private: qint64 id; qint64 petId; qint32 quantity; @@ -53,8 +54,8 @@ private: QString* status; bool complete; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SWGOrder_H_ */ + #endif /* SWGOrder_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.cpp b/samples/client/petstore/qt5cpp/client/SWGPet.cpp index d0e5b8280e2..9ee24fb7d4f 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPet.cpp @@ -1,31 +1,35 @@ -#include "SWGPet.h" + #include "SWGPet.h" -#include "SWGHelpers.h" + #include "SWGHelpers.h" -#include -#include -#include -#include + #include + + #include + + #include + + #include + -namespace Swagger { + namespace Swagger { -SWGPet::SWGPet(QString* json) { - init(); - this->fromJson(*json); -} + SWGPet::SWGPet(QString* json) { + init(); + this->fromJson(*json); + } -SWGPet::SWGPet() { - init(); -} + SWGPet::SWGPet() { + init(); + } -SWGPet::~SWGPet() { - this->cleanup(); -} + SWGPet::~SWGPet() { + this->cleanup(); + } -void -SWGPet::init() { + void + SWGPet::init() { id = 0L; category = new SWGCategory(); name = new QString(""); @@ -33,48 +37,48 @@ SWGPet::init() { tags = new QList(); status = new QString(""); -} + } -void -SWGPet::cleanup() { + void + SWGPet::cleanup() { if(category != NULL) { - delete category; - } + delete category; + } if(name != NULL) { - delete name; - } + delete name; + } if(photoUrls != NULL) { - QList* arr = photoUrls; + QList* arr = photoUrls; foreach(QString* o, *arr) { - delete o; + delete o; + } + delete photoUrls; } - delete photoUrls; - } if(tags != NULL) { - QList* arr = tags; + QList* arr = tags; foreach(SWGTag* o, *arr) { - delete o; + delete o; + } + delete tags; } - delete tags; - } if(status != NULL) { - delete status; - } + delete status; + } -} + } -SWGPet* -SWGPet::fromJson(QString &json) { - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); - return this; -} + SWGPet* + SWGPet::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; + } -void -SWGPet::fromJsonObject(QJsonObject &pJson) { + void + SWGPet::fromJsonObject(QJsonObject &pJson) { setValue(&id, pJson["id"], "qint64", ""); setValue(&category, pJson["category"], "SWGCategory", "SWGCategory"); setValue(&name, pJson["name"], "QString", "QString"); @@ -82,118 +86,127 @@ SWGPet::fromJsonObject(QJsonObject &pJson) { setValue(&tags, pJson["tags"], "QList", "SWGTag"); setValue(&status, pJson["status"], "QString", "QString"); -} + } -QString -SWGPet::asJson () -{ - QJsonObject* obj = this->asJsonObject(); - - QJsonDocument doc(*obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} + QString + SWGPet::asJson () + { + QJsonObject* obj = this->asJsonObject(); -QJsonObject* -SWGPet::asJsonObject() { - QJsonObject* obj = new QJsonObject(); + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); + } + + QJsonObject* + SWGPet::asJsonObject() { + QJsonObject* obj = new QJsonObject(); obj->insert("id", QJsonValue(id)); - - toJsonValue(QString("category"), category, obj, QString("SWGCategory")); + + toJsonValue(QString("category"), category, obj, QString("SWGCategory")); + + + + toJsonValue(QString("name"), name, obj, QString("QString")); + + - - toJsonValue(QString("name"), name, obj, QString("QString")); - - - - - - QList* photoUrlsList = photoUrls; - QJsonArray photoUrlsJsonArray; - toJsonArray((QList*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString"); + + QList* photoUrlsList = photoUrls; + QJsonArray photoUrlsJsonArray; + toJsonArray((QList + *)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString"); - obj->insert("photoUrls", photoUrlsJsonArray); + obj->insert("photoUrls", photoUrlsJsonArray); + - - - QList* tagsList = tags; - QJsonArray tagsJsonArray; - toJsonArray((QList*)tags, &tagsJsonArray, "tags", "SWGTag"); + + QList* tagsList = tags; + QJsonArray tagsJsonArray; + toJsonArray((QList + *)tags, &tagsJsonArray, "tags", "SWGTag"); - obj->insert("tags", tagsJsonArray); - - - - - toJsonValue(QString("status"), status, obj, QString("QString")); + obj->insert("tags", tagsJsonArray); + + + toJsonValue(QString("status"), status, obj, QString("QString")); + + - return obj; -} + return obj; + } -qint64 -SWGPet::getId() { - return id; -} -void -SWGPet::setId(qint64 id) { - this->id = id; -} + + qint64 + SWGPet::getId() { + return id; + } + void + SWGPet::setId(qint64 id) { + this->id = id; + } -SWGCategory* -SWGPet::getCategory() { - return category; -} -void -SWGPet::setCategory(SWGCategory* category) { - this->category = category; -} + + SWGCategory* + SWGPet::getCategory() { + return category; + } + void + SWGPet::setCategory(SWGCategory* category) { + this->category = category; + } -QString* -SWGPet::getName() { - return name; -} -void -SWGPet::setName(QString* name) { - this->name = name; -} + + QString* + SWGPet::getName() { + return name; + } + void + SWGPet::setName(QString* name) { + this->name = name; + } -QList* -SWGPet::getPhotoUrls() { - return photoUrls; -} -void -SWGPet::setPhotoUrls(QList* photoUrls) { - this->photoUrls = photoUrls; -} + + QList* + SWGPet::getPhotoUrls() { + return photoUrls; + } + void + SWGPet::setPhotoUrls(QList* photoUrls) { + this->photoUrls = photoUrls; + } -QList* -SWGPet::getTags() { - return tags; -} -void -SWGPet::setTags(QList* tags) { - this->tags = tags; -} + + QList* + SWGPet::getTags() { + return tags; + } + void + SWGPet::setTags(QList* tags) { + this->tags = tags; + } -QString* -SWGPet::getStatus() { - return status; -} -void -SWGPet::setStatus(QString* status) { - this->status = status; -} + + QString* + SWGPet::getStatus() { + return status; + } + void + SWGPet::setStatus(QString* status) { + this->status = status; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index e9cb4d08233..e0bd3f0f8df 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -1,13 +1,14 @@ /* - * SWGPet.h - * - * - */ +* SWGPet.h +* +* +*/ #ifndef SWGPet_H_ #define SWGPet_H_ -#include +#include + #include "SWGTag.h" @@ -15,39 +16,39 @@ #include "SWGCategory.h" #include -#include "SWGObject.h" + #include "SWGObject.h" -namespace Swagger { + namespace Swagger { -class SWGPet: public SWGObject { -public: + class SWGPet: public SWGObject { + public: SWGPet(); SWGPet(QString* json); - virtual ~SWGPet(); - void init(); - void cleanup(); + virtual ~SWGPet(); + void init(); + void cleanup(); - QString asJson (); - QJsonObject* asJsonObject(); - void fromJsonObject(QJsonObject &json); + QString asJson (); + QJsonObject* asJsonObject(); + void fromJsonObject(QJsonObject &json); SWGPet* fromJson(QString &jsonString); qint64 getId(); - void setId(qint64 id); + void setId(qint64 id); SWGCategory* getCategory(); - void setCategory(SWGCategory* category); + void setCategory(SWGCategory* category); QString* getName(); - void setName(QString* name); + void setName(QString* name); QList* getPhotoUrls(); - void setPhotoUrls(QList* photoUrls); + void setPhotoUrls(QList* photoUrls); QList* getTags(); - void setTags(QList* tags); + void setTags(QList* tags); QString* getStatus(); - void setStatus(QString* status); + void setStatus(QString* status); -private: + private: qint64 id; SWGCategory* category; QString* name; @@ -55,8 +56,8 @@ private: QList* tags; QString* status; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SWGPet_H_ */ + #endif /* SWGPet_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index 0be3a197cd1..08a71c5df0c 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -2,530 +2,549 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" -#include -#include +#include + + #include + -namespace Swagger { -SWGPetApi::SWGPetApi() {} + namespace Swagger { + SWGPetApi::SWGPetApi() {} -SWGPetApi::~SWGPetApi() {} + SWGPetApi::~SWGPetApi() {} -SWGPetApi::SWGPetApi(QString host, QString basePath) { - this->host = host; - this->basePath = basePath; -} - -void -SWGPetApi::updatePet(SWGPet body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet"); - - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "PUT"); - - - - - - - QString output = body.asJson(); - input.request_body.append(output); - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::updatePetCallback); - - worker->execute(&input); -} - -void -SWGPetApi::updatePetCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit updatePetSignal(); -} -void -SWGPetApi::addPet(SWGPet body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet"); - - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - - - - - - - QString output = body.asJson(); - input.request_body.append(output); - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::addPetCallback); - - worker->execute(&input); -} - -void -SWGPetApi::addPetCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit addPetSignal(); -} -void -SWGPetApi::findPetsByStatus(QList* status) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); - - - - - - - - - if(status->size() > 0) { - if(QString("multi").indexOf("multi") == 0) { - foreach(QString* t, *status) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("status=").append(stringValue(t)); + SWGPetApi::SWGPetApi(QString host, QString basePath) { + this->host = host; + this->basePath = basePath; } - } - else if (QString("multi").indexOf("ssv") == 0) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("status="); - qint32 count = 0; - foreach(QString* t, *status) { - if(count > 0) { - fullPath.append(" "); - } - fullPath.append(stringValue(t)); - } - } - else if (QString("multi").indexOf("tsv") == 0) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("status="); - qint32 count = 0; - foreach(QString* t, *status) { - if(count > 0) { - fullPath.append("\t"); - } - fullPath.append(stringValue(t)); - } - } - } - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::findPetsByStatusCallback); - - worker->execute(&input); -} - -void -SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - QList* output = new QList(); - QString json(worker->response); - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonArray jsonArray = doc.array(); - - foreach(QJsonValue obj, jsonArray) { - SWGPet* o = new SWGPet(); - QJsonObject jv = obj.toObject(); - QJsonObject * ptr = (QJsonObject*)&jv; - o->fromJsonObject(*ptr); - output->append(o); - } - - - - - worker->deleteLater(); - - emit findPetsByStatusSignal(output); - -} -void -SWGPetApi::findPetsByTags(QList* tags) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); - - - - - - - - - if(tags->size() > 0) { - if(QString("multi").indexOf("multi") == 0) { - foreach(QString* t, *tags) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("tags=").append(stringValue(t)); - } - } - else if (QString("multi").indexOf("ssv") == 0) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("tags="); - qint32 count = 0; - foreach(QString* t, *tags) { - if(count > 0) { - fullPath.append(" "); - } - fullPath.append(stringValue(t)); - } - } - else if (QString("multi").indexOf("tsv") == 0) { - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append("tags="); - qint32 count = 0; - foreach(QString* t, *tags) { - if(count > 0) { - fullPath.append("\t"); - } - fullPath.append(stringValue(t)); - } - } - } - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::findPetsByTagsCallback); - - worker->execute(&input); -} - -void -SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - QList* output = new QList(); - QString json(worker->response); - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonArray jsonArray = doc.array(); - - foreach(QJsonValue obj, jsonArray) { - SWGPet* o = new SWGPet(); - QJsonObject jv = obj.toObject(); - QJsonObject * ptr = (QJsonObject*)&jv; - o->fromJsonObject(*ptr); - output->append(o); - } - - - - - worker->deleteLater(); - - emit findPetsByTagsSignal(output); - -} -void -SWGPetApi::getPetById(qint64 petId) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); - - - QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); - fullPath.replace(petIdPathParam, stringValue(petId)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::getPetByIdCallback); - - worker->execute(&input); -} - -void -SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - - - - QString json(worker->response); - SWGPet* output = static_cast(create(json, QString("SWGPet"))); - - - - - worker->deleteLater(); - - emit getPetByIdSignal(output); - -} -void -SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); - - - QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); - fullPath.replace(petIdPathParam, stringValue(petId)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - - - if(name != NULL) { - input.add_var("name", *name); - } - - if(status != NULL) { - input.add_var("status", *status); - } - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::updatePetWithFormCallback); - - worker->execute(&input); -} - -void -SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit updatePetWithFormSignal(); -} -void -SWGPetApi::deletePet(QString* apiKey, qint64 petId) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); - - - QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); - fullPath.replace(petIdPathParam, stringValue(petId)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); - - - - - - - // TODO: add header support - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::deletePetCallback); - - worker->execute(&input); -} - -void -SWGPetApi::deletePetCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit deletePetSignal(); -} -void -SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); - - - QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); - fullPath.replace(petIdPathParam, stringValue(petId)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - - - if(additionalMetadata != NULL) { - input.add_var("additionalMetadata", *additionalMetadata); - } - - + + + void + SWGPetApi::updatePet(SWGPet body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet"); - + - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGPetApi::uploadFileCallback); - - worker->execute(&input); -} - -void -SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + - + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "PUT"); - worker->deleteLater(); + - - emit uploadFileSignal(); -} -} /* namespace Swagger */ + + + + QString output = body.asJson(); + input.request_body.append(output); + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::updatePetCallback); + + worker->execute(&input); + } + + void + SWGPetApi::updatePetCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit updatePetSignal(); + } + + void + SWGPetApi::addPet(SWGPet body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet"); + + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::addPetCallback); + + worker->execute(&input); + } + + void + SWGPetApi::addPetCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit addPetSignal(); + } + + void + SWGPetApi::findPetsByStatus(QList* status) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); + + + + + + + + + if(status->size() > 0) { + if(QString("multi").indexOf("multi") == 0) { + foreach(QString* t, *status) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("status=").append(stringValue(t)); + } + } + else if (QString("multi").indexOf("ssv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("status="); + qint32 count = 0; + foreach(QString* t, *status) { + if(count > 0) { + fullPath.append(" "); + } + fullPath.append(stringValue(t)); + } + } + else if (QString("multi").indexOf("tsv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("status="); + qint32 count = 0; + foreach(QString* t, *status) { + if(count > 0) { + fullPath.append("\t"); + } + fullPath.append(stringValue(t)); + } + } + } + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::findPetsByStatusCallback); + + worker->execute(&input); + } + + void + SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + QList* output = new QList(); + QString json(worker->response); + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonArray jsonArray = doc.array(); + + foreach(QJsonValue obj, jsonArray) { + SWGPet* o = new SWGPet(); + QJsonObject jv = obj.toObject(); + QJsonObject * ptr = (QJsonObject*)&jv; + o->fromJsonObject(*ptr); + output->append(o); + } + + + + + worker->deleteLater(); + + emit findPetsByStatusSignal(output); + + } + + void + SWGPetApi::findPetsByTags(QList* tags) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); + + + + + + + + + if(tags->size() > 0) { + if(QString("multi").indexOf("multi") == 0) { + foreach(QString* t, *tags) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("tags=").append(stringValue(t)); + } + } + else if (QString("multi").indexOf("ssv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("tags="); + qint32 count = 0; + foreach(QString* t, *tags) { + if(count > 0) { + fullPath.append(" "); + } + fullPath.append(stringValue(t)); + } + } + else if (QString("multi").indexOf("tsv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("tags="); + qint32 count = 0; + foreach(QString* t, *tags) { + if(count > 0) { + fullPath.append("\t"); + } + fullPath.append(stringValue(t)); + } + } + } + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::findPetsByTagsCallback); + + worker->execute(&input); + } + + void + SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + QList* output = new QList(); + QString json(worker->response); + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonArray jsonArray = doc.array(); + + foreach(QJsonValue obj, jsonArray) { + SWGPet* o = new SWGPet(); + QJsonObject jv = obj.toObject(); + QJsonObject * ptr = (QJsonObject*)&jv; + o->fromJsonObject(*ptr); + output->append(o); + } + + + + + worker->deleteLater(); + + emit findPetsByTagsSignal(output); + + } + + void + SWGPetApi::getPetById(qint64 petId) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + + + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); + fullPath.replace(petIdPathParam, stringValue(petId)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::getPetByIdCallback); + + worker->execute(&input); + } + + void + SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + + + + QString json(worker->response); + SWGPet* output = static_cast(create(json, + QString("SWGPet"))); + + + + + worker->deleteLater(); + + emit getPetByIdSignal(output); + + } + + void + SWGPetApi::updatePetWithForm(QString* petId + , QString* name + , QString* status) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + + + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); + fullPath.replace(petIdPathParam, stringValue(petId)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + + + if(name != NULL) { + input.add_var("name", *name); + } + + if(status != NULL) { + input.add_var("status", *status); + } + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::updatePetWithFormCallback); + + worker->execute(&input); + } + + void + SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit updatePetWithFormSignal(); + } + + void + SWGPetApi::deletePet(QString* apiKey + , qint64 petId) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + + + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); + fullPath.replace(petIdPathParam, stringValue(petId)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); + + + + + + + // TODO: add header support + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::deletePetCallback); + + worker->execute(&input); + } + + void + SWGPetApi::deletePetCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit deletePetSignal(); + } + + void + SWGPetApi::uploadFile(qint64 petId + , QString* additionalMetadata + , SWGHttpRequestInputFileElement* file) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); + + + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); + fullPath.replace(petIdPathParam, stringValue(petId)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + + + if(additionalMetadata != NULL) { + input.add_var("additionalMetadata", *additionalMetadata); + } + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGPetApi::uploadFileCallback); + + worker->execute(&input); + } + + void + SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit uploadFileSignal(); + } + + + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index 488865729b9..af70a469614 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -7,14 +7,15 @@ #include #include "SWGHttpRequest.h" -#include +#include + -namespace Swagger { + namespace Swagger { -class SWGPetApi: public QObject { + class SWGPetApi: public QObject { Q_OBJECT -public: + public: SWGPetApi(); SWGPetApi(QString host, QString basePath); ~SWGPetApi(); @@ -27,11 +28,16 @@ public: void findPetsByStatus(QList* status); void findPetsByTags(QList* tags); void getPetById(qint64 petId); - void updatePetWithForm(QString* petId, QString* name, QString* status); - void deletePet(QString* apiKey, qint64 petId); - void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file); + void updatePetWithForm(QString* petId + , QString* name + , QString* status); + void deletePet(QString* apiKey + , qint64 petId); + void uploadFile(qint64 petId + , QString* additionalMetadata + , SWGHttpRequestInputFileElement* file); -private: + private: void updatePetCallback (HttpRequestWorker * worker); void addPetCallback (HttpRequestWorker * worker); void findPetsByStatusCallback (HttpRequestWorker * worker); @@ -41,7 +47,7 @@ private: void deletePetCallback (HttpRequestWorker * worker); void uploadFileCallback (HttpRequestWorker * worker); -signals: + signals: void updatePetSignal(); void addPetSignal(); void findPetsByStatusSignal(QList* summary); @@ -51,6 +57,6 @@ signals: void deletePetSignal(); void uploadFileSignal(); -}; -} -#endif \ No newline at end of file + }; + } + #endif \ No newline at end of file diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index be603573f62..888935e31b1 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -2,238 +2,249 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" -#include -#include +#include + + #include + -namespace Swagger { -SWGStoreApi::SWGStoreApi() {} + namespace Swagger { + SWGStoreApi::SWGStoreApi() {} -SWGStoreApi::~SWGStoreApi() {} + SWGStoreApi::~SWGStoreApi() {} -SWGStoreApi::SWGStoreApi(QString host, QString basePath) { - this->host = host; - this->basePath = basePath; -} + SWGStoreApi::SWGStoreApi(QString host, QString basePath) { + this->host = host; + this->basePath = basePath; + } -void -SWGStoreApi::getInventory() { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/store/inventory"); + + + void + SWGStoreApi::getInventory() { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/store/inventory"); - + - + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); - + - + - + - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGStoreApi::getInventoryCallback); + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGStoreApi::getInventoryCallback); - worker->execute(&input); -} + worker->execute(&input); + } -void -SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + void + SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } - + - - - QMap* output = new QMap(); + + + QMap* output = new QMap(); - QString json(worker->response); - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject obj = doc.object(); + QString json(worker->response); + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject obj = doc.object(); - foreach(QString key, obj.keys()) { - qint32* val; - setValue(&val, obj[key], "QMap", ""); - output->insert(key, *val); - } + foreach(QString key, obj.keys()) { + qint32* val; + setValue(&val, obj[key], "QMap", ""); + output->insert(key, *val); + } - - - + + + - worker->deleteLater(); + worker->deleteLater(); - emit getInventorySignal(output); - -} -void -SWGStoreApi::placeOrder(SWGOrder body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/store/order"); + emit getInventorySignal(output); + + } + + void + SWGStoreApi::placeOrder(SWGOrder body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/store/order"); - + - + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); - + - - - - QString output = body.asJson(); - input.request_body.append(output); - + + + + QString output = body.asJson(); + input.request_body.append(output); + - + - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGStoreApi::placeOrderCallback); + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGStoreApi::placeOrderCallback); - worker->execute(&input); -} + worker->execute(&input); + } -void -SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + void + SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } - + - - - - QString json(worker->response); - SWGOrder* output = static_cast(create(json, QString("SWGOrder"))); - - - + + + + QString json(worker->response); + SWGOrder* output = static_cast(create(json, + QString("SWGOrder"))); + + + - worker->deleteLater(); + worker->deleteLater(); - emit placeOrderSignal(output); - -} -void -SWGStoreApi::getOrderById(QString* orderId) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); + emit placeOrderSignal(output); + + } + + void + SWGStoreApi::getOrderById(QString* orderId) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); - - QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); - fullPath.replace(orderIdPathParam, stringValue(orderId)); - + + QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); + fullPath.replace(orderIdPathParam, stringValue(orderId)); + - + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); - + - + - + - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGStoreApi::getOrderByIdCallback); + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGStoreApi::getOrderByIdCallback); - worker->execute(&input); -} + worker->execute(&input); + } -void -SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + void + SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } - + - - - - QString json(worker->response); - SWGOrder* output = static_cast(create(json, QString("SWGOrder"))); - - - + + + + QString json(worker->response); + SWGOrder* output = static_cast(create(json, + QString("SWGOrder"))); + + + - worker->deleteLater(); + worker->deleteLater(); - emit getOrderByIdSignal(output); - -} -void -SWGStoreApi::deleteOrder(QString* orderId) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); + emit getOrderByIdSignal(output); + + } + + void + SWGStoreApi::deleteOrder(QString* orderId) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); - - QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); - fullPath.replace(orderIdPathParam, stringValue(orderId)); - + + QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); + fullPath.replace(orderIdPathParam, stringValue(orderId)); + - + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); - + - + - + - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGStoreApi::deleteOrderCallback); + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGStoreApi::deleteOrderCallback); - worker->execute(&input); -} + worker->execute(&input); + } -void -SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + void + SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } - + - worker->deleteLater(); + worker->deleteLater(); - - emit deleteOrderSignal(); -} -} /* namespace Swagger */ + + emit deleteOrderSignal(); + } + + + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h index 7bbe8e5f92a..cb801248863 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h @@ -7,14 +7,15 @@ #include "SWGOrder.h" #include -#include +#include + -namespace Swagger { + namespace Swagger { -class SWGStoreApi: public QObject { + class SWGStoreApi: public QObject { Q_OBJECT -public: + public: SWGStoreApi(); SWGStoreApi(QString host, QString basePath); ~SWGStoreApi(); @@ -27,18 +28,18 @@ public: void getOrderById(QString* orderId); void deleteOrder(QString* orderId); -private: + private: void getInventoryCallback (HttpRequestWorker * worker); void placeOrderCallback (HttpRequestWorker * worker); void getOrderByIdCallback (HttpRequestWorker * worker); void deleteOrderCallback (HttpRequestWorker * worker); -signals: + signals: void getInventorySignal(QMap* summary); void placeOrderSignal(SWGOrder* summary); void getOrderByIdSignal(SWGOrder* summary); void deleteOrderSignal(); -}; -} -#endif \ No newline at end of file + }; + } + #endif \ No newline at end of file diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.cpp b/samples/client/petstore/qt5cpp/client/SWGTag.cpp index bb4404de8df..da3406abc68 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGTag.cpp @@ -1,105 +1,112 @@ -#include "SWGTag.h" + #include "SWGTag.h" -#include "SWGHelpers.h" + #include "SWGHelpers.h" -#include -#include -#include -#include + #include + + #include + + #include + + #include + -namespace Swagger { + namespace Swagger { -SWGTag::SWGTag(QString* json) { - init(); - this->fromJson(*json); -} + SWGTag::SWGTag(QString* json) { + init(); + this->fromJson(*json); + } -SWGTag::SWGTag() { - init(); -} + SWGTag::SWGTag() { + init(); + } -SWGTag::~SWGTag() { - this->cleanup(); -} + SWGTag::~SWGTag() { + this->cleanup(); + } -void -SWGTag::init() { + void + SWGTag::init() { id = 0L; name = new QString(""); -} + } -void -SWGTag::cleanup() { + void + SWGTag::cleanup() { if(name != NULL) { - delete name; - } + delete name; + } -} + } -SWGTag* -SWGTag::fromJson(QString &json) { - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); - return this; -} + SWGTag* + SWGTag::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; + } -void -SWGTag::fromJsonObject(QJsonObject &pJson) { + void + SWGTag::fromJsonObject(QJsonObject &pJson) { setValue(&id, pJson["id"], "qint64", ""); setValue(&name, pJson["name"], "QString", "QString"); -} + } -QString -SWGTag::asJson () -{ - QJsonObject* obj = this->asJsonObject(); - - QJsonDocument doc(*obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} + QString + SWGTag::asJson () + { + QJsonObject* obj = this->asJsonObject(); -QJsonObject* -SWGTag::asJsonObject() { - QJsonObject* obj = new QJsonObject(); + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); + } + + QJsonObject* + SWGTag::asJsonObject() { + QJsonObject* obj = new QJsonObject(); obj->insert("id", QJsonValue(id)); - - toJsonValue(QString("name"), name, obj, QString("QString")); - - + + toJsonValue(QString("name"), name, obj, QString("QString")); + + - return obj; -} + return obj; + } -qint64 -SWGTag::getId() { - return id; -} -void -SWGTag::setId(qint64 id) { - this->id = id; -} + + qint64 + SWGTag::getId() { + return id; + } + void + SWGTag::setId(qint64 id) { + this->id = id; + } -QString* -SWGTag::getName() { - return name; -} -void -SWGTag::setName(QString* name) { - this->name = name; -} + + QString* + SWGTag::getName() { + return name; + } + void + SWGTag::setName(QString* name) { + this->name = name; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.h b/samples/client/petstore/qt5cpp/client/SWGTag.h index 067b200675b..f1d650fe1ea 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.h +++ b/samples/client/petstore/qt5cpp/client/SWGTag.h @@ -1,47 +1,48 @@ /* - * SWGTag.h - * - * - */ +* SWGTag.h +* +* +*/ #ifndef SWGTag_H_ #define SWGTag_H_ -#include +#include + #include -#include "SWGObject.h" + #include "SWGObject.h" -namespace Swagger { + namespace Swagger { -class SWGTag: public SWGObject { -public: + class SWGTag: public SWGObject { + public: SWGTag(); SWGTag(QString* json); - virtual ~SWGTag(); - void init(); - void cleanup(); + virtual ~SWGTag(); + void init(); + void cleanup(); - QString asJson (); - QJsonObject* asJsonObject(); - void fromJsonObject(QJsonObject &json); + QString asJson (); + QJsonObject* asJsonObject(); + void fromJsonObject(QJsonObject &json); SWGTag* fromJson(QString &jsonString); qint64 getId(); - void setId(qint64 id); + void setId(qint64 id); QString* getName(); - void setName(QString* name); + void setName(QString* name); -private: + private: qint64 id; QString* name; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SWGTag_H_ */ + #endif /* SWGTag_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.cpp b/samples/client/petstore/qt5cpp/client/SWGUser.cpp index f0d58c7e97b..58aa806e9a4 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUser.cpp @@ -1,31 +1,35 @@ -#include "SWGUser.h" + #include "SWGUser.h" -#include "SWGHelpers.h" + #include "SWGHelpers.h" -#include -#include -#include -#include + #include + + #include + + #include + + #include + -namespace Swagger { + namespace Swagger { -SWGUser::SWGUser(QString* json) { - init(); - this->fromJson(*json); -} + SWGUser::SWGUser(QString* json) { + init(); + this->fromJson(*json); + } -SWGUser::SWGUser() { - init(); -} + SWGUser::SWGUser() { + init(); + } -SWGUser::~SWGUser() { - this->cleanup(); -} + SWGUser::~SWGUser() { + this->cleanup(); + } -void -SWGUser::init() { + void + SWGUser::init() { id = 0L; username = new QString(""); firstName = new QString(""); @@ -35,44 +39,44 @@ SWGUser::init() { phone = new QString(""); userStatus = 0; -} + } -void -SWGUser::cleanup() { + void + SWGUser::cleanup() { if(username != NULL) { - delete username; - } + delete username; + } if(firstName != NULL) { - delete firstName; - } + delete firstName; + } if(lastName != NULL) { - delete lastName; - } + delete lastName; + } if(email != NULL) { - delete email; - } + delete email; + } if(password != NULL) { - delete password; - } + delete password; + } if(phone != NULL) { - delete phone; - } + delete phone; + } -} + } -SWGUser* -SWGUser::fromJson(QString &json) { - QByteArray array (json.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); - return this; -} + SWGUser* + SWGUser::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; + } -void -SWGUser::fromJsonObject(QJsonObject &pJson) { + void + SWGUser::fromJsonObject(QJsonObject &pJson) { setValue(&id, pJson["id"], "qint64", ""); setValue(&username, pJson["username"], "QString", "QString"); setValue(&firstName, pJson["firstName"], "QString", "QString"); @@ -82,137 +86,146 @@ SWGUser::fromJsonObject(QJsonObject &pJson) { setValue(&phone, pJson["phone"], "QString", "QString"); setValue(&userStatus, pJson["userStatus"], "qint32", ""); -} + } -QString -SWGUser::asJson () -{ - QJsonObject* obj = this->asJsonObject(); - - QJsonDocument doc(*obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} + QString + SWGUser::asJson () + { + QJsonObject* obj = this->asJsonObject(); -QJsonObject* -SWGUser::asJsonObject() { - QJsonObject* obj = new QJsonObject(); + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); + } + + QJsonObject* + SWGUser::asJsonObject() { + QJsonObject* obj = new QJsonObject(); obj->insert("id", QJsonValue(id)); - - toJsonValue(QString("username"), username, obj, QString("QString")); + + toJsonValue(QString("username"), username, obj, QString("QString")); + + + + toJsonValue(QString("firstName"), firstName, obj, QString("QString")); + + - - toJsonValue(QString("firstName"), firstName, obj, QString("QString")); + + toJsonValue(QString("lastName"), lastName, obj, QString("QString")); + + + + toJsonValue(QString("email"), email, obj, QString("QString")); + + - - toJsonValue(QString("lastName"), lastName, obj, QString("QString")); - - - - - - toJsonValue(QString("email"), email, obj, QString("QString")); - - - - - - toJsonValue(QString("password"), password, obj, QString("QString")); - - - - - - toJsonValue(QString("phone"), phone, obj, QString("QString")); + + toJsonValue(QString("password"), password, obj, QString("QString")); + + + + toJsonValue(QString("phone"), phone, obj, QString("QString")); + + obj->insert("userStatus", QJsonValue(userStatus)); - return obj; -} + return obj; + } -qint64 -SWGUser::getId() { - return id; -} -void -SWGUser::setId(qint64 id) { - this->id = id; -} + + qint64 + SWGUser::getId() { + return id; + } + void + SWGUser::setId(qint64 id) { + this->id = id; + } -QString* -SWGUser::getUsername() { - return username; -} -void -SWGUser::setUsername(QString* username) { - this->username = username; -} + + QString* + SWGUser::getUsername() { + return username; + } + void + SWGUser::setUsername(QString* username) { + this->username = username; + } -QString* -SWGUser::getFirstName() { - return firstName; -} -void -SWGUser::setFirstName(QString* firstName) { - this->firstName = firstName; -} + + QString* + SWGUser::getFirstName() { + return firstName; + } + void + SWGUser::setFirstName(QString* firstName) { + this->firstName = firstName; + } -QString* -SWGUser::getLastName() { - return lastName; -} -void -SWGUser::setLastName(QString* lastName) { - this->lastName = lastName; -} + + QString* + SWGUser::getLastName() { + return lastName; + } + void + SWGUser::setLastName(QString* lastName) { + this->lastName = lastName; + } -QString* -SWGUser::getEmail() { - return email; -} -void -SWGUser::setEmail(QString* email) { - this->email = email; -} + + QString* + SWGUser::getEmail() { + return email; + } + void + SWGUser::setEmail(QString* email) { + this->email = email; + } -QString* -SWGUser::getPassword() { - return password; -} -void -SWGUser::setPassword(QString* password) { - this->password = password; -} + + QString* + SWGUser::getPassword() { + return password; + } + void + SWGUser::setPassword(QString* password) { + this->password = password; + } -QString* -SWGUser::getPhone() { - return phone; -} -void -SWGUser::setPhone(QString* phone) { - this->phone = phone; -} + + QString* + SWGUser::getPhone() { + return phone; + } + void + SWGUser::setPhone(QString* phone) { + this->phone = phone; + } -qint32 -SWGUser::getUserStatus() { - return userStatus; -} -void -SWGUser::setUserStatus(qint32 userStatus) { - this->userStatus = userStatus; -} + + qint32 + SWGUser::getUserStatus() { + return userStatus; + } + void + SWGUser::setUserStatus(qint32 userStatus) { + this->userStatus = userStatus; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.h b/samples/client/petstore/qt5cpp/client/SWGUser.h index eaa0e496c39..6484a2e67b2 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.h +++ b/samples/client/petstore/qt5cpp/client/SWGUser.h @@ -1,54 +1,55 @@ /* - * SWGUser.h - * - * - */ +* SWGUser.h +* +* +*/ #ifndef SWGUser_H_ #define SWGUser_H_ -#include +#include + #include -#include "SWGObject.h" + #include "SWGObject.h" -namespace Swagger { + namespace Swagger { -class SWGUser: public SWGObject { -public: + class SWGUser: public SWGObject { + public: SWGUser(); SWGUser(QString* json); - virtual ~SWGUser(); - void init(); - void cleanup(); + virtual ~SWGUser(); + void init(); + void cleanup(); - QString asJson (); - QJsonObject* asJsonObject(); - void fromJsonObject(QJsonObject &json); + QString asJson (); + QJsonObject* asJsonObject(); + void fromJsonObject(QJsonObject &json); SWGUser* fromJson(QString &jsonString); qint64 getId(); - void setId(qint64 id); + void setId(qint64 id); QString* getUsername(); - void setUsername(QString* username); + void setUsername(QString* username); QString* getFirstName(); - void setFirstName(QString* firstName); + void setFirstName(QString* firstName); QString* getLastName(); - void setLastName(QString* lastName); + void setLastName(QString* lastName); QString* getEmail(); - void setEmail(QString* email); + void setEmail(QString* email); QString* getPassword(); - void setPassword(QString* password); + void setPassword(QString* password); QString* getPhone(); - void setPhone(QString* phone); + void setPhone(QString* phone); qint32 getUserStatus(); - void setUserStatus(qint32 userStatus); + void setUserStatus(qint32 userStatus); -private: + private: qint64 id; QString* username; QString* firstName; @@ -58,8 +59,8 @@ private: QString* phone; qint32 userStatus; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SWGUser_H_ */ + #endif /* SWGUser_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp index 6341231a884..4f90b151e29 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp @@ -2,442 +2,463 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" -#include -#include +#include + + #include + -namespace Swagger { -SWGUserApi::SWGUserApi() {} + namespace Swagger { + SWGUserApi::SWGUserApi() {} -SWGUserApi::~SWGUserApi() {} + SWGUserApi::~SWGUserApi() {} -SWGUserApi::SWGUserApi(QString host, QString basePath) { - this->host = host; - this->basePath = basePath; -} + SWGUserApi::SWGUserApi(QString host, QString basePath) { + this->host = host; + this->basePath = basePath; + } -void -SWGUserApi::createUser(SWGUser body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user"); + + + void + SWGUserApi::createUser(SWGUser body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user"); - + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); - + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); + + + + QString output = body.asJson(); + input.request_body.append(output); + - + - - - - QString output = body.asJson(); - input.request_body.append(output); - + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::createUserCallback); - + worker->execute(&input); + } - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::createUserCallback); + void + SWGUserApi::createUserCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } - worker->execute(&input); -} + -void -SWGUserApi::createUserCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } + worker->deleteLater(); - + + emit createUserSignal(); + } + + void + SWGUserApi::createUsersWithArrayInput(QList* body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); - worker->deleteLater(); + - - emit createUserSignal(); -} -void -SWGUserApi::createUsersWithArrayInput(QList* body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); + - + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); - + + + + + QJsonArray* bodyArray = new QJsonArray(); + toJsonArray((QList + *)body, bodyArray, QString("body"), QString("SWGUser*")); - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - - - - - - QJsonArray* bodyArray = new QJsonArray(); - toJsonArray((QList*)body, bodyArray, QString("body"), QString("SWGUser*")); - - QJsonDocument doc(*bodyArray); - QByteArray bytes = doc.toJson(); - - input.request_body.append(bytes); - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::createUsersWithArrayInputCallback); - - worker->execute(&input); -} - -void -SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit createUsersWithArrayInputSignal(); -} -void -SWGUserApi::createUsersWithListInput(QList* body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); - - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - - - - - - QJsonArray* bodyArray = new QJsonArray(); - toJsonArray((QList*)body, bodyArray, QString("body"), QString("SWGUser*")); - - QJsonDocument doc(*bodyArray); - QByteArray bytes = doc.toJson(); - - input.request_body.append(bytes); - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::createUsersWithListInputCallback); - - worker->execute(&input); -} - -void -SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit createUsersWithListInputSignal(); -} -void -SWGUserApi::loginUser(QString* username, QString* password) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/login"); - - - - - - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("username")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(username))); - - - - - - if(fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("password")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(password))); - - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::loginUserCallback); - - worker->execute(&input); -} - -void -SWGUserApi::loginUserCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - - - - QString json(worker->response); - QString* output = static_cast(create(json, QString("QString"))); - - - - - worker->deleteLater(); - - emit loginUserSignal(output); - -} -void -SWGUserApi::logoutUser() { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/logout"); - - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::logoutUserCallback); - - worker->execute(&input); -} - -void -SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit logoutUserSignal(); -} -void -SWGUserApi::getUserByName(QString* username) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/{username}"); - - - QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); - fullPath.replace(usernamePathParam, stringValue(username)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::getUserByNameCallback); - - worker->execute(&input); -} - -void -SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - - - - QString json(worker->response); - SWGUser* output = static_cast(create(json, QString("SWGUser"))); - - - - - worker->deleteLater(); - - emit getUserByNameSignal(output); - -} -void -SWGUserApi::updateUser(QString* username, SWGUser body) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/{username}"); - - - QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); - fullPath.replace(usernamePathParam, stringValue(username)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "PUT"); - - - - - - - QString output = body.asJson(); - input.request_body.append(output); - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::updateUserCallback); - - worker->execute(&input); -} - -void -SWGUserApi::updateUserCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit updateUserSignal(); -} -void -SWGUserApi::deleteUser(QString* username) { - QString fullPath; - fullPath.append(this->host).append(this->basePath).append("/user/{username}"); - - - QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); - fullPath.replace(usernamePathParam, stringValue(username)); - - - - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); - - - - - - - - connect(worker, - &HttpRequestWorker::on_execution_finished, - this, - &SWGUserApi::deleteUserCallback); - - worker->execute(&input); -} - -void -SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) { - QString msg; - if (worker->error_type == QNetworkReply::NoError) { - msg = QString("Success! %1 bytes").arg(worker->response.length()); - } - else { - msg = "Error: " + worker->error_str; - } - - - - worker->deleteLater(); - - - emit deleteUserSignal(); -} -} /* namespace Swagger */ + QJsonDocument doc(*bodyArray); + QByteArray bytes = doc.toJson(); + + input.request_body.append(bytes); + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::createUsersWithArrayInputCallback); + + worker->execute(&input); + } + + void + SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit createUsersWithArrayInputSignal(); + } + + void + SWGUserApi::createUsersWithListInput(QList* body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); + + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + + + + + + QJsonArray* bodyArray = new QJsonArray(); + toJsonArray((QList + *)body, bodyArray, QString("body"), QString("SWGUser*")); + + QJsonDocument doc(*bodyArray); + QByteArray bytes = doc.toJson(); + + input.request_body.append(bytes); + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::createUsersWithListInputCallback); + + worker->execute(&input); + } + + void + SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit createUsersWithListInputSignal(); + } + + void + SWGUserApi::loginUser(QString* username + , QString* password) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/login"); + + + + + + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append(QUrl::toPercentEncoding("username")) + .append("=") + .append(QUrl::toPercentEncoding(stringValue(username))); + + + + + + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append(QUrl::toPercentEncoding("password")) + .append("=") + .append(QUrl::toPercentEncoding(stringValue(password))); + + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::loginUserCallback); + + worker->execute(&input); + } + + void + SWGUserApi::loginUserCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + + + + QString json(worker->response); + QString* output = static_cast(create(json, + QString("QString"))); + + + + + worker->deleteLater(); + + emit loginUserSignal(output); + + } + + void + SWGUserApi::logoutUser() { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/logout"); + + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::logoutUserCallback); + + worker->execute(&input); + } + + void + SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit logoutUserSignal(); + } + + void + SWGUserApi::getUserByName(QString* username) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + + + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); + fullPath.replace(usernamePathParam, stringValue(username)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::getUserByNameCallback); + + worker->execute(&input); + } + + void + SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + + + + QString json(worker->response); + SWGUser* output = static_cast(create(json, + QString("SWGUser"))); + + + + + worker->deleteLater(); + + emit getUserByNameSignal(output); + + } + + void + SWGUserApi::updateUser(QString* username + , SWGUser body) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + + + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); + fullPath.replace(usernamePathParam, stringValue(username)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "PUT"); + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::updateUserCallback); + + worker->execute(&input); + } + + void + SWGUserApi::updateUserCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit updateUserSignal(); + } + + void + SWGUserApi::deleteUser(QString* username) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + + + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); + fullPath.replace(usernamePathParam, stringValue(username)); + + + + + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); + + + + + + + + connect(worker, + &HttpRequestWorker::on_execution_finished, + this, + &SWGUserApi::deleteUserCallback); + + worker->execute(&input); + } + + void + SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) { + QString msg; + if (worker->error_type == QNetworkReply::NoError) { + msg = QString("Success! %1 bytes").arg(worker->response.length()); + } + else { + msg = "Error: " + worker->error_str; + } + + + + worker->deleteLater(); + + + emit deleteUserSignal(); + } + + + } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.h b/samples/client/petstore/qt5cpp/client/SWGUserApi.h index 2e3e119dc78..62bd43e9a4e 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.h @@ -7,14 +7,15 @@ #include #include -#include +#include + -namespace Swagger { + namespace Swagger { -class SWGUserApi: public QObject { + class SWGUserApi: public QObject { Q_OBJECT -public: + public: SWGUserApi(); SWGUserApi(QString host, QString basePath); ~SWGUserApi(); @@ -25,13 +26,15 @@ public: void createUser(SWGUser body); void createUsersWithArrayInput(QList* body); void createUsersWithListInput(QList* body); - void loginUser(QString* username, QString* password); + void loginUser(QString* username + , QString* password); void logoutUser(); void getUserByName(QString* username); - void updateUser(QString* username, SWGUser body); + void updateUser(QString* username + , SWGUser body); void deleteUser(QString* username); -private: + private: void createUserCallback (HttpRequestWorker * worker); void createUsersWithArrayInputCallback (HttpRequestWorker * worker); void createUsersWithListInputCallback (HttpRequestWorker * worker); @@ -41,7 +44,7 @@ private: void updateUserCallback (HttpRequestWorker * worker); void deleteUserCallback (HttpRequestWorker * worker); -signals: + signals: void createUserSignal(); void createUsersWithArrayInputSignal(); void createUsersWithListInputSignal(); @@ -51,6 +54,6 @@ signals: void updateUserSignal(); void deleteUserSignal(); -}; -} -#endif \ No newline at end of file + }; + } + #endif \ No newline at end of file diff --git a/samples/client/petstore/retrofit/pom.xml b/samples/client/petstore/retrofit/pom.xml index 1ec0876f3e6..8895c7719fb 100644 --- a/samples/client/petstore/retrofit/pom.xml +++ b/samples/client/petstore/retrofit/pom.xml @@ -1,4 +1,4 @@ - 4.0.0 io.swagger @@ -77,7 +77,8 @@ - src/main/java + + src/main/java @@ -89,7 +90,8 @@ - src/test/java + + src/test/java @@ -100,7 +102,8 @@ maven-compiler-plugin 2.3.2 - 1.6 + + 1.6 1.6 diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/ServiceGenerator.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/ServiceGenerator.java index 184f11acc75..81751b50cd1 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/ServiceGenerator.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/ServiceGenerator.java @@ -6,19 +6,18 @@ import retrofit.RestAdapter; import retrofit.converter.GsonConverter; public class ServiceGenerator { - // No need to instantiate this class. - private ServiceGenerator() { - } +// No need to instantiate this class. +private ServiceGenerator() { } - public static S createService(Class serviceClass) { - Gson gson = new GsonBuilder() - .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") - .create(); - RestAdapter adapter = new RestAdapter.Builder() - .setEndpoint("http://petstore.swagger.io/v2") - .setConverter(new GsonConverter(gson)) - .build(); +public static S createService(Class serviceClass) { + Gson gson = new GsonBuilder() + .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") + .create(); + RestAdapter adapter = new RestAdapter.Builder() + .setEndpoint("http://petstore.swagger.io/v2") + .setConverter(new GsonConverter(gson)) + .build(); - return adapter.create(serviceClass); + return adapter.create(serviceClass); + } } -} diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/PetApi.java index fed89d092d4..e92a43fbae4 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -1,117 +1,117 @@ package io.swagger.client.api; -import io.swagger.client.model.Pet; +import io.swagger.client.model.*; + import retrofit.http.*; import retrofit.mime.*; +import java.util.*; -import java.util.List; +import io.swagger.client.model.Pet; +import java.io.File; -public interface PetApi { - - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store - * @return Void - */ - - @PUT("/pet") - Void updatePet( - @Body Pet body - ); - - /** - * Add a new pet to the store - * - * @param body Pet object that needs to be added to the store - * @return Void - */ - - @POST("/pet") - Void addPet( - @Body Pet body - ); - - /** - * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * - * @param status Status values that need to be considered for filter - * @return List - */ - - @GET("/pet/findByStatus") - List findPetsByStatus( - @Query("status") List status - ); - - /** - * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * - * @param tags Tags to filter by - * @return List - */ - - @GET("/pet/findByTags") - List findPetsByTags( - @Query("tags") List tags - ); - - /** - * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * - * @param petId ID of pet that needs to be fetched - * @return Pet - */ - - @GET("/pet/{petId}") - Pet getPetById( - @Path("petId") Long petId - ); - - /** - * Updates a pet in the store with form data - * - * @param petId ID of pet that needs to be updated - * @param name Updated name of the pet - * @param status Updated status of the pet - * @return Void - */ - - @FormUrlEncoded - @POST("/pet/{petId}") - Void updatePetWithForm( - @Path("petId") String petId, @Field("name") String name, @Field("status") String status - ); - - /** - * Deletes a pet - * - * @param apiKey - * @param petId Pet id to delete - * @return Void - */ - - @DELETE("/pet/{petId}") - Void deletePet( - @Header("api_key") String apiKey, @Path("petId") Long petId - ); - - /** - * uploads an image - * - * @param petId ID of pet to update - * @param additionalMetadata Additional data to pass to server - * @param file file to upload - * @return Void - */ - - @Multipart - @POST("/pet/{petId}/uploadImage") - Void uploadFile( - @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file - ); - -} + public interface PetApi { + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return Void + */ + + @PUT("/pet") + Void updatePet( + @Body Pet body + ); + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + * @return Void + */ + + @POST("/pet") + Void addPet( + @Body Pet body + ); + + /** + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * @param status Status values that need to be considered for filter + * @return List + */ + + @GET("/pet/findByStatus") + List findPetsByStatus( + @Query("status") List status + ); + + /** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + * @return List + */ + + @GET("/pet/findByTags") + List findPetsByTags( + @Query("tags") List tags + ); + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return Pet + */ + + @GET("/pet/{petId}") + Pet getPetById( + @Path("petId") Long petId + ); + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @return Void + */ + + @FormUrlEncoded + @POST("/pet/{petId}") + Void updatePetWithForm( + @Path("petId") String petId,@Field("name") String name,@Field("status") String status + ); + + /** + * Deletes a pet + * + * @param apiKey + * @param petId Pet id to delete + * @return Void + */ + + @DELETE("/pet/{petId}") + Void deletePet( + @Header("api_key") String apiKey,@Path("petId") Long petId + ); + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @return Void + */ + + @Multipart + @POST("/pet/{petId}/uploadImage") + Void uploadFile( + @Path("petId") Long petId,@Part("additionalMetadata") String additionalMetadata,@Part("file") TypedFile file + ); + + } diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index 57d43953ace..ead55d0e2c0 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -1,60 +1,60 @@ package io.swagger.client.api; -import io.swagger.client.model.Order; +import io.swagger.client.model.*; + import retrofit.http.*; import retrofit.mime.*; +import java.util.*; import java.util.Map; +import io.swagger.client.model.Order; -public interface StoreApi { - - /** - * Returns pet inventories by status - * Returns a map of status codes to quantities - * - * @return Map - */ - - @GET("/store/inventory") - Map getInventory(); - - - /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet - * @return Order - */ - - @POST("/store/order") - Order placeOrder( - @Body Order body - ); - - /** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * - * @param orderId ID of pet that needs to be fetched - * @return Order - */ - - @GET("/store/order/{orderId}") - Order getOrderById( - @Path("orderId") 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 - * - * @param orderId ID of the order that needs to be deleted - * @return Void - */ - - @DELETE("/store/order/{orderId}") - Void deleteOrder( - @Path("orderId") String orderId - ); - -} + public interface StoreApi { + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map + */ + + @GET("/store/inventory") + Map getInventory(); + + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order + */ + + @POST("/store/order") + Order placeOrder( + @Body Order body + ); + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + * @return Order + */ + + @GET("/store/order/{orderId}") + Order getOrderById( + @Path("orderId") 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 + * @param orderId ID of the order that needs to be deleted + * @return Void + */ + + @DELETE("/store/order/{orderId}") + Void deleteOrder( + @Path("orderId") String orderId + ); + + } diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/UserApi.java index afd4418f729..824e244526f 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/api/UserApi.java @@ -1,110 +1,110 @@ package io.swagger.client.api; -import io.swagger.client.model.User; +import io.swagger.client.model.*; + import retrofit.http.*; import retrofit.mime.*; +import java.util.*; -import java.util.List; +import io.swagger.client.model.User; +import java.util.*; -public interface UserApi { - - /** - * Create user - * This can only be done by the logged in user. - * - * @param body Created user object - * @return Void - */ - - @POST("/user") - Void createUser( - @Body User body - ); - - /** - * Creates list of users with given input array - * - * @param body List of user object - * @return Void - */ - - @POST("/user/createWithArray") - Void createUsersWithArrayInput( - @Body List body - ); - - /** - * Creates list of users with given input array - * - * @param body List of user object - * @return Void - */ - - @POST("/user/createWithList") - Void createUsersWithListInput( - @Body List body - ); - - /** - * Logs user into the system - * - * @param username The user name for login - * @param password The password for login in clear text - * @return String - */ - - @GET("/user/login") - String loginUser( - @Query("username") String username, @Query("password") String password - ); - - /** - * Logs out current logged in user session - * - * @return Void - */ - - @GET("/user/logout") - Void logoutUser(); - - - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. - * @return User - */ - - @GET("/user/{username}") - User getUserByName( - @Path("username") String username - ); - - /** - * Updated user - * This can only be done by the logged in user. - * - * @param username name that need to be deleted - * @param body Updated user object - * @return Void - */ - - @PUT("/user/{username}") - Void updateUser( - @Path("username") String username, @Body User body - ); - - /** - * Delete user - * This can only be done by the logged in user. - * - * @param username The name that needs to be deleted - * @return Void - */ - - @DELETE("/user/{username}") - Void deleteUser( - @Path("username") String username - ); - -} + public interface UserApi { + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + * @return Void + */ + + @POST("/user") + Void createUser( + @Body User body + ); + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return Void + */ + + @POST("/user/createWithArray") + Void createUsersWithArrayInput( + @Body List body + ); + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return Void + */ + + @POST("/user/createWithList") + Void createUsersWithListInput( + @Body List body + ); + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return String + */ + + @GET("/user/login") + String loginUser( + @Query("username") String username,@Query("password") String password + ); + + /** + * Logs out current logged in user session + * + * @return Void + */ + + @GET("/user/logout") + Void logoutUser(); + + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ + + @GET("/user/{username}") + User getUserByName( + @Path("username") String username + ); + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + * @return Void + */ + + @PUT("/user/{username}") + Void updateUser( + @Path("username") String username,@Body User body + ); + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return Void + */ + + @DELETE("/user/{username}") + Void deleteUser( + @Path("username") String username + ); + + } diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Category.java index 0e6c2484ab6..1a964573856 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Category.java @@ -1,50 +1,50 @@ package io.swagger.client.model; +import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - -@ApiModel(description = "") -public class Category { - + + @ApiModel(description = "") + public class Category { + /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("id") - private Long id = null; + private Long id = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("name") - private String name = null; + private String name = null; - - public Long getId() { + + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } - - public String getName() { + } + + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } - + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Order.java index 05206761a58..1f1fe1f7df4 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -1,115 +1,111 @@ package io.swagger.client.model; -import com.google.gson.annotations.SerializedName; - import java.util.Date; +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; -@ApiModel(description = "") -public class Order { - + + @ApiModel(description = "") + public class Order { + /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("id") - private Long id = null; + private Long id = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("petId") - private Long petId = null; + private Long petId = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("quantity") - private Integer quantity = null; + private Integer quantity = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("shipDate") - private Date shipDate = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + /** - * Order Status - **/ + * Order Status + **/ @ApiModelProperty(value = "Order Status") @SerializedName("status") - private StatusEnum status = null; + private StatusEnum status = null; - ; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("complete") - private Boolean complete = null; + private Boolean complete = null; - public Long getId() { + + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } - - public Long getPetId() { + } + + public Long getPetId() { return petId; - } - - public void setPetId(Long petId) { + } + public void setPetId(Long petId) { this.petId = petId; - } - - public Integer getQuantity() { + } + + public Integer getQuantity() { return quantity; - } - - public void setQuantity(Integer quantity) { + } + public void setQuantity(Integer quantity) { this.quantity = quantity; - } - - public Date getShipDate() { + } + + public Date getShipDate() { return shipDate; - } - - public void setShipDate(Date shipDate) { + } + public void setShipDate(Date shipDate) { this.shipDate = shipDate; - } - - public StatusEnum getStatus() { + } + + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } - - public Boolean getComplete() { + } + + public Boolean getComplete() { return complete; - } - - public void setComplete(Boolean complete) { + } + public void setComplete(Boolean complete) { this.complete = complete; - } - + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - public enum StatusEnum { - placed, approved, delivered, } -} + diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java index a2ee96be5ef..e311a11be48 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java @@ -1,119 +1,113 @@ package io.swagger.client.model; -import com.google.gson.annotations.SerializedName; import io.swagger.client.model.Category; import io.swagger.client.model.Tag; +import java.util.*; -import java.util.ArrayList; -import java.util.List; - - -@ApiModel(description = "") -public class Pet { +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + @ApiModel(description = "") + public class Pet { + /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("id") - private Long id = null; + private Long id = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("category") - private Category category = null; + private Category category = null; /** - **/ + **/ @ApiModelProperty(required = true, value = "") @SerializedName("name") - private String name = null; + private String name = null; /** - **/ + **/ @ApiModelProperty(required = true, value = "") @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); + private List photoUrls = new ArrayList() ; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("tags") - private List tags = new ArrayList(); + private List tags = new ArrayList() ; + public enum StatusEnum { + available, pending, sold, + }; + /** - * pet status in the store - **/ + * pet status in the store + **/ @ApiModelProperty(value = "pet status in the store") @SerializedName("status") - private StatusEnum status = null; + private StatusEnum status = null; - ; - - public Long getId() { + + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } - - public Category getCategory() { + } + + public Category getCategory() { return category; - } - - public void setCategory(Category category) { + } + public void setCategory(Category category) { this.category = category; - } - - public String getName() { + } + + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } - - public List getPhotoUrls() { + } + + public List getPhotoUrls() { return photoUrls; - } - - public void setPhotoUrls(List photoUrls) { + } + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; - } - - public List getTags() { + } + + public List getTags() { return tags; - } - - public void setTags(List tags) { + } + public void setTags(List tags) { this.tags = tags; - } - - public StatusEnum getStatus() { + } + + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } - + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - public enum StatusEnum { - available, pending, sold, } -} + diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Tag.java index 21492bb94ed..0135992c7c6 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Tag.java @@ -1,50 +1,50 @@ package io.swagger.client.model; +import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - -@ApiModel(description = "") -public class Tag { - + + @ApiModel(description = "") + public class Tag { + /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("id") - private Long id = null; + private Long id = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("name") - private String name = null; + private String name = null; - - public Long getId() { + + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } - - public String getName() { + } + + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } - + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/User.java index c75a91577c4..10fae2f8318 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/User.java @@ -1,141 +1,135 @@ package io.swagger.client.model; +import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - -@ApiModel(description = "") -public class User { - + + @ApiModel(description = "") + public class User { + /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("id") - private Long id = null; + private Long id = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("username") - private String username = null; + private String username = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("firstName") - private String firstName = null; + private String firstName = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("lastName") - private String lastName = null; + private String lastName = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("email") - private String email = null; + private String email = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("password") - private String password = null; + private String password = null; /** - **/ + **/ @ApiModelProperty(value = "") @SerializedName("phone") - private String phone = null; + private String phone = null; /** - * User Status - **/ + * User Status + **/ @ApiModelProperty(value = "User Status") @SerializedName("userStatus") - private Integer userStatus = null; + private Integer userStatus = null; - - public Long getId() { + + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } - - public String getUsername() { + } + + public String getUsername() { return username; - } - - public void setUsername(String username) { + } + public void setUsername(String username) { this.username = username; - } - - public String getFirstName() { + } + + public String getFirstName() { return firstName; - } - - public void setFirstName(String firstName) { + } + public void setFirstName(String firstName) { this.firstName = firstName; - } - - public String getLastName() { + } + + public String getLastName() { return lastName; - } - - public void setLastName(String lastName) { + } + public void setLastName(String lastName) { this.lastName = lastName; - } - - public String getEmail() { + } + + public String getEmail() { return email; - } - - public void setEmail(String email) { + } + public void setEmail(String email) { this.email = email; - } - - public String getPassword() { + } + + public String getPassword() { return password; - } - - public void setPassword(String password) { + } + public void setPassword(String password) { this.password = password; - } - - public String getPhone() { + } + + public String getPhone() { return phone; - } - - public void setPhone(String phone) { + } + public void setPhone(String phone) { this.phone = phone; - } - - public Integer getUserStatus() { + } + + public Integer getUserStatus() { return userStatus; - } - - public void setUserStatus(Integer userStatus) { + } + public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; - } - + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/client/petstore/ruby/lib/swagger_client.rb b/samples/client/petstore/ruby/lib/swagger_client.rb index 6d239185005..6b2f591df88 100644 --- a/samples/client/petstore/ruby/lib/swagger_client.rb +++ b/samples/client/petstore/ruby/lib/swagger_client.rb @@ -8,18 +8,22 @@ 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 7bed9b47780..5e0d4539867 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,328 +1,337 @@ 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 = {}) + - # 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') - # resource path - path = "/pet".sub('{format}','json') + # query parameters + query_params = {} - # query parameters - query_params = {} + # header parameters + header_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 '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) - # 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 = {} - # form parameters - form_params = {} + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + - # http body (model) - post_body = Swagger::Request.object_to_http_body(opts[:'body']) - + 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 = {}) + - 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 + # 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 - - # 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 010d170945b..ab468e94669 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,161 +1,166 @@ 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 = {}) + - # 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') - # resource path - path = "/store/inventory".sub('{format}','json') + # query parameters + query_params = {} - # query parameters - query_params = {} + # header parameters + header_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 '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) - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + # form parameters + form_params = {} - # form parameters - form_params = {} + # http body (model) + post_body = nil + - # http body (model) - post_body = nil - + 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 = {}) + - 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) } + # 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 - - # 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 a3a57503b01..72ecae9f26b 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,316 +1,325 @@ 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 = {}) + - # 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') - # resource path - path = "/user".sub('{format}','json') + # query parameters + query_params = {} - # query parameters - query_params = {} + # header parameters + header_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 '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) - # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type) + # form parameters + form_params = {} - # form parameters - form_params = {} + # http body (model) + post_body = Swagger::Request.object_to_http_body(opts[:'body']) + - # 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_array_input(opts = {}) + - 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 + # 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 - - # 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 642e4769e55..93354b7f1dc 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 - - # 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 - - 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 - - # 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 +# 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 + +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 + +# 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 + +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 fe195c7ac87..08b3b9e8d46 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/category.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/category.rb @@ -1,44 +1,37 @@ 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'] - end - - if attributes[:'name'] - @name = attributes[:'name'] - end - - end - end +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'] + 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 3fe0282ed9b..faf62fb6a2f 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/order.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/order.rb @@ -1,76 +1,61 @@ 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 - - # 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? - - # 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'] - end - - end - 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 + +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[:'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 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 32f95646c72..561f4a9ed7a 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/pet.rb @@ -1,80 +1,65 @@ 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 - - # 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? - - # 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'] - end - - end - 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 + +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[:'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 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 9c5cdde1af6..6c66fbe4dc5 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/tag.rb @@ -1,44 +1,37 @@ 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'] - end - - if attributes[:'name'] - @name = attributes[:'name'] - end - - end - end +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'] + 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 2d723da54c4..910bd70d726 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/models/user.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/models/user.rb @@ -1,92 +1,73 @@ 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 - - # 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? - - # 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'] - end - - end - 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 + +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[:'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 diff --git a/samples/client/petstore/ruby/lib/swagger_client/monkey.rb b/samples/client/petstore/ruby/lib/swagger_client/monkey.rb index 28932890af9..f400813974f 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 - - unless Object.method_defined? :blank? - def blank? - respond_to?(:empty?) ? empty? : !self - end - end - - unless Object.method_defined? :present? - def present? - !blank? - end - end +class Object - end +unless Object.method_defined? :blank? +def blank? +respond_to?(:empty?) ? empty? : !self +end +end - class String +unless Object.method_defined? :present? +def present? +!blank? +end +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 +end - end +class String - class Hash +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 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 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? :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 +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 +class Hash - 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? :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 # 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 2e2632c169d..1820bbfcc9e 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 a2d4fe0e291..023242c9cd5 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 4cd5d84b0b9..f3a15971682 100644 --- a/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb +++ b/samples/client/petstore/ruby/lib/swagger_client/swagger/request.rb @@ -1,271 +1,270 @@ 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 - - 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 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 - - # 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! /\?$/, '' - - 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 - - # 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 - - p = p.sub("{format}", self.format.to_s) - - 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 - - # 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 - - # 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 - - 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 - ) - - 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 :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 - - def response - self.make - 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 - - # 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 - - # 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 - - end - 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 + +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 + +# 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 + +# Drop trailing question mark, if present +u.sub! /\?$/, '' + +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 + +# 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 + +p = p.sub("{format}", self.format.to_s) + +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 + +# 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 + +# 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 + +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 +) + +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 :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 + +def response +self.make +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 + +# 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 + +# 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 + +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 538821bea69..d5eaf2edac0 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 - - def code - raw.code - 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 - - # `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 - - def json? - format == 'json' - 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_headers - JSON.pretty_generate(headers).gsub(/\n/, '
') - end - 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 + +# 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 + +# `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 + +def json? +format == 'json' +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_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 c6e8d5aee53..e869b16a807 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 c0d507b3c5b..0b58b597765 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 diff --git a/samples/client/petstore/tizen/client/SamiApiClient.cpp b/samples/client/petstore/tizen/client/SamiApiClient.cpp index 35779307fa2..f3c988dea5a 100644 --- a/samples/client/petstore/tizen/client/SamiApiClient.cpp +++ b/samples/client/petstore/tizen/client/SamiApiClient.cpp @@ -5,120 +5,120 @@ using namespace Tizen::Base::Utility; namespace Swagger { SamiApiClient::SamiApiClient() { - enc = new Utf8Encoding(); +enc = new Utf8Encoding(); } void SamiApiClient::success(void (*success) (HttpResponse*, void (*cb)(void*, SamiError*)), void (*cb)(void*, SamiError*)) { - this->successFunction = success; - this->cb = cb; +this->successFunction = success; +this->cb = cb; } SamiApiClient::~SamiApiClient() { - if(enc) - delete enc; +if(enc) +delete enc; } result SamiApiClient::execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap* formParams, String contentType) { - NetHttpMethod httpMethod; - if(method.Equals(L"GET", false)) { - httpMethod = NET_HTTP_METHOD_GET; - } - else if(method.Equals(L"PUT", false)) { - httpMethod = NET_HTTP_METHOD_PUT; - } - else if(method.Equals(L"POST", false)) { - httpMethod = NET_HTTP_METHOD_POST; - } - else if(method.Equals(L"DELETE", false)) { - httpMethod = NET_HTTP_METHOD_DELETE; - } - else if(method.Equals(L"OPTIONS", false)) { - httpMethod = NET_HTTP_METHOD_OPTIONS; - } - else if(method.Equals(L"HEAD", false)) { - httpMethod = NET_HTTP_METHOD_HEAD; - } - else if(method.Equals(L"TRACE", false)) { - httpMethod = NET_HTTP_METHOD_TRACE; - } +NetHttpMethod httpMethod; +if(method.Equals(L"GET", false)) { +httpMethod = NET_HTTP_METHOD_GET; +} +else if(method.Equals(L"PUT", false)) { +httpMethod = NET_HTTP_METHOD_PUT; +} +else if(method.Equals(L"POST", false)) { +httpMethod = NET_HTTP_METHOD_POST; +} +else if(method.Equals(L"DELETE", false)) { +httpMethod = NET_HTTP_METHOD_DELETE; +} +else if(method.Equals(L"OPTIONS", false)) { +httpMethod = NET_HTTP_METHOD_OPTIONS; +} +else if(method.Equals(L"HEAD", false)) { +httpMethod = NET_HTTP_METHOD_HEAD; +} +else if(method.Equals(L"TRACE", false)) { +httpMethod = NET_HTTP_METHOD_TRACE; +} - String uri = String(host); - uri.Append(path); +String uri = String(host); +uri.Append(path); - HttpSession* __pHttpSession = null; - HttpTransaction* pHttpTransaction = null; - HttpRequest* pHttpRequest = null; +HttpSession* __pHttpSession = null; +HttpTransaction* pHttpTransaction = null; +HttpRequest* pHttpRequest = null; - if (__pHttpSession == null) { - __pHttpSession = new (std::nothrow) HttpSession(); - __pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, uri, null); - __pHttpSession->SetAutoRedirectionEnabled(true); - } - pHttpTransaction = __pHttpSession->OpenTransactionN(); - pHttpTransaction->AddHttpTransactionListener(*this); +if (__pHttpSession == null) { +__pHttpSession = new (std::nothrow) HttpSession(); +__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, uri, null); +__pHttpSession->SetAutoRedirectionEnabled(true); +} +pHttpTransaction = __pHttpSession->OpenTransactionN(); +pHttpTransaction->AddHttpTransactionListener(*this); - pHttpRequest = const_cast< HttpRequest* >(pHttpTransaction->GetRequest()); +pHttpRequest = const_cast< HttpRequest* >(pHttpTransaction->GetRequest()); - HttpHeader *pHeader = pHttpRequest->GetHeader(); - if(contentType != null && !contentType.Equals(L"", true)) { - pHeader->AddField(L"Accept", contentType); - } - if(queryParams != null) { - IMapEnumerator* pMapEnum = queryParams->GetMapEnumeratorN(); - String queryParam = L""; - while (pMapEnum->MoveNext() == E_SUCCESS) { - if(queryParam.GetLength() == 0) - queryParam.Append(L"?"); - else - queryParam.Append(L"&"); +HttpHeader *pHeader = pHttpRequest->GetHeader(); +if(contentType != null && !contentType.Equals(L"", true)) { +pHeader->AddField(L"Accept", contentType); +} +if(queryParams != null) { +IMapEnumerator* pMapEnum = queryParams->GetMapEnumeratorN(); +String queryParam = L""; +while (pMapEnum->MoveNext() == E_SUCCESS) { +if(queryParam.GetLength() == 0) +queryParam.Append(L"?"); +else +queryParam.Append(L"&"); - String* pKey = static_cast< String* > (pMapEnum->GetKey()); - String* pValue = static_cast< String* > (pMapEnum->GetValue()); - String encoded; - UrlEncoder::Encode(*pKey, L"UTF-8", encoded); +String* pKey = static_cast< String* > (pMapEnum->GetKey()); +String* pValue = static_cast< String* > (pMapEnum->GetValue()); +String encoded; +UrlEncoder::Encode(*pKey, L"UTF-8", encoded); - queryParam.Append(encoded); - queryParam.Append("="); - UrlEncoder::Encode(*pValue, L"UTF-8", encoded); - queryParam.Append(encoded); - } - uri.Append(queryParam); - delete queryParams; - } - if(headerParams != null) { - IMapEnumerator* pMapEnum = headerParams->GetMapEnumeratorN(); - while (pMapEnum->MoveNext() == E_SUCCESS) { - String* pKey = static_cast< String* > (pMapEnum->GetKey()); - String* pValue = static_cast< String* > (pMapEnum->GetValue()); - pHeader->AddField(*pKey, *pValue); - } - delete headerParams; - } - if(body != null) { - HttpStringEntity * pEntity = new HttpStringEntity(); - String* cp = new String(*body); - result res = pEntity->Construct(*body, L"application/json", "utf-8", *enc); - res = pHttpRequest->SetEntity(*pEntity); - } +queryParam.Append(encoded); +queryParam.Append("="); +UrlEncoder::Encode(*pValue, L"UTF-8", encoded); +queryParam.Append(encoded); +} +uri.Append(queryParam); +delete queryParams; +} +if(headerParams != null) { +IMapEnumerator* pMapEnum = headerParams->GetMapEnumeratorN(); +while (pMapEnum->MoveNext() == E_SUCCESS) { +String* pKey = static_cast< String* > (pMapEnum->GetKey()); +String* pValue = static_cast< String* > (pMapEnum->GetValue()); +pHeader->AddField(*pKey, *pValue); +} +delete headerParams; +} +if(body != null) { +HttpStringEntity * pEntity = new HttpStringEntity(); +String* cp = new String(*body); +result res = pEntity->Construct(*body, L"application/json", "utf-8", *enc); +res = pHttpRequest->SetEntity(*pEntity); +} - pHttpRequest->SetUri(uri); - pHttpRequest->SetMethod(httpMethod); +pHttpRequest->SetUri(uri); +pHttpRequest->SetMethod(httpMethod); - AppLog("%ls", uri.GetPointer()); - return pHttpTransaction->Submit(); +AppLog("%ls", uri.GetPointer()); +return pHttpTransaction->Submit(); } void SamiApiClient::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction) { - HttpResponse* pHttpResponse = pHttpTransaction.GetResponse(); +HttpResponse* pHttpResponse = pHttpTransaction.GetResponse(); - if(successFunction != null) { - successFunction(pHttpResponse, cb); - } - delete &httpSession; - delete &pHttpTransaction; +if(successFunction != null) { +successFunction(pHttpResponse, cb); +} +delete &httpSession; +delete &pHttpTransaction; } } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiApiClient.h b/samples/client/petstore/tizen/client/SamiApiClient.h index f20eb6e158b..d152af8b838 100644 --- a/samples/client/petstore/tizen/client/SamiApiClient.h +++ b/samples/client/petstore/tizen/client/SamiApiClient.h @@ -1,73 +1,75 @@ -#include +#include + -#include "SamiHelpers.h" -#include "SamiError.h" + #include "SamiHelpers.h" + #include "SamiError.h" -using namespace Tizen::Net::Http; -using namespace Tizen::Base; -using namespace Tizen::Base::Collection; -using namespace Tizen::Text; + using namespace Tizen::Net::Http; + using namespace Tizen::Base; + using namespace Tizen::Base::Collection; + using namespace Tizen::Text; -#ifndef APICLIENT_H_ -#define APICLIENT_H_ + #ifndef APICLIENT_H_ + #define APICLIENT_H_ -namespace Swagger { + namespace Swagger { -class SamiApiClient: public IHttpTransactionEventListener { -public: - SamiApiClient(); - virtual ~SamiApiClient(); + class SamiApiClient: public IHttpTransactionEventListener { + public: + SamiApiClient(); + virtual ~SamiApiClient(); - result - execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap* formParams, String contentType); + result + execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap* + formParams, String contentType); - void success(void (*res) (HttpResponse*, void (*cb)(void*, SamiError*)), void (*cb)(void*, SamiError*)); + void success(void (*res) (HttpResponse*, void (*cb)(void*, SamiError*)), void (*cb)(void*, SamiError*)); - virtual void - OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction); + virtual void + OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction); - virtual void - OnAudioInAudioFocusChanged(void) { + virtual void + OnAudioInAudioFocusChanged(void) { AppLog("OnAudioInAudioFocusChanged"); - } + } - virtual void - OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, - Tizen::Base::String* pCert) { + virtual void + OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, + Tizen::Base::String* pCert) { AppLog("OnTransactionCertVerificationRequiredN"); httpTransaction.Resume(); delete pCert; - } - - virtual void - OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) { - AppLog("OnTransactionReadyToWrite"); - } + } - virtual void - OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) { + virtual void + OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) { + AppLog("OnTransactionReadyToWrite"); + } + + virtual void + OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) { AppLog("OnTransactionReadyToRead"); - } - - virtual void - OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) { + } + + virtual void + OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) { AppLog("OnTransactionAborted: %ls", GetErrorMessage(r)); delete &httpTransaction; - } - - virtual void - OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool - bAuthRequired) { + } + + virtual void + OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool + bAuthRequired) { AppLog("OnTransactionHeaderCompleted"); -} + } -private: - void (*successFunction) (HttpResponse*, void (*success)(void*, SamiError*)); - void (*cb)(void*, SamiError*); - Utf8Encoding* enc; -}; + private: + void (*successFunction) (HttpResponse*, void (*success)(void*, SamiError*)); + void (*cb)(void*, SamiError*); + Utf8Encoding* enc; + }; -} /* namespace Swagger */ -#endif /* APICLIENT_H_ */ + } /* namespace Swagger */ + #endif /* APICLIENT_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiCategory.cpp b/samples/client/petstore/tizen/client/SamiCategory.cpp index 185b1f9d895..6b92fe64809 100644 --- a/samples/client/petstore/tizen/client/SamiCategory.cpp +++ b/samples/client/petstore/tizen/client/SamiCategory.cpp @@ -1,182 +1,186 @@ -#include "SamiCategory.h" -#include + #include "SamiCategory.h" + #include + -using namespace Tizen::Base; -using namespace Tizen::System; -using namespace Tizen::Base::Utility; -using namespace Tizen::Base::Collection; -using namespace Tizen::Web::Json; -using namespace Tizen::Locales; + using namespace Tizen::Base; + using namespace Tizen::System; + using namespace Tizen::Base::Utility; + using namespace Tizen::Base::Collection; + using namespace Tizen::Web::Json; + using namespace Tizen::Locales; -namespace Swagger { + namespace Swagger { -SamiCategory::SamiCategory() { - init(); -} + SamiCategory::SamiCategory() { + init(); + } -SamiCategory::~SamiCategory() { - this->cleanup(); -} + SamiCategory::~SamiCategory() { + this->cleanup(); + } -void -SamiCategory::init() { + void + SamiCategory::init() { pId = null; pName = null; -} + } -void -SamiCategory::cleanup() { + void + SamiCategory::cleanup() { if(pId != null) { - - delete pId; - pId = null; - } - if(pName != null) { - - delete pName; - pName = null; - } -} + delete pId; + pId = null; + } + if(pName != null) { + + delete pName; + pName = null; + } + + } -SamiCategory* -SamiCategory::fromJson(String* json) { - this->cleanup(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiCategory* + SamiCategory::fromJson(String* json) { + this->cleanup(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; - return this; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + return this; + } -void -SamiCategory::fromJsonObject(IJsonValue* pJson) { - JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); + void + SamiCategory::fromJsonObject(IJsonValue* pJson) { + JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); - if(pJsonObject != null) { - JsonString* pIdKey = new JsonString(L"id"); + if(pJsonObject != null) { + JsonString* pIdKey = new JsonString(L"id"); IJsonValue* pIdVal = null; pJsonObject->GetValue(pIdKey, pIdVal); if(pIdVal != null) { - - pId = new Long(); - jsonToValue(pId, pIdVal, L"Long", L"Long"); + + pId = new Long(); + jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pNameKey = new JsonString(L"name"); + JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { - - pName = new String(); - jsonToValue(pName, pNameVal, L"String", L"String"); + + pName = new String(); + jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - - } -} + + } + } -SamiCategory::SamiCategory(String* json) { - init(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiCategory::SamiCategory(String* json) { + init(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + } -String -SamiCategory::asJson () -{ - JsonObject* pJsonObject = asJsonObject(); + String + SamiCategory::asJson () + { + JsonObject* pJsonObject = asJsonObject(); - char *pComposeBuf = new char[256]; - JsonWriter::Compose(pJsonObject, pComposeBuf, 256); - String s = String(pComposeBuf); + char *pComposeBuf = new char[256]; + JsonWriter::Compose(pJsonObject, pComposeBuf, 256); + String s = String(pComposeBuf); - delete pComposeBuf; - pJsonObject->RemoveAll(true); - delete pJsonObject; + delete pComposeBuf; + pJsonObject->RemoveAll(true); + delete pJsonObject; - return s; -} + return s; + } -JsonObject* -SamiCategory::asJsonObject() { - JsonObject *pJsonObject = new JsonObject(); - pJsonObject->Construct(); + JsonObject* + SamiCategory::asJsonObject() { + JsonObject *pJsonObject = new JsonObject(); + pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); - pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); + JsonString *pIdKey = new JsonString(L"id"); + pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pNameKey = new JsonString(L"name"); - pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); + JsonString *pNameKey = new JsonString(L"name"); + pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - return pJsonObject; -} + return pJsonObject; + } -Long* -SamiCategory::getPId() { - return pId; -} -void -SamiCategory::setPId(Long* pId) { - this->pId = pId; -} + + Long* + SamiCategory::getPId() { + return pId; + } + void + SamiCategory::setPId(Long* pId) { + this->pId = pId; + } -String* -SamiCategory::getPName() { - return pName; -} -void -SamiCategory::setPName(String* pName) { - this->pName = pName; -} + + String* + SamiCategory::getPName() { + return pName; + } + void + SamiCategory::setPName(String* pName) { + this->pName = pName; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiCategory.h b/samples/client/petstore/tizen/client/SamiCategory.h index a361ea047fa..0b35b7ac929 100644 --- a/samples/client/petstore/tizen/client/SamiCategory.h +++ b/samples/client/petstore/tizen/client/SamiCategory.h @@ -1,60 +1,64 @@ /* - * SamiCategory.h - * - * - */ +* SamiCategory.h +* +* +*/ #ifndef SamiCategory_H_ #define SamiCategory_H_ -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; using Tizen::Base::Long; using Tizen::Base::String; -namespace Swagger { + namespace Swagger { -class SamiCategory: public SamiObject { -public: + class SamiCategory: public SamiObject { + public: SamiCategory(); SamiCategory(String* json); - virtual ~SamiCategory(); + virtual ~SamiCategory(); - void init(); + void init(); - void cleanup(); + void cleanup(); - String asJson (); + String asJson (); - JsonObject* asJsonObject(); + JsonObject* asJsonObject(); - void fromJsonObject(IJsonValue* json); + void fromJsonObject(IJsonValue* json); SamiCategory* fromJson(String* obj); - Long* getPId(); - void setPId(Long* pId); + Long* getPId(); + void setPId(Long* pId); - String* getPName(); - void setPName(String* pName); + String* getPName(); + void setPName(String* pName); -private: + private: Long* pId; String* pName; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiCategory_H_ */ + #endif /* SamiCategory_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiError.cpp b/samples/client/petstore/tizen/client/SamiError.cpp index 1aaaa9e726b..9f0a82bf1a5 100644 --- a/samples/client/petstore/tizen/client/SamiError.cpp +++ b/samples/client/petstore/tizen/client/SamiError.cpp @@ -6,49 +6,49 @@ using namespace Tizen::System; namespace Swagger { SamiError::SamiError() { - init(); +init(); } SamiError::SamiError(int code, String* message) { - init(); - this->setCode(code); - this->setMessage(message); +init(); +this->setCode(code); +this->setMessage(message); } SamiError::~SamiError() { - this->cleanup(); +this->cleanup(); } void SamiError::init() { - pCode = 0; - pMessage = null; +pCode = 0; +pMessage = null; } void SamiError::cleanup() { - if(pMessage != null) { - delete pMessage; - pMessage = null; - } +if(pMessage != null) { +delete pMessage; +pMessage = null; +} } int SamiError::getCode() { - return pCode; +return pCode; } void SamiError::setCode(int pCode) { - this->pCode = pCode; +this->pCode = pCode; } String* SamiError::getMessage() { - return pMessage; +return pMessage; } void SamiError::setMessage(String* pMessage) { - this->pMessage = pMessage; +this->pMessage = pMessage; } } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiError.h b/samples/client/petstore/tizen/client/SamiError.h index d3afe4596b2..7afaf929bcb 100644 --- a/samples/client/petstore/tizen/client/SamiError.h +++ b/samples/client/petstore/tizen/client/SamiError.h @@ -1,14 +1,15 @@ #ifndef SamiError_H_ #define SamiError_H_ -#include +#include + -using namespace Tizen::Base; + using namespace Tizen::Base; -namespace Swagger { + namespace Swagger { -class SamiError { -public: + class SamiError { + public: SamiError(); SamiError(int code, String* message); virtual ~SamiError(); @@ -20,16 +21,16 @@ public: int getCode(); void setCode(int pCode); - + String* getMessage(); void setMessage(String* pMessage); - -private: + + private: int pCode; String* pMessage; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiError_H_ */ + #endif /* SamiError_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiHelpers.cpp b/samples/client/petstore/tizen/client/SamiHelpers.cpp index 484be3246f7..32dbd5cc810 100644 --- a/samples/client/petstore/tizen/client/SamiHelpers.cpp +++ b/samples/client/petstore/tizen/client/SamiHelpers.cpp @@ -9,265 +9,265 @@ using namespace Tizen::Locales; using namespace Tizen::System; namespace Swagger { - JsonObject* - toJson(void* ptr, String type, String containerType) { - if(ptr == null) - return null; - if(containerType != null && !type.Equals(L"", false)) { - if(containerType.Equals(L"array", false)) { - if(type != null) { - IList* list = static_cast< IList* >(ptr); - JsonArray* array = new JsonArray(); - int sz = list->GetCount(); - for(int i = 0; i < sz; i++) { - void* itemAt = list->GetAt(i); - JsonObject* item = toJson(itemAt, type, null); - if(item != null) - array->Add(item); - } - return (JsonObject*)array; - } - return null; - } - } - else if(type.Equals(L"Boolean", false)) { - Boolean* v = static_cast< Boolean* >(ptr); - return (JsonObject*) new JsonBool(*v); - } - else if(type.Equals(L"String", false)) { - String* v = static_cast< String* >(ptr); - return (JsonObject*) new JsonString(*v); - } - else if(type.Equals(L"Integer", false)) { - Integer* v = static_cast< Integer* >(ptr); - return (JsonObject*) new JsonNumber(v->ToInt()); - } - else if(type.Equals(L"Long", false)) { - Long* v = static_cast< Long* >(ptr); - return (JsonObject*) new JsonNumber(v->ToInt()); - } - else if(type.Equals(L"Float", false)) { - Float* v = static_cast< Float* >(ptr); - return (JsonObject*) new JsonNumber(v->ToFloat()); - } - else if(type.Equals(L"Double", false)) { - Double* v = static_cast< Double* >(ptr); - return (JsonObject*) new JsonNumber(v->ToDouble()); - } - else if(type.Equals(L"DateTime", false)) { - DateTime* v = static_cast< DateTime* >(ptr); - DateTimeFormatter* pFormatter = DateTimeFormatter::CreateDateTimeFormatterN(); - String date; - pFormatter->ApplyPattern(L"yyyy-MM-dd"); - pFormatter->Format(*v, date); +JsonObject* +toJson(void* ptr, String type, String containerType) { +if(ptr == null) +return null; +if(containerType != null && !type.Equals(L"", false)) { +if(containerType.Equals(L"array", false)) { +if(type != null) { +IList* list = static_cast< IList* >(ptr); +JsonArray* array = new JsonArray(); +int sz = list->GetCount(); +for(int i = 0; i < sz; i++) { +void* itemAt = list->GetAt(i); +JsonObject* item = toJson(itemAt, type, null); +if(item != null) +array->Add(item); +} +return (JsonObject*)array; +} +return null; +} +} +else if(type.Equals(L"Boolean", false)) { +Boolean* v = static_cast< Boolean* >(ptr); +return (JsonObject*) new JsonBool(*v); +} +else if(type.Equals(L"String", false)) { +String* v = static_cast< String* >(ptr); +return (JsonObject*) new JsonString(*v); +} +else if(type.Equals(L"Integer", false)) { +Integer* v = static_cast< Integer* >(ptr); +return (JsonObject*) new JsonNumber(v->ToInt()); +} +else if(type.Equals(L"Long", false)) { +Long* v = static_cast< Long* >(ptr); +return (JsonObject*) new JsonNumber(v->ToInt()); +} +else if(type.Equals(L"Float", false)) { +Float* v = static_cast< Float* >(ptr); +return (JsonObject*) new JsonNumber(v->ToFloat()); +} +else if(type.Equals(L"Double", false)) { +Double* v = static_cast< Double* >(ptr); +return (JsonObject*) new JsonNumber(v->ToDouble()); +} +else if(type.Equals(L"DateTime", false)) { +DateTime* v = static_cast< DateTime* >(ptr); +DateTimeFormatter* pFormatter = DateTimeFormatter::CreateDateTimeFormatterN(); +String date; +pFormatter->ApplyPattern(L"yyyy-MM-dd"); +pFormatter->Format(*v, date); - String time; - pFormatter->ApplyPattern(L"hh:mm:ss"); - pFormatter->Format(*v, time); - String formattedString = date + "T" + time; - delete pFormatter; - return (JsonObject*)new JsonString(formattedString); - } - else if(type.StartsWith(L"Sami", 0)) { - SamiObject* obj = static_cast< SamiObject* >(ptr); - return obj->asJsonObject(); - } - return null; - } +String time; +pFormatter->ApplyPattern(L"hh:mm:ss"); +pFormatter->Format(*v, time); +String formattedString = date + "T" + time; +delete pFormatter; +return (JsonObject*)new JsonString(formattedString); +} +else if(type.StartsWith(L"Sami", 0)) { +SamiObject* obj = static_cast< SamiObject* >(ptr); +return obj->asJsonObject(); +} +return null; +} - void - toISO8601(String str, DateTime* dt) { - int idx, start; - int year, month, day, hour, minute, second; +void +toISO8601(String str, DateTime* dt) { +int idx, start; +int year, month, day, hour, minute, second; - start = 0; - str.IndexOf(L"-", start, idx); - String yearString; - str.SubString(0, idx, yearString); - Integer::Parse(yearString, year); +start = 0; +str.IndexOf(L"-", start, idx); +String yearString; +str.SubString(0, idx, yearString); +Integer::Parse(yearString, year); - start = idx+1; - str.IndexOf(L"-", start, idx); - String monthString; - str.SubString(start, idx - start, monthString); - Integer::Parse(monthString, month); +start = idx+1; +str.IndexOf(L"-", start, idx); +String monthString; +str.SubString(start, idx - start, monthString); +Integer::Parse(monthString, month); - start = idx+1; - str.IndexOf(L"T", start, idx); - String dayString; - str.SubString(start, idx - start, dayString); - Integer::Parse(dayString, day); +start = idx+1; +str.IndexOf(L"T", start, idx); +String dayString; +str.SubString(start, idx - start, dayString); +Integer::Parse(dayString, day); - start = idx+1; - str.IndexOf(L":", start, idx); - if(idx > 0) { - String hourString; - str.SubString(start, idx - start, hourString); - Integer::Parse(hourString, hour); - } +start = idx+1; +str.IndexOf(L":", start, idx); +if(idx > 0) { +String hourString; +str.SubString(start, idx - start, hourString); +Integer::Parse(hourString, hour); +} - start = idx+1; - str.IndexOf(L":", start, idx); - if(idx > 0) { - String minuteString; - str.SubString(start, idx - start, minuteString); - Integer::Parse(minuteString, minute); - } +start = idx+1; +str.IndexOf(L":", start, idx); +if(idx > 0) { +String minuteString; +str.SubString(start, idx - start, minuteString); +Integer::Parse(minuteString, minute); +} - start = idx+1; - str.IndexOf(L"+", start, idx); - if(idx > 0) { - String secondString; - str.SubString(start, idx - start, secondString); - Integer::Parse(secondString, second); - } +start = idx+1; +str.IndexOf(L"+", start, idx); +if(idx > 0) { +String secondString; +str.SubString(start, idx - start, secondString); +Integer::Parse(secondString, second); +} - dt->SetValue(year, month, day, hour, minute, second); - } +dt->SetValue(year, month, day, hour, minute, second); +} - void - jsonToValue(void* target, IJsonValue* ptr, String type, String innerType) { - if(target == null || ptr == null) { - return; - } - if(type.StartsWith(L"Boolean", 0)) { - JsonBool* json = static_cast< JsonBool* >(ptr); - Boolean* val = static_cast< Boolean* > (target); - val->value = json->ToBool(); - } - else if(type.StartsWith(L"String", 0)) { - JsonString* json = static_cast< JsonString* >(ptr); - String* val = static_cast< String* > (target); - val->Clear(); - val->Append(json->GetPointer()); - } - else if(type.StartsWith(L"Integer", 0)) { - JsonNumber* json = static_cast< JsonNumber* >(ptr); - Integer* val = static_cast< Integer* > (target); - *val = json->ToInt(); - } - else if(type.StartsWith(L"Long", 0)) { - JsonNumber* json = static_cast< JsonNumber* >(ptr); - Long* val = static_cast< Long* > (target); - *val = json->ToLong(); - } - else if(type.StartsWith(L"DateTime", 0)) { - JsonString* json = static_cast< JsonString* >(ptr); - String str; - str.Append(json->GetPointer()); +void +jsonToValue(void* target, IJsonValue* ptr, String type, String innerType) { +if(target == null || ptr == null) { +return; +} +if(type.StartsWith(L"Boolean", 0)) { +JsonBool* json = static_cast< JsonBool* >(ptr); +Boolean* val = static_cast< Boolean* > (target); +val->value = json->ToBool(); +} +else if(type.StartsWith(L"String", 0)) { +JsonString* json = static_cast< JsonString* >(ptr); +String* val = static_cast< String* > (target); +val->Clear(); +val->Append(json->GetPointer()); +} +else if(type.StartsWith(L"Integer", 0)) { +JsonNumber* json = static_cast< JsonNumber* >(ptr); +Integer* val = static_cast< Integer* > (target); +*val = json->ToInt(); +} +else if(type.StartsWith(L"Long", 0)) { +JsonNumber* json = static_cast< JsonNumber* >(ptr); +Long* val = static_cast< Long* > (target); +*val = json->ToLong(); +} +else if(type.StartsWith(L"DateTime", 0)) { +JsonString* json = static_cast< JsonString* >(ptr); +String str; +str.Append(json->GetPointer()); - DateTime* val = static_cast< DateTime* > (target); - toISO8601(str, val); - } - else if(type.StartsWith(L"Sami", 0)) { - SamiObject* obj = static_cast< SamiObject* > (target); - obj->fromJsonObject(ptr); - } - else if(type.StartsWith(L"IList", 0)) { - IList* obj = static_cast< IList* >(target); - JsonArray* pJsonArray = static_cast< JsonArray* >(ptr); +DateTime* val = static_cast< DateTime* > (target); +toISO8601(str, val); +} +else if(type.StartsWith(L"Sami", 0)) { +SamiObject* obj = static_cast< SamiObject* > (target); +obj->fromJsonObject(ptr); +} +else if(type.StartsWith(L"IList", 0)) { +IList* obj = static_cast< IList* >(target); +JsonArray* pJsonArray = static_cast< JsonArray* >(ptr); - IEnumeratorT< IJsonValue* >* pEnum = pJsonArray->GetEnumeratorN(); - while (pEnum->MoveNext() == E_SUCCESS) { - IJsonValue* pJsonValue = null; - pEnum->GetCurrent(pJsonValue); - void* updatedTarget = null; - updatedTarget = create(innerType); +IEnumeratorT< IJsonValue* >* pEnum = pJsonArray->GetEnumeratorN(); +while (pEnum->MoveNext() == E_SUCCESS) { +IJsonValue* pJsonValue = null; +pEnum->GetCurrent(pJsonValue); +void* updatedTarget = null; +updatedTarget = create(innerType); - if(updatedTarget != null) { - jsonToValue(updatedTarget, pJsonValue, innerType, L""); - obj->Add((Object*)updatedTarget); - } - } - delete pEnum; - } - } +if(updatedTarget != null) { +jsonToValue(updatedTarget, pJsonValue, innerType, L""); +obj->Add((Object*)updatedTarget); +} +} +delete pEnum; +} +} - Integer* - jsonToInteger(IJsonValue* value) { - if(value == null) - return null; - switch(value->GetType()) { - case JSON_TYPE_STRING: - break; - case JSON_TYPE_NUMBER: { - JsonNumber* number = static_cast< JsonNumber* >(value); - int num = number->ToInt(); - return new Integer(num); - } - case JSON_TYPE_OBJECT: - break; - case JSON_TYPE_ARRAY: - break; - case JSON_TYPE_BOOL: - break; - case JSON_TYPE_NULL: - break; - } - return null; - } +Integer* +jsonToInteger(IJsonValue* value) { +if(value == null) +return null; +switch(value->GetType()) { +case JSON_TYPE_STRING: +break; +case JSON_TYPE_NUMBER: { +JsonNumber* number = static_cast< JsonNumber* >(value); +int num = number->ToInt(); +return new Integer(num); +} +case JSON_TYPE_OBJECT: +break; +case JSON_TYPE_ARRAY: +break; +case JSON_TYPE_BOOL: +break; +case JSON_TYPE_NULL: +break; +} +return null; +} - Long* - jsonToLong(IJsonValue* value) { - if(value == null) - return null; - switch(value->GetType()) { - case JSON_TYPE_STRING: - break; - case JSON_TYPE_NUMBER: { - JsonNumber* number = static_cast< JsonNumber* >(value); - long int num = number->ToLong(); - return new Long(num); - } - case JSON_TYPE_OBJECT: - break; - case JSON_TYPE_ARRAY: - break; - case JSON_TYPE_BOOL: - break; - case JSON_TYPE_NULL: - break; - } - return null; - } +Long* +jsonToLong(IJsonValue* value) { +if(value == null) +return null; +switch(value->GetType()) { +case JSON_TYPE_STRING: +break; +case JSON_TYPE_NUMBER: { +JsonNumber* number = static_cast< JsonNumber* >(value); +long int num = number->ToLong(); +return new Long(num); +} +case JSON_TYPE_OBJECT: +break; +case JSON_TYPE_ARRAY: +break; +case JSON_TYPE_BOOL: +break; +case JSON_TYPE_NULL: +break; +} +return null; +} - String* - jsonToString(IJsonValue* value) { - if(value == null) - return null; - switch(value->GetType()) { - case JSON_TYPE_STRING: { - JsonString* string = static_cast< JsonString* >(value); - return new String(string->GetPointer()); - } - case JSON_TYPE_NUMBER: - break; - case JSON_TYPE_OBJECT: - break; - case JSON_TYPE_ARRAY: - break; - case JSON_TYPE_BOOL: - break; - case JSON_TYPE_NULL: - break; - } - return null; - } +String* +jsonToString(IJsonValue* value) { +if(value == null) +return null; +switch(value->GetType()) { +case JSON_TYPE_STRING: { +JsonString* string = static_cast< JsonString* >(value); +return new String(string->GetPointer()); +} +case JSON_TYPE_NUMBER: +break; +case JSON_TYPE_OBJECT: +break; +case JSON_TYPE_ARRAY: +break; +case JSON_TYPE_BOOL: +break; +case JSON_TYPE_NULL: +break; +} +return null; +} - String - stringify(void* ptr, String type) { - if(type.StartsWith(L"String", 0)) { - String * str = static_cast< String* > (ptr); - return String(str->GetPointer()); - } - if(type.StartsWith(L"Integer", 0)) { - Integer* pInt = static_cast< Integer* > (ptr); - return pInt->ToString(); - } - if(type.StartsWith(L"Long", 0)) { - Long* pLong = static_cast< Long* > (ptr); - return pLong->ToString(); - } - return L""; - } +String +stringify(void* ptr, String type) { +if(type.StartsWith(L"String", 0)) { +String * str = static_cast< String* > (ptr); +return String(str->GetPointer()); +} +if(type.StartsWith(L"Integer", 0)) { +Integer* pInt = static_cast< Integer* > (ptr); +return pInt->ToString(); +} +if(type.StartsWith(L"Long", 0)) { +Long* pLong = static_cast< Long* > (ptr); +return pLong->ToString(); +} +return L""; +} } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiHelpers.h b/samples/client/petstore/tizen/client/SamiHelpers.h index e29eb3cb34b..c7181c6432f 100644 --- a/samples/client/petstore/tizen/client/SamiHelpers.h +++ b/samples/client/petstore/tizen/client/SamiHelpers.h @@ -1,45 +1,50 @@ #ifndef HELPERS_H_ #define HELPERS_H_ -#include -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using Tizen::Base::String; -using Tizen::Base::DateTime; -using namespace Tizen::Web::Json; -using namespace Tizen::Base::Collection; + using Tizen::Base::String; + using Tizen::Base::DateTime; + using namespace Tizen::Web::Json; + using namespace Tizen::Base::Collection; -using Tizen::Base::Long; -using Tizen::Base::DateTime; -using Tizen::Base::String; -using Tizen::Base::Integer; + using Tizen::Base::Long; + using Tizen::Base::DateTime; + using Tizen::Base::String; + using Tizen::Base::Integer; -namespace Swagger { -JsonObject* -toJson(void* v, String type, String containerType); + namespace Swagger { + JsonObject* + toJson(void* v, String type, String containerType); -void -jsonToValue(void* target, IJsonValue* ptr, String type, String innerType); + void + jsonToValue(void* target, IJsonValue* ptr, String type, String innerType); -Integer* -jsonToInteger(IJsonValue* value); + Integer* + jsonToInteger(IJsonValue* value); -Long* -jsonToLong(IJsonValue* value); + Long* + jsonToLong(IJsonValue* value); -String* -jsonToString(IJsonValue* value); + String* + jsonToString(IJsonValue* value); -DateTime* -jsonToDateTime(IJsonValue* value); + DateTime* + jsonToDateTime(IJsonValue* value); -String -stringify(void* ptr, String type); + String + stringify(void* ptr, String type); -} /* namespace Swagger */ -#endif /* HELPERS_H_ */ + } /* namespace Swagger */ + #endif /* HELPERS_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiModelFactory.h b/samples/client/petstore/tizen/client/SamiModelFactory.h index a2e1ab0e0de..6331b2af5c6 100644 --- a/samples/client/petstore/tizen/client/SamiModelFactory.h +++ b/samples/client/petstore/tizen/client/SamiModelFactory.h @@ -3,45 +3,45 @@ #include "SamiObject.h" -#include "SamiUser.h" -#include "SamiCategory.h" -#include "SamiPet.h" -#include "SamiTag.h" -#include "SamiOrder.h" + #include "SamiUser.h" + #include "SamiCategory.h" + #include "SamiPet.h" + #include "SamiTag.h" + #include "SamiOrder.h" namespace Swagger { - void* - create(String type) { - if(type.Equals(L"SamiUser", true)) { - return new SamiUser(); - } - if(type.Equals(L"SamiCategory", true)) { - return new SamiCategory(); - } - if(type.Equals(L"SamiPet", true)) { - return new SamiPet(); - } - if(type.Equals(L"SamiTag", true)) { - return new SamiTag(); - } - if(type.Equals(L"SamiOrder", true)) { - return new SamiOrder(); - } - - if(type.Equals(L"String", true)) { - return new String(); - } - if(type.Equals(L"Integer", true)) { - return new Integer(); - } - if(type.Equals(L"Long", true)) { - return new Long(); - } - if(type.Equals(L"DateTime", true)) { - return new DateTime(); - } - return null; - } +void* +create(String type) { +if(type.Equals(L"SamiUser", true)) { +return new SamiUser(); +} +if(type.Equals(L"SamiCategory", true)) { +return new SamiCategory(); +} +if(type.Equals(L"SamiPet", true)) { +return new SamiPet(); +} +if(type.Equals(L"SamiTag", true)) { +return new SamiTag(); +} +if(type.Equals(L"SamiOrder", true)) { +return new SamiOrder(); +} + +if(type.Equals(L"String", true)) { +return new String(); +} +if(type.Equals(L"Integer", true)) { +return new Integer(); +} +if(type.Equals(L"Long", true)) { +return new Long(); +} +if(type.Equals(L"DateTime", true)) { +return new DateTime(); +} +return null; +} } /* namespace Swagger */ #endif /* ModelFactory_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiObject.h b/samples/client/petstore/tizen/client/SamiObject.h index b0f921205ad..8feefbe3552 100644 --- a/samples/client/petstore/tizen/client/SamiObject.h +++ b/samples/client/petstore/tizen/client/SamiObject.h @@ -1,27 +1,30 @@ #ifndef _Sami_OBJECT_H_ #define _Sami_OBJECT_H_ -#include -#include -#include +#include + + #include + + #include + -using Tizen::Base::String; + using Tizen::Base::String; -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; -class SamiObject { - public: - virtual JsonObject* asJsonObject() { - return null; - } - virtual ~SamiObject() {} - virtual SamiObject* fromJson(String* obj) { - return null; - } - virtual void fromJsonObject(IJsonValue* obj) {} - virtual String asJson() { - return L""; - } -}; + class SamiObject { + public: + virtual JsonObject* asJsonObject() { + return null; + } + virtual ~SamiObject() {} + virtual SamiObject* fromJson(String* obj) { + return null; + } + virtual void fromJsonObject(IJsonValue* obj) {} + virtual String asJson() { + return L""; + } + }; -#endif /* _Sami_OBJECT_H_ */ + #endif /* _Sami_OBJECT_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiOrder.cpp b/samples/client/petstore/tizen/client/SamiOrder.cpp index a319e88e616..f75cb93277d 100644 --- a/samples/client/petstore/tizen/client/SamiOrder.cpp +++ b/samples/client/petstore/tizen/client/SamiOrder.cpp @@ -1,27 +1,28 @@ -#include "SamiOrder.h" -#include + #include "SamiOrder.h" + #include + -using namespace Tizen::Base; -using namespace Tizen::System; -using namespace Tizen::Base::Utility; -using namespace Tizen::Base::Collection; -using namespace Tizen::Web::Json; -using namespace Tizen::Locales; + using namespace Tizen::Base; + using namespace Tizen::System; + using namespace Tizen::Base::Utility; + using namespace Tizen::Base::Collection; + using namespace Tizen::Web::Json; + using namespace Tizen::Locales; -namespace Swagger { + namespace Swagger { -SamiOrder::SamiOrder() { - init(); -} + SamiOrder::SamiOrder() { + init(); + } -SamiOrder::~SamiOrder() { - this->cleanup(); -} + SamiOrder::~SamiOrder() { + this->cleanup(); + } -void -SamiOrder::init() { + void + SamiOrder::init() { pId = null; pPetId = null; pQuantity = null; @@ -29,266 +30,273 @@ SamiOrder::init() { pStatus = null; pComplete = null; -} + } -void -SamiOrder::cleanup() { + void + SamiOrder::cleanup() { if(pId != null) { - - delete pId; - pId = null; - } - if(pPetId != null) { - - delete pPetId; - pPetId = null; - } - if(pQuantity != null) { - - delete pQuantity; - pQuantity = null; - } - if(pShipDate != null) { - - delete pShipDate; - pShipDate = null; - } - if(pStatus != null) { - - delete pStatus; - pStatus = null; - } - if(pComplete != null) { - - delete pComplete; - pComplete = null; - } -} + delete pId; + pId = null; + } + if(pPetId != null) { + + delete pPetId; + pPetId = null; + } + if(pQuantity != null) { + + delete pQuantity; + pQuantity = null; + } + if(pShipDate != null) { + + delete pShipDate; + pShipDate = null; + } + if(pStatus != null) { + + delete pStatus; + pStatus = null; + } + if(pComplete != null) { + + delete pComplete; + pComplete = null; + } + + } -SamiOrder* -SamiOrder::fromJson(String* json) { - this->cleanup(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiOrder* + SamiOrder::fromJson(String* json) { + this->cleanup(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; - return this; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + return this; + } -void -SamiOrder::fromJsonObject(IJsonValue* pJson) { - JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); + void + SamiOrder::fromJsonObject(IJsonValue* pJson) { + JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); - if(pJsonObject != null) { - JsonString* pIdKey = new JsonString(L"id"); + if(pJsonObject != null) { + JsonString* pIdKey = new JsonString(L"id"); IJsonValue* pIdVal = null; pJsonObject->GetValue(pIdKey, pIdVal); if(pIdVal != null) { - - pId = new Long(); - jsonToValue(pId, pIdVal, L"Long", L"Long"); + + pId = new Long(); + jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pPetIdKey = new JsonString(L"petId"); + JsonString* pPetIdKey = new JsonString(L"petId"); IJsonValue* pPetIdVal = null; pJsonObject->GetValue(pPetIdKey, pPetIdVal); if(pPetIdVal != null) { - - pPetId = new Long(); - jsonToValue(pPetId, pPetIdVal, L"Long", L"Long"); + + pPetId = new Long(); + jsonToValue(pPetId, pPetIdVal, L"Long", L"Long"); } delete pPetIdKey; - JsonString* pQuantityKey = new JsonString(L"quantity"); + JsonString* pQuantityKey = new JsonString(L"quantity"); IJsonValue* pQuantityVal = null; pJsonObject->GetValue(pQuantityKey, pQuantityVal); if(pQuantityVal != null) { - - pQuantity = new Integer(); - jsonToValue(pQuantity, pQuantityVal, L"Integer", L"Integer"); + + pQuantity = new Integer(); + jsonToValue(pQuantity, pQuantityVal, L"Integer", L"Integer"); } delete pQuantityKey; - JsonString* pShipDateKey = new JsonString(L"shipDate"); + JsonString* pShipDateKey = new JsonString(L"shipDate"); IJsonValue* pShipDateVal = null; pJsonObject->GetValue(pShipDateKey, pShipDateVal); if(pShipDateVal != null) { - - pShipDate = new DateTime(); - jsonToValue(pShipDate, pShipDateVal, L"DateTime", L"DateTime"); + + pShipDate = new DateTime(); + jsonToValue(pShipDate, pShipDateVal, L"DateTime", L"DateTime"); } delete pShipDateKey; - JsonString* pStatusKey = new JsonString(L"status"); + JsonString* pStatusKey = new JsonString(L"status"); IJsonValue* pStatusVal = null; pJsonObject->GetValue(pStatusKey, pStatusVal); if(pStatusVal != null) { - - pStatus = new String(); - jsonToValue(pStatus, pStatusVal, L"String", L"String"); + + pStatus = new String(); + jsonToValue(pStatus, pStatusVal, L"String", L"String"); } delete pStatusKey; - JsonString* pCompleteKey = new JsonString(L"complete"); + JsonString* pCompleteKey = new JsonString(L"complete"); IJsonValue* pCompleteVal = null; pJsonObject->GetValue(pCompleteKey, pCompleteVal); if(pCompleteVal != null) { - - pComplete = new Boolean(false); - jsonToValue(pComplete, pCompleteVal, L"Boolean", L"Boolean"); + + pComplete = new Boolean(false); + jsonToValue(pComplete, pCompleteVal, L"Boolean", L"Boolean"); } delete pCompleteKey; - - } -} + + } + } -SamiOrder::SamiOrder(String* json) { - init(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiOrder::SamiOrder(String* json) { + init(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + } -String -SamiOrder::asJson () -{ - JsonObject* pJsonObject = asJsonObject(); + String + SamiOrder::asJson () + { + JsonObject* pJsonObject = asJsonObject(); - char *pComposeBuf = new char[256]; - JsonWriter::Compose(pJsonObject, pComposeBuf, 256); - String s = String(pComposeBuf); + char *pComposeBuf = new char[256]; + JsonWriter::Compose(pJsonObject, pComposeBuf, 256); + String s = String(pComposeBuf); - delete pComposeBuf; - pJsonObject->RemoveAll(true); - delete pJsonObject; + delete pComposeBuf; + pJsonObject->RemoveAll(true); + delete pJsonObject; - return s; -} + return s; + } -JsonObject* -SamiOrder::asJsonObject() { - JsonObject *pJsonObject = new JsonObject(); - pJsonObject->Construct(); + JsonObject* + SamiOrder::asJsonObject() { + JsonObject *pJsonObject = new JsonObject(); + pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); - pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); + JsonString *pIdKey = new JsonString(L"id"); + pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pPetIdKey = new JsonString(L"petId"); - pJsonObject->Add(pPetIdKey, toJson(getPPetId(), "Long", "")); + JsonString *pPetIdKey = new JsonString(L"petId"); + pJsonObject->Add(pPetIdKey, toJson(getPPetId(), "Long", "")); - JsonString *pQuantityKey = new JsonString(L"quantity"); - pJsonObject->Add(pQuantityKey, toJson(getPQuantity(), "Integer", "")); + JsonString *pQuantityKey = new JsonString(L"quantity"); + pJsonObject->Add(pQuantityKey, toJson(getPQuantity(), "Integer", "")); - JsonString *pShipDateKey = new JsonString(L"shipDate"); - pJsonObject->Add(pShipDateKey, toJson(getPShipDate(), "DateTime", "")); + JsonString *pShipDateKey = new JsonString(L"shipDate"); + pJsonObject->Add(pShipDateKey, toJson(getPShipDate(), "DateTime", "")); - JsonString *pStatusKey = new JsonString(L"status"); - pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); + JsonString *pStatusKey = new JsonString(L"status"); + pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); - JsonString *pCompleteKey = new JsonString(L"complete"); - pJsonObject->Add(pCompleteKey, toJson(getPComplete(), "Boolean", "")); + JsonString *pCompleteKey = new JsonString(L"complete"); + pJsonObject->Add(pCompleteKey, toJson(getPComplete(), "Boolean", "")); - return pJsonObject; -} + return pJsonObject; + } -Long* -SamiOrder::getPId() { - return pId; -} -void -SamiOrder::setPId(Long* pId) { - this->pId = pId; -} + + Long* + SamiOrder::getPId() { + return pId; + } + void + SamiOrder::setPId(Long* pId) { + this->pId = pId; + } -Long* -SamiOrder::getPPetId() { - return pPetId; -} -void -SamiOrder::setPPetId(Long* pPetId) { - this->pPetId = pPetId; -} + + Long* + SamiOrder::getPPetId() { + return pPetId; + } + void + SamiOrder::setPPetId(Long* pPetId) { + this->pPetId = pPetId; + } -Integer* -SamiOrder::getPQuantity() { - return pQuantity; -} -void -SamiOrder::setPQuantity(Integer* pQuantity) { - this->pQuantity = pQuantity; -} + + Integer* + SamiOrder::getPQuantity() { + return pQuantity; + } + void + SamiOrder::setPQuantity(Integer* pQuantity) { + this->pQuantity = pQuantity; + } -DateTime* -SamiOrder::getPShipDate() { - return pShipDate; -} -void -SamiOrder::setPShipDate(DateTime* pShipDate) { - this->pShipDate = pShipDate; -} + + DateTime* + SamiOrder::getPShipDate() { + return pShipDate; + } + void + SamiOrder::setPShipDate(DateTime* pShipDate) { + this->pShipDate = pShipDate; + } -String* -SamiOrder::getPStatus() { - return pStatus; -} -void -SamiOrder::setPStatus(String* pStatus) { - this->pStatus = pStatus; -} + + String* + SamiOrder::getPStatus() { + return pStatus; + } + void + SamiOrder::setPStatus(String* pStatus) { + this->pStatus = pStatus; + } -Boolean* -SamiOrder::getPComplete() { - return pComplete; -} -void -SamiOrder::setPComplete(Boolean* pComplete) { - this->pComplete = pComplete; -} + + Boolean* + SamiOrder::getPComplete() { + return pComplete; + } + void + SamiOrder::setPComplete(Boolean* pComplete) { + this->pComplete = pComplete; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiOrder.h b/samples/client/petstore/tizen/client/SamiOrder.h index 08b79cc195c..0b13f1723f7 100644 --- a/samples/client/petstore/tizen/client/SamiOrder.h +++ b/samples/client/petstore/tizen/client/SamiOrder.h @@ -1,20 +1,24 @@ /* - * SamiOrder.h - * - * - */ +* SamiOrder.h +* +* +*/ #ifndef SamiOrder_H_ #define SamiOrder_H_ -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; using Tizen::Base::Long; @@ -24,47 +28,47 @@ using Tizen::Base::Boolean; using Tizen::Base::Integer; -namespace Swagger { + namespace Swagger { -class SamiOrder: public SamiObject { -public: + class SamiOrder: public SamiObject { + public: SamiOrder(); SamiOrder(String* json); - virtual ~SamiOrder(); + virtual ~SamiOrder(); - void init(); + void init(); - void cleanup(); + void cleanup(); - String asJson (); + String asJson (); - JsonObject* asJsonObject(); + JsonObject* asJsonObject(); - void fromJsonObject(IJsonValue* json); + void fromJsonObject(IJsonValue* json); SamiOrder* fromJson(String* obj); - Long* getPId(); - void setPId(Long* pId); + Long* getPId(); + void setPId(Long* pId); - Long* getPPetId(); - void setPPetId(Long* pPetId); + Long* getPPetId(); + void setPPetId(Long* pPetId); - Integer* getPQuantity(); - void setPQuantity(Integer* pQuantity); + Integer* getPQuantity(); + void setPQuantity(Integer* pQuantity); - DateTime* getPShipDate(); - void setPShipDate(DateTime* pShipDate); + DateTime* getPShipDate(); + void setPShipDate(DateTime* pShipDate); - String* getPStatus(); - void setPStatus(String* pStatus); + String* getPStatus(); + void setPStatus(String* pStatus); - Boolean* getPComplete(); - void setPComplete(Boolean* pComplete); + Boolean* getPComplete(); + void setPComplete(Boolean* pComplete); -private: + private: Long* pId; Long* pPetId; Integer* pQuantity; @@ -72,8 +76,8 @@ private: String* pStatus; Boolean* pComplete; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiOrder_H_ */ + #endif /* SamiOrder_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiPet.cpp b/samples/client/petstore/tizen/client/SamiPet.cpp index ecf63f060a4..a24dca97441 100644 --- a/samples/client/petstore/tizen/client/SamiPet.cpp +++ b/samples/client/petstore/tizen/client/SamiPet.cpp @@ -1,27 +1,28 @@ -#include "SamiPet.h" -#include + #include "SamiPet.h" + #include + -using namespace Tizen::Base; -using namespace Tizen::System; -using namespace Tizen::Base::Utility; -using namespace Tizen::Base::Collection; -using namespace Tizen::Web::Json; -using namespace Tizen::Locales; + using namespace Tizen::Base; + using namespace Tizen::System; + using namespace Tizen::Base::Utility; + using namespace Tizen::Base::Collection; + using namespace Tizen::Web::Json; + using namespace Tizen::Locales; -namespace Swagger { + namespace Swagger { -SamiPet::SamiPet() { - init(); -} + SamiPet::SamiPet() { + init(); + } -SamiPet::~SamiPet() { - this->cleanup(); -} + SamiPet::~SamiPet() { + this->cleanup(); + } -void -SamiPet::init() { + void + SamiPet::init() { pId = null; pCategory = null; pName = null; @@ -29,266 +30,273 @@ SamiPet::init() { pTags = null; pStatus = null; -} + } -void -SamiPet::cleanup() { + void + SamiPet::cleanup() { if(pId != null) { - - delete pId; - pId = null; - } - if(pCategory != null) { - - delete pCategory; - pCategory = null; - } - if(pName != null) { - - delete pName; - pName = null; - } - if(pPhotoUrls != null) { - pPhotoUrls->RemoveAll(true); - delete pPhotoUrls; - pPhotoUrls = null; - } - if(pTags != null) { - pTags->RemoveAll(true); - delete pTags; - pTags = null; - } - if(pStatus != null) { - - delete pStatus; - pStatus = null; - } -} + delete pId; + pId = null; + } + if(pCategory != null) { + + delete pCategory; + pCategory = null; + } + if(pName != null) { + + delete pName; + pName = null; + } + if(pPhotoUrls != null) { + pPhotoUrls->RemoveAll(true); + delete pPhotoUrls; + pPhotoUrls = null; + } + if(pTags != null) { + pTags->RemoveAll(true); + delete pTags; + pTags = null; + } + if(pStatus != null) { + + delete pStatus; + pStatus = null; + } + + } -SamiPet* -SamiPet::fromJson(String* json) { - this->cleanup(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiPet* + SamiPet::fromJson(String* json) { + this->cleanup(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; - return this; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + return this; + } -void -SamiPet::fromJsonObject(IJsonValue* pJson) { - JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); + void + SamiPet::fromJsonObject(IJsonValue* pJson) { + JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); - if(pJsonObject != null) { - JsonString* pIdKey = new JsonString(L"id"); + if(pJsonObject != null) { + JsonString* pIdKey = new JsonString(L"id"); IJsonValue* pIdVal = null; pJsonObject->GetValue(pIdKey, pIdVal); if(pIdVal != null) { - - pId = new Long(); - jsonToValue(pId, pIdVal, L"Long", L"Long"); + + pId = new Long(); + jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pCategoryKey = new JsonString(L"category"); + JsonString* pCategoryKey = new JsonString(L"category"); IJsonValue* pCategoryVal = null; pJsonObject->GetValue(pCategoryKey, pCategoryVal); if(pCategoryVal != null) { - - pCategory = new SamiCategory(); - jsonToValue(pCategory, pCategoryVal, L"SamiCategory", L"SamiCategory"); + + pCategory = new SamiCategory(); + jsonToValue(pCategory, pCategoryVal, L"SamiCategory", L"SamiCategory"); } delete pCategoryKey; - JsonString* pNameKey = new JsonString(L"name"); + JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { - - pName = new String(); - jsonToValue(pName, pNameVal, L"String", L"String"); + + pName = new String(); + jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls"); + JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls"); IJsonValue* pPhotoUrlsVal = null; pJsonObject->GetValue(pPhotoUrlsKey, pPhotoUrlsVal); if(pPhotoUrlsVal != null) { - pPhotoUrls = new ArrayList(); - - jsonToValue(pPhotoUrls, pPhotoUrlsVal, L"IList", L"String"); + pPhotoUrls = new ArrayList(); + + jsonToValue(pPhotoUrls, pPhotoUrlsVal, L"IList", L"String"); } delete pPhotoUrlsKey; - JsonString* pTagsKey = new JsonString(L"tags"); + JsonString* pTagsKey = new JsonString(L"tags"); IJsonValue* pTagsVal = null; pJsonObject->GetValue(pTagsKey, pTagsVal); if(pTagsVal != null) { - pTags = new ArrayList(); - - jsonToValue(pTags, pTagsVal, L"IList", L"SamiTag"); + pTags = new ArrayList(); + + jsonToValue(pTags, pTagsVal, L"IList", L"SamiTag"); } delete pTagsKey; - JsonString* pStatusKey = new JsonString(L"status"); + JsonString* pStatusKey = new JsonString(L"status"); IJsonValue* pStatusVal = null; pJsonObject->GetValue(pStatusKey, pStatusVal); if(pStatusVal != null) { - - pStatus = new String(); - jsonToValue(pStatus, pStatusVal, L"String", L"String"); + + pStatus = new String(); + jsonToValue(pStatus, pStatusVal, L"String", L"String"); } delete pStatusKey; - - } -} + + } + } -SamiPet::SamiPet(String* json) { - init(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiPet::SamiPet(String* json) { + init(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + } -String -SamiPet::asJson () -{ - JsonObject* pJsonObject = asJsonObject(); + String + SamiPet::asJson () + { + JsonObject* pJsonObject = asJsonObject(); - char *pComposeBuf = new char[256]; - JsonWriter::Compose(pJsonObject, pComposeBuf, 256); - String s = String(pComposeBuf); + char *pComposeBuf = new char[256]; + JsonWriter::Compose(pJsonObject, pComposeBuf, 256); + String s = String(pComposeBuf); - delete pComposeBuf; - pJsonObject->RemoveAll(true); - delete pJsonObject; + delete pComposeBuf; + pJsonObject->RemoveAll(true); + delete pJsonObject; - return s; -} + return s; + } -JsonObject* -SamiPet::asJsonObject() { - JsonObject *pJsonObject = new JsonObject(); - pJsonObject->Construct(); + JsonObject* + SamiPet::asJsonObject() { + JsonObject *pJsonObject = new JsonObject(); + pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); - pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); + JsonString *pIdKey = new JsonString(L"id"); + pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pCategoryKey = new JsonString(L"category"); - pJsonObject->Add(pCategoryKey, toJson(getPCategory(), "SamiCategory", "")); + JsonString *pCategoryKey = new JsonString(L"category"); + pJsonObject->Add(pCategoryKey, toJson(getPCategory(), "SamiCategory", "")); - JsonString *pNameKey = new JsonString(L"name"); - pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); + JsonString *pNameKey = new JsonString(L"name"); + pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls"); - pJsonObject->Add(pPhotoUrlsKey, toJson(getPPhotoUrls(), "String", "array")); + JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls"); + pJsonObject->Add(pPhotoUrlsKey, toJson(getPPhotoUrls(), "String", "array")); - JsonString *pTagsKey = new JsonString(L"tags"); - pJsonObject->Add(pTagsKey, toJson(getPTags(), "SamiTag", "array")); + JsonString *pTagsKey = new JsonString(L"tags"); + pJsonObject->Add(pTagsKey, toJson(getPTags(), "SamiTag", "array")); - JsonString *pStatusKey = new JsonString(L"status"); - pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); + JsonString *pStatusKey = new JsonString(L"status"); + pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); - return pJsonObject; -} + return pJsonObject; + } -Long* -SamiPet::getPId() { - return pId; -} -void -SamiPet::setPId(Long* pId) { - this->pId = pId; -} + + Long* + SamiPet::getPId() { + return pId; + } + void + SamiPet::setPId(Long* pId) { + this->pId = pId; + } -SamiCategory* -SamiPet::getPCategory() { - return pCategory; -} -void -SamiPet::setPCategory(SamiCategory* pCategory) { - this->pCategory = pCategory; -} + + SamiCategory* + SamiPet::getPCategory() { + return pCategory; + } + void + SamiPet::setPCategory(SamiCategory* pCategory) { + this->pCategory = pCategory; + } -String* -SamiPet::getPName() { - return pName; -} -void -SamiPet::setPName(String* pName) { - this->pName = pName; -} + + String* + SamiPet::getPName() { + return pName; + } + void + SamiPet::setPName(String* pName) { + this->pName = pName; + } -IList* -SamiPet::getPPhotoUrls() { - return pPhotoUrls; -} -void -SamiPet::setPPhotoUrls(IList* pPhotoUrls) { - this->pPhotoUrls = pPhotoUrls; -} + + IList* + SamiPet::getPPhotoUrls() { + return pPhotoUrls; + } + void + SamiPet::setPPhotoUrls(IList* pPhotoUrls) { + this->pPhotoUrls = pPhotoUrls; + } -IList* -SamiPet::getPTags() { - return pTags; -} -void -SamiPet::setPTags(IList* pTags) { - this->pTags = pTags; -} + + IList* + SamiPet::getPTags() { + return pTags; + } + void + SamiPet::setPTags(IList* pTags) { + this->pTags = pTags; + } -String* -SamiPet::getPStatus() { - return pStatus; -} -void -SamiPet::setPStatus(String* pStatus) { - this->pStatus = pStatus; -} + + String* + SamiPet::getPStatus() { + return pStatus; + } + void + SamiPet::setPStatus(String* pStatus) { + this->pStatus = pStatus; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiPet.h b/samples/client/petstore/tizen/client/SamiPet.h index a1658248436..d50fcc1915e 100644 --- a/samples/client/petstore/tizen/client/SamiPet.h +++ b/samples/client/petstore/tizen/client/SamiPet.h @@ -1,20 +1,24 @@ /* - * SamiPet.h - * - * - */ +* SamiPet.h +* +* +*/ #ifndef SamiPet_H_ #define SamiPet_H_ -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; #include "SamiCategory.h" @@ -24,47 +28,47 @@ using Tizen::Base::String; using Tizen::Base::Collection::IList; -namespace Swagger { + namespace Swagger { -class SamiPet: public SamiObject { -public: + class SamiPet: public SamiObject { + public: SamiPet(); SamiPet(String* json); - virtual ~SamiPet(); + virtual ~SamiPet(); - void init(); + void init(); - void cleanup(); + void cleanup(); - String asJson (); + String asJson (); - JsonObject* asJsonObject(); + JsonObject* asJsonObject(); - void fromJsonObject(IJsonValue* json); + void fromJsonObject(IJsonValue* json); SamiPet* fromJson(String* obj); - Long* getPId(); - void setPId(Long* pId); + Long* getPId(); + void setPId(Long* pId); - SamiCategory* getPCategory(); - void setPCategory(SamiCategory* pCategory); + SamiCategory* getPCategory(); + void setPCategory(SamiCategory* pCategory); - String* getPName(); - void setPName(String* pName); + String* getPName(); + void setPName(String* pName); - IList* getPPhotoUrls(); - void setPPhotoUrls(IList* pPhotoUrls); + IList* getPPhotoUrls(); + void setPPhotoUrls(IList* pPhotoUrls); - IList* getPTags(); - void setPTags(IList* pTags); + IList* getPTags(); + void setPTags(IList* pTags); - String* getPStatus(); - void setPStatus(String* pStatus); + String* getPStatus(); + void setPStatus(String* pStatus); -private: + private: Long* pId; SamiCategory* pCategory; String* pName; @@ -72,8 +76,8 @@ private: IList* pTags; String* pStatus; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiPet_H_ */ + #endif /* SamiPet_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiPetApi.cpp b/samples/client/petstore/tizen/client/SamiPetApi.cpp index 69997d3cee0..32a53aae42a 100644 --- a/samples/client/petstore/tizen/client/SamiPetApi.cpp +++ b/samples/client/petstore/tizen/client/SamiPetApi.cpp @@ -8,457 +8,466 @@ using namespace Tizen::Base; namespace Swagger { -SamiPetApi::SamiPetApi() { + SamiPetApi::SamiPetApi() { -} - -SamiPetApi::~SamiPetApi() { - -} - -void -updatePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiPetApi::updatePetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&updatePetProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/pet"); - - - - client->execute(SamiPetApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -addPetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiPetApi::addPetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&addPetProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/pet"); - - - - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -findPetsByStatusProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - IList* out = new ArrayList(); - jsonToValue(out, pJson, L"IList*", L"SamiPet"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); + + SamiPetApi::~SamiPetApi() { + } + - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + updatePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } + + void + SamiPetApi::updatePetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&updatePetProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + + + String url(L"/pet"); + + + + client->execute(SamiPetApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } + - } -} + void + addPetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -IList* -SamiPetApi::findPetsByStatusWithCompletion(IList* status, void (* success)(IList*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&findPetsByStatusProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiPetApi::addPetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&addPetProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - - int sz = status->GetCount(); - for(int i = 0; i < sz; i++) { - String itemAt = stringify(status->GetAt(i), "String*"); - queryParams->Add(new String("status"), new String(itemAt)); - } - - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/pet/findByStatus"); + + + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + - + String url(L"/pet"); - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + -void -findPetsByTagsProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - IList* out = new ArrayList(); - jsonToValue(out, pJson, L"IList*", L"SamiPet"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + findPetsByStatusProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + IList* out = new ArrayList(); + jsonToValue(out, pJson, L"IList*", L"SamiPet"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } + + IList* + SamiPetApi::findPetsByStatusWithCompletion(IList* status, void (* success)(IList*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&findPetsByStatusProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + int sz = status->GetCount(); + for(int i = 0; i < sz; i++) { + String itemAt = stringify(status->GetAt(i), "String*"); + queryParams->Add(new String("status"), new String(itemAt)); + } + + + + String* mBody = null; + + + + String url(L"/pet/findByStatus"); + + + + client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } + - } -} + void + findPetsByTagsProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -IList* -SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - client->success(&findPetsByTagsProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + IList* out = new ArrayList(); + jsonToValue(out, pJson, L"IList*", L"SamiPet"); - + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + IList* + SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, SamiError*)) { + client = new SamiApiClient(); - - int sz = tags->GetCount(); - for(int i = 0; i < sz; i++) { - String itemAt = stringify(tags->GetAt(i), "String*"); - queryParams->Add(new String("tags"), new String(itemAt)); - } - - + client->success(&findPetsByTagsProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - String* mBody = null; + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String url(L"/pet/findByTags"); + + int sz = tags->GetCount(); + for(int i = 0; i < sz; i++) { + String itemAt = stringify(tags->GetAt(i), "String*"); + queryParams->Add(new String("tags"), new String(itemAt)); + } + + - + String* mBody = null; - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + -void -getPetByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + String url(L"/pet/findByTags"); - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + - SamiPet* out = new SamiPet(); - jsonToValue(out, pJson, L"SamiPet*", L"SamiPet"); + client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + getPetByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + SamiPet* out = new SamiPet(); + jsonToValue(out, pJson, L"SamiPet*", L"SamiPet"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } + + SamiPet* + SamiPetApi::getPetByIdWithCompletion(Long* petId, void (* success)(SamiPet*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&getPetByIdProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + String url(L"/pet/{petId}"); + + + String s_petId(L"{"); + s_petId.Append(L"petId"); + s_petId.Append(L"}"); + url.Replace(s_petId, stringify(petId, L"Long*")); + + + client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } + - } -} + void + updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -SamiPet* -SamiPetApi::getPetByIdWithCompletion(Long* petId, void (* success)(SamiPet*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&getPetByIdProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiPetApi::updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&updatePetWithFormProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/pet/{petId}"); + - - String s_petId(L"{"); - s_petId.Append(L"petId"); - s_petId.Append(L"}"); - url.Replace(s_petId, stringify(petId, L"Long*")); - + String url(L"/pet/{petId}"); - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + + String s_petId(L"{"); + s_petId.Append(L"petId"); + s_petId.Append(L"}"); + url.Replace(s_petId, stringify(petId, L"String*")); + -void -updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} + void + deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -void -SamiPetApi::updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(*success)(SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&updatePetWithFormProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiPetApi::deletePetWithCompletion(String* apiKey, Long* petId, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + + headerParams->Add(new String("api_key"), apiKey); + + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/pet/{petId}"); + - - String s_petId(L"{"); - s_petId.Append(L"petId"); - s_petId.Append(L"}"); - url.Replace(s_petId, stringify(petId, L"String*")); - + String url(L"/pet/{petId}"); - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} + + String s_petId(L"{"); + s_petId.Append(L"petId"); + s_petId.Append(L"}"); + url.Replace(s_petId, stringify(petId, L"Long*")); + -void -deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiPetApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} + void + uploadFileProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -void -SamiPetApi::deletePetWithCompletion(String* apiKey, Long* petId, void(*success)(SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(*success)(SamiError*)) { + client = new SamiApiClient(); - - headerParams->Add(new String("api_key"), apiKey); - - + client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/pet/{petId}"); + - - String s_petId(L"{"); - s_petId.Append(L"petId"); - s_petId.Append(L"}"); - url.Replace(s_petId, stringify(petId, L"Long*")); - + String url(L"/pet/{petId}/uploadImage"); - client->execute(SamiPetApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} + + String s_petId(L"{"); + s_petId.Append(L"petId"); + s_petId.Append(L"}"); + url.Replace(s_petId, stringify(petId, L"Long*")); + -void -uploadFileProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} - -void -SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/pet/{petId}/uploadImage"); - - - String s_petId(L"{"); - s_petId.Append(L"petId"); - s_petId.Append(L"}"); - url.Replace(s_petId, stringify(petId, L"Long*")); - - - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiPetApi.h b/samples/client/petstore/tizen/client/SamiPetApi.h index 05844bd88bd..ac6d8d61762 100644 --- a/samples/client/petstore/tizen/client/SamiPetApi.h +++ b/samples/client/petstore/tizen/client/SamiPetApi.h @@ -1,58 +1,70 @@ #ifndef SamiPetApi_H_ #define SamiPetApi_H_ -#include -#include "SamiApiClient.h" -#include "SamiError.h" +#include + + #include "SamiApiClient.h" + #include "SamiError.h" -#include "SamiPet.h" -using Tizen::Base::String; -using Tizen::Base::Long; -#include "SamiFile.h" + #include "SamiPet.h" + using Tizen::Base::String; + using Tizen::Base::Long; + #include "SamiFile.h" + -using namespace Tizen::Net::Http; + using namespace Tizen::Net::Http; -namespace Swagger { + namespace Swagger { -class SamiPetApi { -public: - SamiPetApi(); - virtual ~SamiPetApi(); + + class SamiPetApi { + public: + SamiPetApi(); + virtual ~SamiPetApi(); - - void - updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - - void - addPetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - - IList* - findPetsByStatusWithCompletion(IList* status, void (* handler)(IList*, SamiError*)); - - IList* - findPetsByTagsWithCompletion(IList* tags, void (* handler)(IList*, SamiError*)); - - SamiPet* - getPetByIdWithCompletion(Long* petId, void (* handler)(SamiPet*, SamiError*)); - - void - updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(* handler)(SamiError*)); - - void - deletePetWithCompletion(String* apiKey, Long* petId, void(* handler)(SamiError*)); - - void - uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(* handler)(SamiError*)); - - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } + + void + updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); + + void + addPetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); + + IList* + findPetsByStatusWithCompletion(IList* status, void (* handler)(IList* + , SamiError*)); + + IList* + findPetsByTagsWithCompletion(IList* tags, void (* handler)(IList* + , SamiError*)); + + SamiPet* + getPetByIdWithCompletion(Long* petId, void (* handler)(SamiPet* + , SamiError*)); + + void + updatePetWithFormWithCompletion(String* petId + , String* name + , String* status, void(* handler)(SamiError*)); + + void + deletePetWithCompletion(String* apiKey + , Long* petId, void(* handler)(SamiError*)); + + void + uploadFileWithCompletion(Long* petId + , String* additionalMetadata + , SamiFile* file, void(* handler)(SamiError*)); + + static String getBasePath() { + return L"http://petstore.swagger.io/v2"; + } -private: - SamiApiClient* client; -}; + private: + SamiApiClient* client; + }; -} /* namespace Swagger */ + + } /* namespace Swagger */ -#endif /* SamiPetApi_H_ */ + #endif /* SamiPetApi_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.cpp b/samples/client/petstore/tizen/client/SamiStoreApi.cpp index c567896c48d..be4bc6e8782 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.cpp +++ b/samples/client/petstore/tizen/client/SamiStoreApi.cpp @@ -8,258 +8,263 @@ using namespace Tizen::Base; namespace Swagger { -SamiStoreApi::SamiStoreApi() { + SamiStoreApi::SamiStoreApi() { -} - -SamiStoreApi::~SamiStoreApi() { - -} - -void -getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - HashMap* out = new HashMap(); - jsonToValue(out, pJson, L"HashMap*", L"Integer"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); + + SamiStoreApi::~SamiStoreApi() { + } + - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + HashMap* out = new HashMap(); + jsonToValue(out, pJson, L"HashMap*", L"Integer"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } + + HashMap* + SamiStoreApi::getInventoryWithCompletion( void (* success)(HashMap*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&getInventoryProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + String url(L"/store/inventory"); + + + + client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } + - } -} + void + placeOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -HashMap* -SamiStoreApi::getInventoryWithCompletion( void (* success)(HashMap*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - client->success(&getInventoryProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + SamiOrder* out = new SamiOrder(); + jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); - + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + SamiOrder* + SamiStoreApi::placeOrderWithCompletion(SamiOrder* body, void (* success)(SamiOrder*, SamiError*)) { + client = new SamiApiClient(); - + client->success(&placeOrderProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - String* mBody = null; + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String url(L"/store/inventory"); + - + String* mBody = null; - client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + + + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + -void -placeOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + String url(L"/store/order"); - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + - SamiOrder* out = new SamiOrder(); - jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); + client->execute(SamiStoreApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + getOrderByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + SamiOrder* out = new SamiOrder(); + jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } + + SamiOrder* + SamiStoreApi::getOrderByIdWithCompletion(String* orderId, void (* success)(SamiOrder*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&getOrderByIdProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + String url(L"/store/order/{orderId}"); + + + String s_orderId(L"{"); + s_orderId.Append(L"orderId"); + s_orderId.Append(L"}"); + url.Replace(s_orderId, stringify(orderId, L"String*")); + + + client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } + - } -} + void + deleteOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -SamiOrder* -SamiStoreApi::placeOrderWithCompletion(SamiOrder* body, void (* success)(SamiOrder*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&placeOrderProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiStoreApi::deleteOrderWithCompletion(String* orderId, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&deleteOrderProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - + String* mBody = null; - String url(L"/store/order"); + - + String url(L"/store/order/{orderId}"); - client->execute(SamiStoreApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + + String s_orderId(L"{"); + s_orderId.Append(L"orderId"); + s_orderId.Append(L"}"); + url.Replace(s_orderId, stringify(orderId, L"String*")); + -void -getOrderByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiStoreApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - SamiOrder* out = new SamiOrder(); - jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); - - } -} - -SamiOrder* -SamiStoreApi::getOrderByIdWithCompletion(String* orderId, void (* success)(SamiOrder*, SamiError*)) { - client = new SamiApiClient(); - - client->success(&getOrderByIdProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/store/order/{orderId}"); - - - String s_orderId(L"{"); - s_orderId.Append(L"orderId"); - s_orderId.Append(L"}"); - url.Replace(s_orderId, stringify(orderId, L"String*")); - - - client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} - -void -deleteOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiStoreApi::deleteOrderWithCompletion(String* orderId, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&deleteOrderProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/store/order/{orderId}"); - - - String s_orderId(L"{"); - s_orderId.Append(L"orderId"); - s_orderId.Append(L"}"); - url.Replace(s_orderId, stringify(orderId, L"String*")); - - - client->execute(SamiStoreApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.h b/samples/client/petstore/tizen/client/SamiStoreApi.h index a36f4ba6ee9..3f93480d37b 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.h +++ b/samples/client/petstore/tizen/client/SamiStoreApi.h @@ -1,45 +1,52 @@ #ifndef SamiStoreApi_H_ #define SamiStoreApi_H_ -#include -#include "SamiApiClient.h" -#include "SamiError.h" +#include + + #include "SamiApiClient.h" + #include "SamiError.h" -using Tizen::Base::Integer; -#include "SamiOrder.h" -using Tizen::Base::String; + using Tizen::Base::Integer; + #include "SamiOrder.h" + using Tizen::Base::String; + -using namespace Tizen::Net::Http; + using namespace Tizen::Net::Http; -namespace Swagger { + namespace Swagger { -class SamiStoreApi { -public: - SamiStoreApi(); - virtual ~SamiStoreApi(); + + class SamiStoreApi { + public: + SamiStoreApi(); + virtual ~SamiStoreApi(); - - HashMap* - getInventoryWithCompletion( void (* handler)(HashMap*, SamiError*)); - - SamiOrder* - placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder*, SamiError*)); - - SamiOrder* - getOrderByIdWithCompletion(String* orderId, void (* handler)(SamiOrder*, SamiError*)); - - void - deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*)); - - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } + + HashMap* + getInventoryWithCompletion( void (* handler)(HashMap* + , SamiError*)); + + SamiOrder* + placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder* + , SamiError*)); + + SamiOrder* + getOrderByIdWithCompletion(String* orderId, void (* handler)(SamiOrder* + , SamiError*)); + + void + deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*)); + + static String getBasePath() { + return L"http://petstore.swagger.io/v2"; + } -private: - SamiApiClient* client; -}; + private: + SamiApiClient* client; + }; -} /* namespace Swagger */ + + } /* namespace Swagger */ -#endif /* SamiStoreApi_H_ */ + #endif /* SamiStoreApi_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiTag.cpp b/samples/client/petstore/tizen/client/SamiTag.cpp index d07b64a531d..0183a623ce9 100644 --- a/samples/client/petstore/tizen/client/SamiTag.cpp +++ b/samples/client/petstore/tizen/client/SamiTag.cpp @@ -1,182 +1,186 @@ -#include "SamiTag.h" -#include + #include "SamiTag.h" + #include + -using namespace Tizen::Base; -using namespace Tizen::System; -using namespace Tizen::Base::Utility; -using namespace Tizen::Base::Collection; -using namespace Tizen::Web::Json; -using namespace Tizen::Locales; + using namespace Tizen::Base; + using namespace Tizen::System; + using namespace Tizen::Base::Utility; + using namespace Tizen::Base::Collection; + using namespace Tizen::Web::Json; + using namespace Tizen::Locales; -namespace Swagger { + namespace Swagger { -SamiTag::SamiTag() { - init(); -} + SamiTag::SamiTag() { + init(); + } -SamiTag::~SamiTag() { - this->cleanup(); -} + SamiTag::~SamiTag() { + this->cleanup(); + } -void -SamiTag::init() { + void + SamiTag::init() { pId = null; pName = null; -} + } -void -SamiTag::cleanup() { + void + SamiTag::cleanup() { if(pId != null) { - - delete pId; - pId = null; - } - if(pName != null) { - - delete pName; - pName = null; - } -} + delete pId; + pId = null; + } + if(pName != null) { + + delete pName; + pName = null; + } + + } -SamiTag* -SamiTag::fromJson(String* json) { - this->cleanup(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiTag* + SamiTag::fromJson(String* json) { + this->cleanup(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; - return this; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + return this; + } -void -SamiTag::fromJsonObject(IJsonValue* pJson) { - JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); + void + SamiTag::fromJsonObject(IJsonValue* pJson) { + JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); - if(pJsonObject != null) { - JsonString* pIdKey = new JsonString(L"id"); + if(pJsonObject != null) { + JsonString* pIdKey = new JsonString(L"id"); IJsonValue* pIdVal = null; pJsonObject->GetValue(pIdKey, pIdVal); if(pIdVal != null) { - - pId = new Long(); - jsonToValue(pId, pIdVal, L"Long", L"Long"); + + pId = new Long(); + jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pNameKey = new JsonString(L"name"); + JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { - - pName = new String(); - jsonToValue(pName, pNameVal, L"String", L"String"); + + pName = new String(); + jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - - } -} + + } + } -SamiTag::SamiTag(String* json) { - init(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiTag::SamiTag(String* json) { + init(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + } -String -SamiTag::asJson () -{ - JsonObject* pJsonObject = asJsonObject(); + String + SamiTag::asJson () + { + JsonObject* pJsonObject = asJsonObject(); - char *pComposeBuf = new char[256]; - JsonWriter::Compose(pJsonObject, pComposeBuf, 256); - String s = String(pComposeBuf); + char *pComposeBuf = new char[256]; + JsonWriter::Compose(pJsonObject, pComposeBuf, 256); + String s = String(pComposeBuf); - delete pComposeBuf; - pJsonObject->RemoveAll(true); - delete pJsonObject; + delete pComposeBuf; + pJsonObject->RemoveAll(true); + delete pJsonObject; - return s; -} + return s; + } -JsonObject* -SamiTag::asJsonObject() { - JsonObject *pJsonObject = new JsonObject(); - pJsonObject->Construct(); + JsonObject* + SamiTag::asJsonObject() { + JsonObject *pJsonObject = new JsonObject(); + pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); - pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); + JsonString *pIdKey = new JsonString(L"id"); + pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pNameKey = new JsonString(L"name"); - pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); + JsonString *pNameKey = new JsonString(L"name"); + pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - return pJsonObject; -} + return pJsonObject; + } -Long* -SamiTag::getPId() { - return pId; -} -void -SamiTag::setPId(Long* pId) { - this->pId = pId; -} + + Long* + SamiTag::getPId() { + return pId; + } + void + SamiTag::setPId(Long* pId) { + this->pId = pId; + } -String* -SamiTag::getPName() { - return pName; -} -void -SamiTag::setPName(String* pName) { - this->pName = pName; -} + + String* + SamiTag::getPName() { + return pName; + } + void + SamiTag::setPName(String* pName) { + this->pName = pName; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiTag.h b/samples/client/petstore/tizen/client/SamiTag.h index 6521b0a6bed..caf113cc7fe 100644 --- a/samples/client/petstore/tizen/client/SamiTag.h +++ b/samples/client/petstore/tizen/client/SamiTag.h @@ -1,60 +1,64 @@ /* - * SamiTag.h - * - * - */ +* SamiTag.h +* +* +*/ #ifndef SamiTag_H_ #define SamiTag_H_ -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; using Tizen::Base::Long; using Tizen::Base::String; -namespace Swagger { + namespace Swagger { -class SamiTag: public SamiObject { -public: + class SamiTag: public SamiObject { + public: SamiTag(); SamiTag(String* json); - virtual ~SamiTag(); + virtual ~SamiTag(); - void init(); + void init(); - void cleanup(); + void cleanup(); - String asJson (); + String asJson (); - JsonObject* asJsonObject(); + JsonObject* asJsonObject(); - void fromJsonObject(IJsonValue* json); + void fromJsonObject(IJsonValue* json); SamiTag* fromJson(String* obj); - Long* getPId(); - void setPId(Long* pId); + Long* getPId(); + void setPId(Long* pId); - String* getPName(); - void setPName(String* pName); + String* getPName(); + void setPName(String* pName); -private: + private: Long* pId; String* pName; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiTag_H_ */ + #endif /* SamiTag_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiUser.cpp b/samples/client/petstore/tizen/client/SamiUser.cpp index 916bec83d5a..bf89570ffcc 100644 --- a/samples/client/petstore/tizen/client/SamiUser.cpp +++ b/samples/client/petstore/tizen/client/SamiUser.cpp @@ -1,27 +1,28 @@ -#include "SamiUser.h" -#include + #include "SamiUser.h" + #include + -using namespace Tizen::Base; -using namespace Tizen::System; -using namespace Tizen::Base::Utility; -using namespace Tizen::Base::Collection; -using namespace Tizen::Web::Json; -using namespace Tizen::Locales; + using namespace Tizen::Base; + using namespace Tizen::System; + using namespace Tizen::Base::Utility; + using namespace Tizen::Base::Collection; + using namespace Tizen::Web::Json; + using namespace Tizen::Locales; -namespace Swagger { + namespace Swagger { -SamiUser::SamiUser() { - init(); -} + SamiUser::SamiUser() { + init(); + } -SamiUser::~SamiUser() { - this->cleanup(); -} + SamiUser::~SamiUser() { + this->cleanup(); + } -void -SamiUser::init() { + void + SamiUser::init() { pId = null; pUsername = null; pFirstName = null; @@ -31,320 +32,329 @@ SamiUser::init() { pPhone = null; pUserStatus = null; -} + } -void -SamiUser::cleanup() { + void + SamiUser::cleanup() { if(pId != null) { - - delete pId; - pId = null; - } - if(pUsername != null) { - - delete pUsername; - pUsername = null; - } - if(pFirstName != null) { - - delete pFirstName; - pFirstName = null; - } - if(pLastName != null) { - - delete pLastName; - pLastName = null; - } - if(pEmail != null) { - - delete pEmail; - pEmail = null; - } - if(pPassword != null) { - - delete pPassword; - pPassword = null; - } - if(pPhone != null) { - - delete pPhone; - pPhone = null; - } - if(pUserStatus != null) { - - delete pUserStatus; - pUserStatus = null; - } -} + delete pId; + pId = null; + } + if(pUsername != null) { + + delete pUsername; + pUsername = null; + } + if(pFirstName != null) { + + delete pFirstName; + pFirstName = null; + } + if(pLastName != null) { + + delete pLastName; + pLastName = null; + } + if(pEmail != null) { + + delete pEmail; + pEmail = null; + } + if(pPassword != null) { + + delete pPassword; + pPassword = null; + } + if(pPhone != null) { + + delete pPhone; + pPhone = null; + } + if(pUserStatus != null) { + + delete pUserStatus; + pUserStatus = null; + } + + } -SamiUser* -SamiUser::fromJson(String* json) { - this->cleanup(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiUser* + SamiUser::fromJson(String* json) { + this->cleanup(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; - return this; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + return this; + } -void -SamiUser::fromJsonObject(IJsonValue* pJson) { - JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); + void + SamiUser::fromJsonObject(IJsonValue* pJson) { + JsonObject* pJsonObject = static_cast< JsonObject* >(pJson); - if(pJsonObject != null) { - JsonString* pIdKey = new JsonString(L"id"); + if(pJsonObject != null) { + JsonString* pIdKey = new JsonString(L"id"); IJsonValue* pIdVal = null; pJsonObject->GetValue(pIdKey, pIdVal); if(pIdVal != null) { - - pId = new Long(); - jsonToValue(pId, pIdVal, L"Long", L"Long"); + + pId = new Long(); + jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pUsernameKey = new JsonString(L"username"); + JsonString* pUsernameKey = new JsonString(L"username"); IJsonValue* pUsernameVal = null; pJsonObject->GetValue(pUsernameKey, pUsernameVal); if(pUsernameVal != null) { - - pUsername = new String(); - jsonToValue(pUsername, pUsernameVal, L"String", L"String"); + + pUsername = new String(); + jsonToValue(pUsername, pUsernameVal, L"String", L"String"); } delete pUsernameKey; - JsonString* pFirstNameKey = new JsonString(L"firstName"); + JsonString* pFirstNameKey = new JsonString(L"firstName"); IJsonValue* pFirstNameVal = null; pJsonObject->GetValue(pFirstNameKey, pFirstNameVal); if(pFirstNameVal != null) { - - pFirstName = new String(); - jsonToValue(pFirstName, pFirstNameVal, L"String", L"String"); + + pFirstName = new String(); + jsonToValue(pFirstName, pFirstNameVal, L"String", L"String"); } delete pFirstNameKey; - JsonString* pLastNameKey = new JsonString(L"lastName"); + JsonString* pLastNameKey = new JsonString(L"lastName"); IJsonValue* pLastNameVal = null; pJsonObject->GetValue(pLastNameKey, pLastNameVal); if(pLastNameVal != null) { - - pLastName = new String(); - jsonToValue(pLastName, pLastNameVal, L"String", L"String"); + + pLastName = new String(); + jsonToValue(pLastName, pLastNameVal, L"String", L"String"); } delete pLastNameKey; - JsonString* pEmailKey = new JsonString(L"email"); + JsonString* pEmailKey = new JsonString(L"email"); IJsonValue* pEmailVal = null; pJsonObject->GetValue(pEmailKey, pEmailVal); if(pEmailVal != null) { - - pEmail = new String(); - jsonToValue(pEmail, pEmailVal, L"String", L"String"); + + pEmail = new String(); + jsonToValue(pEmail, pEmailVal, L"String", L"String"); } delete pEmailKey; - JsonString* pPasswordKey = new JsonString(L"password"); + JsonString* pPasswordKey = new JsonString(L"password"); IJsonValue* pPasswordVal = null; pJsonObject->GetValue(pPasswordKey, pPasswordVal); if(pPasswordVal != null) { - - pPassword = new String(); - jsonToValue(pPassword, pPasswordVal, L"String", L"String"); + + pPassword = new String(); + jsonToValue(pPassword, pPasswordVal, L"String", L"String"); } delete pPasswordKey; - JsonString* pPhoneKey = new JsonString(L"phone"); + JsonString* pPhoneKey = new JsonString(L"phone"); IJsonValue* pPhoneVal = null; pJsonObject->GetValue(pPhoneKey, pPhoneVal); if(pPhoneVal != null) { - - pPhone = new String(); - jsonToValue(pPhone, pPhoneVal, L"String", L"String"); + + pPhone = new String(); + jsonToValue(pPhone, pPhoneVal, L"String", L"String"); } delete pPhoneKey; - JsonString* pUserStatusKey = new JsonString(L"userStatus"); + JsonString* pUserStatusKey = new JsonString(L"userStatus"); IJsonValue* pUserStatusVal = null; pJsonObject->GetValue(pUserStatusKey, pUserStatusVal); if(pUserStatusVal != null) { - - pUserStatus = new Integer(); - jsonToValue(pUserStatus, pUserStatusVal, L"Integer", L"Integer"); + + pUserStatus = new Integer(); + jsonToValue(pUserStatus, pUserStatusVal, L"Integer", L"Integer"); } delete pUserStatusKey; - - } -} + + } + } -SamiUser::SamiUser(String* json) { - init(); - String str(json->GetPointer()); - int length = str.GetLength(); + SamiUser::SamiUser(String* json) { + init(); + String str(json->GetPointer()); + int length = str.GetLength(); - ByteBuffer buffer; - buffer.Construct(length); + ByteBuffer buffer; + buffer.Construct(length); - for (int i = 0; i < length; ++i) { - byte b = str[i]; - buffer.SetByte(b); - } + for (int i = 0; i < length; ++i) { + byte b = str[i]; + buffer.SetByte(b); + } - IJsonValue* pJson = JsonParser::ParseN(buffer); - fromJsonObject(pJson); - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - delete pJson; -} + IJsonValue* pJson = JsonParser::ParseN(buffer); + fromJsonObject(pJson); + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + delete pJson; + } -String -SamiUser::asJson () -{ - JsonObject* pJsonObject = asJsonObject(); + String + SamiUser::asJson () + { + JsonObject* pJsonObject = asJsonObject(); - char *pComposeBuf = new char[256]; - JsonWriter::Compose(pJsonObject, pComposeBuf, 256); - String s = String(pComposeBuf); + char *pComposeBuf = new char[256]; + JsonWriter::Compose(pJsonObject, pComposeBuf, 256); + String s = String(pComposeBuf); - delete pComposeBuf; - pJsonObject->RemoveAll(true); - delete pJsonObject; + delete pComposeBuf; + pJsonObject->RemoveAll(true); + delete pJsonObject; - return s; -} + return s; + } -JsonObject* -SamiUser::asJsonObject() { - JsonObject *pJsonObject = new JsonObject(); - pJsonObject->Construct(); + JsonObject* + SamiUser::asJsonObject() { + JsonObject *pJsonObject = new JsonObject(); + pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); - pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); + JsonString *pIdKey = new JsonString(L"id"); + pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pUsernameKey = new JsonString(L"username"); - pJsonObject->Add(pUsernameKey, toJson(getPUsername(), "String", "")); + JsonString *pUsernameKey = new JsonString(L"username"); + pJsonObject->Add(pUsernameKey, toJson(getPUsername(), "String", "")); - JsonString *pFirstNameKey = new JsonString(L"firstName"); - pJsonObject->Add(pFirstNameKey, toJson(getPFirstName(), "String", "")); + JsonString *pFirstNameKey = new JsonString(L"firstName"); + pJsonObject->Add(pFirstNameKey, toJson(getPFirstName(), "String", "")); - JsonString *pLastNameKey = new JsonString(L"lastName"); - pJsonObject->Add(pLastNameKey, toJson(getPLastName(), "String", "")); + JsonString *pLastNameKey = new JsonString(L"lastName"); + pJsonObject->Add(pLastNameKey, toJson(getPLastName(), "String", "")); - JsonString *pEmailKey = new JsonString(L"email"); - pJsonObject->Add(pEmailKey, toJson(getPEmail(), "String", "")); + JsonString *pEmailKey = new JsonString(L"email"); + pJsonObject->Add(pEmailKey, toJson(getPEmail(), "String", "")); - JsonString *pPasswordKey = new JsonString(L"password"); - pJsonObject->Add(pPasswordKey, toJson(getPPassword(), "String", "")); + JsonString *pPasswordKey = new JsonString(L"password"); + pJsonObject->Add(pPasswordKey, toJson(getPPassword(), "String", "")); - JsonString *pPhoneKey = new JsonString(L"phone"); - pJsonObject->Add(pPhoneKey, toJson(getPPhone(), "String", "")); + JsonString *pPhoneKey = new JsonString(L"phone"); + pJsonObject->Add(pPhoneKey, toJson(getPPhone(), "String", "")); - JsonString *pUserStatusKey = new JsonString(L"userStatus"); - pJsonObject->Add(pUserStatusKey, toJson(getPUserStatus(), "Integer", "")); + JsonString *pUserStatusKey = new JsonString(L"userStatus"); + pJsonObject->Add(pUserStatusKey, toJson(getPUserStatus(), "Integer", "")); - return pJsonObject; -} + return pJsonObject; + } -Long* -SamiUser::getPId() { - return pId; -} -void -SamiUser::setPId(Long* pId) { - this->pId = pId; -} + + Long* + SamiUser::getPId() { + return pId; + } + void + SamiUser::setPId(Long* pId) { + this->pId = pId; + } -String* -SamiUser::getPUsername() { - return pUsername; -} -void -SamiUser::setPUsername(String* pUsername) { - this->pUsername = pUsername; -} + + String* + SamiUser::getPUsername() { + return pUsername; + } + void + SamiUser::setPUsername(String* pUsername) { + this->pUsername = pUsername; + } -String* -SamiUser::getPFirstName() { - return pFirstName; -} -void -SamiUser::setPFirstName(String* pFirstName) { - this->pFirstName = pFirstName; -} + + String* + SamiUser::getPFirstName() { + return pFirstName; + } + void + SamiUser::setPFirstName(String* pFirstName) { + this->pFirstName = pFirstName; + } -String* -SamiUser::getPLastName() { - return pLastName; -} -void -SamiUser::setPLastName(String* pLastName) { - this->pLastName = pLastName; -} + + String* + SamiUser::getPLastName() { + return pLastName; + } + void + SamiUser::setPLastName(String* pLastName) { + this->pLastName = pLastName; + } -String* -SamiUser::getPEmail() { - return pEmail; -} -void -SamiUser::setPEmail(String* pEmail) { - this->pEmail = pEmail; -} + + String* + SamiUser::getPEmail() { + return pEmail; + } + void + SamiUser::setPEmail(String* pEmail) { + this->pEmail = pEmail; + } -String* -SamiUser::getPPassword() { - return pPassword; -} -void -SamiUser::setPPassword(String* pPassword) { - this->pPassword = pPassword; -} + + String* + SamiUser::getPPassword() { + return pPassword; + } + void + SamiUser::setPPassword(String* pPassword) { + this->pPassword = pPassword; + } -String* -SamiUser::getPPhone() { - return pPhone; -} -void -SamiUser::setPPhone(String* pPhone) { - this->pPhone = pPhone; -} + + String* + SamiUser::getPPhone() { + return pPhone; + } + void + SamiUser::setPPhone(String* pPhone) { + this->pPhone = pPhone; + } -Integer* -SamiUser::getPUserStatus() { - return pUserStatus; -} -void -SamiUser::setPUserStatus(Integer* pUserStatus) { - this->pUserStatus = pUserStatus; -} + + Integer* + SamiUser::getPUserStatus() { + return pUserStatus; + } + void + SamiUser::setPUserStatus(Integer* pUserStatus) { + this->pUserStatus = pUserStatus; + } + + - -} /* namespace Swagger */ + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiUser.h b/samples/client/petstore/tizen/client/SamiUser.h index a874f9c6245..d60b17dea72 100644 --- a/samples/client/petstore/tizen/client/SamiUser.h +++ b/samples/client/petstore/tizen/client/SamiUser.h @@ -1,20 +1,24 @@ /* - * SamiUser.h - * - * - */ +* SamiUser.h +* +* +*/ #ifndef SamiUser_H_ #define SamiUser_H_ -#include -#include -#include -#include -#include "SamiHelpers.h" -#include "SamiObject.h" +#include + + #include + + #include + + #include + + #include "SamiHelpers.h" + #include "SamiObject.h" -using namespace Tizen::Web::Json; + using namespace Tizen::Web::Json; using Tizen::Base::Long; @@ -22,53 +26,53 @@ using Tizen::Base::String; using Tizen::Base::Integer; -namespace Swagger { + namespace Swagger { -class SamiUser: public SamiObject { -public: + class SamiUser: public SamiObject { + public: SamiUser(); SamiUser(String* json); - virtual ~SamiUser(); + virtual ~SamiUser(); - void init(); + void init(); - void cleanup(); + void cleanup(); - String asJson (); + String asJson (); - JsonObject* asJsonObject(); + JsonObject* asJsonObject(); - void fromJsonObject(IJsonValue* json); + void fromJsonObject(IJsonValue* json); SamiUser* fromJson(String* obj); - Long* getPId(); - void setPId(Long* pId); + Long* getPId(); + void setPId(Long* pId); - String* getPUsername(); - void setPUsername(String* pUsername); + String* getPUsername(); + void setPUsername(String* pUsername); - String* getPFirstName(); - void setPFirstName(String* pFirstName); + String* getPFirstName(); + void setPFirstName(String* pFirstName); - String* getPLastName(); - void setPLastName(String* pLastName); + String* getPLastName(); + void setPLastName(String* pLastName); - String* getPEmail(); - void setPEmail(String* pEmail); + String* getPEmail(); + void setPEmail(String* pEmail); - String* getPPassword(); - void setPPassword(String* pPassword); + String* getPPassword(); + void setPPassword(String* pPassword); - String* getPPhone(); - void setPPhone(String* pPhone); + String* getPPhone(); + void setPPhone(String* pPhone); - Integer* getPUserStatus(); - void setPUserStatus(Integer* pUserStatus); + Integer* getPUserStatus(); + void setPUserStatus(Integer* pUserStatus); -private: + private: Long* pId; String* pUsername; String* pFirstName; @@ -78,8 +82,8 @@ private: String* pPhone; Integer* pUserStatus; -}; + }; -} /* namespace Swagger */ + } /* namespace Swagger */ -#endif /* SamiUser_H_ */ + #endif /* SamiUser_H_ */ diff --git a/samples/client/petstore/tizen/client/SamiUserApi.cpp b/samples/client/petstore/tizen/client/SamiUserApi.cpp index 7010ed6bac7..2e277d4d8ba 100644 --- a/samples/client/petstore/tizen/client/SamiUserApi.cpp +++ b/samples/client/petstore/tizen/client/SamiUserApi.cpp @@ -8,454 +8,463 @@ using namespace Tizen::Base; namespace Swagger { -SamiUserApi::SamiUserApi() { + SamiUserApi::SamiUserApi() { -} - -SamiUserApi::~SamiUserApi() { - -} - -void -createUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiUserApi::createUserWithCompletion(SamiUser* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&createUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/user"); - - - - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -createUsersWithArrayInputProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&createUsersWithArrayInputProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - if(body != null) { - mBody = new String(""); - int sz = body->GetCount(); - for(int i = 0; i < sz; i++) { - SamiObject * obj = (SamiObject*)body->GetAt(i); - String json = obj->asJson(); - if(i > 0) - mBody->Append(","); - mBody->Append(json); } - mBody->Append("]"); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/user/createWithArray"); + SamiUserApi::~SamiUserApi() { - - - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -createUsersWithListInputProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&createUsersWithListInputProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - if(body != null) { - mBody = new String(""); - int sz = body->GetCount(); - for(int i = 0; i < sz; i++) { - SamiObject * obj = (SamiObject*)body->GetAt(i); - String json = obj->asJson(); - if(i > 0) - mBody->Append(","); - mBody->Append(json); } - mBody->Append("]"); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/user/createWithList"); - - - - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -loginUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - String* out = new String(); - jsonToValue(out, pJson, L"String*", L"String"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + createUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } + + void + SamiUserApi::createUserWithCompletion(SamiUser* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&createUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + + + String url(L"/user"); + + + + client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } + - } -} + void + createUsersWithArrayInputProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -String* -SamiUserApi::loginUserWithCompletion(String* username, String* password, void (* success)(String*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&loginUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&createUsersWithArrayInputProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - - queryParams->Add(new String("username"), username); - - - queryParams->Add(new String("password"), password); - - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/user/login"); + + + if(body != null) { + mBody = new String(""); + int sz = body->GetCount(); + for(int i = 0; i < sz; i++) { + SamiObject * obj = (SamiObject*)body->GetAt(i); + String json = obj->asJson(); + if(i > 0) + mBody->Append(","); + mBody->Append(json); + } + mBody->Append("]"); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + + - + String url(L"/user/createWithArray"); - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + -void -logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} + void + createUsersWithListInputProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -void -SamiUserApi::logoutUserWithCompletion( void(*success)(SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&logoutUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&createUsersWithListInputProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/user/logout"); + + + if(body != null) { + mBody = new String(""); + int sz = body->GetCount(); + for(int i = 0; i < sz; i++) { + SamiObject * obj = (SamiObject*)body->GetAt(i); + String json = obj->asJson(); + if(i > 0) + mBody->Append(","); + mBody->Append(json); + } + mBody->Append("]"); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + + - + String url(L"/user/createWithList"); - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} + -void -getUserByNameProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - SamiUser* out = new SamiUser(); - jsonToValue(out, pJson, L"SamiUser*", L"SamiUser"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); + void + loginUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + String* out = new String(); + jsonToValue(out, pJson, L"String*", L"String"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } + + String* + SamiUserApi::loginUserWithCompletion(String* username, String* password, void (* success)(String*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&loginUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + queryParams->Add(new String("username"), username); + + + queryParams->Add(new String("password"), password); + + + + String* mBody = null; + + + + String url(L"/user/login"); + + + + client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } + - } -} + void + logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -SamiUser* -SamiUserApi::getUserByNameWithCompletion(String* username, void (* success)(SamiUser*, SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&getUserByNameProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiUserApi::logoutUserWithCompletion( void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&logoutUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/user/{username}"); + - - String s_username(L"{"); - s_username.Append(L"username"); - s_username.Append(L"}"); - url.Replace(s_username, stringify(username, L"String*")); - + String url(L"/user/logout"); - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} + -void -updateUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} + void + getUserByNameProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -void -SamiUserApi::updateUserWithCompletion(String* username, SamiUser* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - client->success(&updateUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + SamiUser* out = new SamiUser(); + jsonToValue(out, pJson, L"SamiUser*", L"SamiUser"); - + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } + } - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + SamiUser* + SamiUserApi::getUserByNameWithCompletion(String* username, void (* success)(SamiUser*, SamiError*)) { + client = new SamiApiClient(); - + client->success(&getUserByNameProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - String* mBody = null; + - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String url(L"/user/{username}"); + - - String s_username(L"{"); - s_username.Append(L"username"); - s_username.Append(L"}"); - url.Replace(s_username, stringify(username, L"String*")); - + String* mBody = null; - client->execute(SamiUserApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} + -void -deleteUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); + String url(L"/user/{username}"); + + + String s_username(L"{"); + s_username.Append(L"username"); + s_username.Append(L"}"); + url.Replace(s_username, stringify(username, L"String*")); + + + client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; + } - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(error, null); - } -} + void + updateUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); -void -SamiUserApi::deleteUserWithCompletion(String* username, void(*success)(SamiError*)) { - client = new SamiApiClient(); + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } - client->success(&deleteUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); + void + SamiUserApi::updateUserWithCompletion(String* username, SamiUser* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); - + client->success(&updateUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); + - + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); - String* mBody = null; + - + String* mBody = null; - String url(L"/user/{username}"); + + + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + - - String s_username(L"{"); - s_username.Append(L"username"); - s_username.Append(L"}"); - url.Replace(s_username, stringify(username, L"String*")); - + String url(L"/user/{username}"); - client->execute(SamiUserApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} + + String s_username(L"{"); + s_username.Append(L"username"); + s_username.Append(L"}"); + url.Replace(s_username, stringify(username, L"String*")); + + client->execute(SamiUserApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } + + + void + deleteUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } + } + + void + SamiUserApi::deleteUserWithCompletion(String* username, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&deleteUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + + String* mBody = null; + + + + String url(L"/user/{username}"); + + + String s_username(L"{"); + s_username.Append(L"username"); + s_username.Append(L"}"); + url.Replace(s_username, stringify(username, L"String*")); + + + client->execute(SamiUserApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + + } + + } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiUserApi.h b/samples/client/petstore/tizen/client/SamiUserApi.h index 1b42e3bc3b1..74f597d9f43 100644 --- a/samples/client/petstore/tizen/client/SamiUserApi.h +++ b/samples/client/petstore/tizen/client/SamiUserApi.h @@ -1,57 +1,65 @@ #ifndef SamiUserApi_H_ #define SamiUserApi_H_ -#include -#include "SamiApiClient.h" -#include "SamiError.h" +#include + + #include "SamiApiClient.h" + #include "SamiError.h" -#include "SamiUser.h" -using Tizen::Base::Collection::IList; -using Tizen::Base::String; + #include "SamiUser.h" + using Tizen::Base::Collection::IList; + using Tizen::Base::String; + -using namespace Tizen::Net::Http; + using namespace Tizen::Net::Http; -namespace Swagger { + namespace Swagger { -class SamiUserApi { -public: - SamiUserApi(); - virtual ~SamiUserApi(); + + class SamiUserApi { + public: + SamiUserApi(); + virtual ~SamiUserApi(); - - void - createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*)); - - void - createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*)); - - void - createUsersWithListInputWithCompletion(IList* body, void(* handler)(SamiError*)); - - String* - loginUserWithCompletion(String* username, String* password, void (* handler)(String*, SamiError*)); - - void - logoutUserWithCompletion( void(* handler)(SamiError*)); - - SamiUser* - getUserByNameWithCompletion(String* username, void (* handler)(SamiUser*, SamiError*)); - - void - updateUserWithCompletion(String* username, SamiUser* body, void(* handler)(SamiError*)); - - void - deleteUserWithCompletion(String* username, void(* handler)(SamiError*)); - - static String getBasePath() { - return L"http://petstore.swagger.io/v2"; - } + + void + createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*)); + + void + createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*)); + + void + createUsersWithListInputWithCompletion(IList* body, void(* handler)(SamiError*)); + + String* + loginUserWithCompletion(String* username + , String* password, void (* handler)(String* + , SamiError*)); + + void + logoutUserWithCompletion( void(* handler)(SamiError*)); + + SamiUser* + getUserByNameWithCompletion(String* username, void (* handler)(SamiUser* + , SamiError*)); + + void + updateUserWithCompletion(String* username + , SamiUser* body, void(* handler)(SamiError*)); + + void + deleteUserWithCompletion(String* username, void(* handler)(SamiError*)); + + static String getBasePath() { + return L"http://petstore.swagger.io/v2"; + } -private: - SamiApiClient* client; -}; + private: + SamiApiClient* client; + }; -} /* namespace Swagger */ + + } /* namespace Swagger */ -#endif /* SamiUserApi_H_ */ + #endif /* SamiUserApi_H_ */ diff --git a/samples/dynamic-html/docs/index.html b/samples/dynamic-html/docs/index.html index 07beb479a6f..c819a83d596 100644 --- a/samples/dynamic-html/docs/index.html +++ b/samples/dynamic-html/docs/index.html @@ -29,82 +29,82 @@
  • Getting Started
  • - - - - - - -
    -
    - StoreApi -
    - -
    - - + + + + + + +
    +
    + StoreApi +
    + +
    + +
    diff --git a/samples/dynamic-html/docs/models/Category.html b/samples/dynamic-html/docs/models/Category.html index e1491c75f21..4c2b1719025 100644 --- a/samples/dynamic-html/docs/models/Category.html +++ b/samples/dynamic-html/docs/models/Category.html @@ -1,14 +1,17 @@ -

    Category

    + -
      -
    • id : Long -
      -
    • -
    - -
      -
    • name : String -
      -
    • -
    - +

    Category

    + +
      +
    • id : Long +
      +
    • +
    + +
      +
    • name : String +
      +
    • +
    + + diff --git a/samples/dynamic-html/docs/models/Order.html b/samples/dynamic-html/docs/models/Order.html index b499b86302f..0f17a843f34 100644 --- a/samples/dynamic-html/docs/models/Order.html +++ b/samples/dynamic-html/docs/models/Order.html @@ -1,38 +1,41 @@ -

    Order

    + -
      -
    • id : Long -
      -
    • -
    - -
      -
    • petId : Long -
      -
    • -
    - -
      -
    • quantity : Integer -
      -
    • -
    - -
      -
    • shipDate : Date -
      -
    • -
    - -
      -
    • status : String -
      Order Status -
    • -
    - -
      -
    • complete : Boolean -
      -
    • -
    - +

    Order

    + +
      +
    • id : Long +
      +
    • +
    + +
      +
    • petId : Long +
      +
    • +
    + +
      +
    • quantity : Integer +
      +
    • +
    + +
      +
    • shipDate : Date +
      +
    • +
    + +
      +
    • status : String +
      Order Status +
    • +
    + +
      +
    • complete : Boolean +
      +
    • +
    + + diff --git a/samples/dynamic-html/docs/models/Pet.html b/samples/dynamic-html/docs/models/Pet.html index ccc786fc630..637ea639490 100644 --- a/samples/dynamic-html/docs/models/Pet.html +++ b/samples/dynamic-html/docs/models/Pet.html @@ -1,38 +1,41 @@ -

    Pet

    + -
      -
    • id : Long -
      -
    • -
    - -
      -
    • category : Category -
      -
    • -
    - -
      -
    • name : String -
      -
    • -
    - -
      -
    • photoUrls : List -
      -
    • -
    - -
      -
    • tags : List -
      -
    • -
    - -
      -
    • status : String -
      pet status in the store -
    • -
    - +

    Pet

    + +
      +
    • id : Long +
      +
    • +
    + +
      +
    • category : Category +
      +
    • +
    + +
      +
    • name : String +
      +
    • +
    + +
      +
    • photoUrls : List +
      +
    • +
    + +
      +
    • tags : List +
      +
    • +
    + +
      +
    • status : String +
      pet status in the store +
    • +
    + + diff --git a/samples/dynamic-html/docs/models/Tag.html b/samples/dynamic-html/docs/models/Tag.html index a9bd72d3351..f41a8ea216d 100644 --- a/samples/dynamic-html/docs/models/Tag.html +++ b/samples/dynamic-html/docs/models/Tag.html @@ -1,14 +1,17 @@ -

    Tag

    + -
      -
    • id : Long -
      -
    • -
    - -
      -
    • name : String -
      -
    • -
    - +

    Tag

    + +
      +
    • id : Long +
      +
    • +
    + +
      +
    • name : String +
      +
    • +
    + + diff --git a/samples/dynamic-html/docs/models/User.html b/samples/dynamic-html/docs/models/User.html index d89a07db636..7fb21a1ce59 100644 --- a/samples/dynamic-html/docs/models/User.html +++ b/samples/dynamic-html/docs/models/User.html @@ -1,50 +1,53 @@ -

    User

    + -
      -
    • id : Long -
      -
    • -
    - -
      -
    • username : String -
      -
    • -
    - -
      -
    • firstName : String -
      -
    • -
    - -
      -
    • lastName : String -
      -
    • -
    - -
      -
    • email : String -
      -
    • -
    - -
      -
    • password : String -
      -
    • -
    - -
      -
    • phone : String -
      -
    • -
    - -
      -
    • userStatus : Integer -
      User Status -
    • -
    - +

    User

    + +
      +
    • id : Long +
      +
    • +
    + +
      +
    • username : String +
      +
    • +
    + +
      +
    • firstName : String +
      +
    • +
    + +
      +
    • lastName : String +
      +
    • +
    + +
      +
    • email : String +
      +
    • +
    + +
      +
    • password : String +
      +
    • +
    + +
      +
    • phone : String +
      +
    • +
    + +
      +
    • userStatus : Integer +
      User Status +
    • +
    + + diff --git a/samples/dynamic-html/docs/operations/PetApi.html b/samples/dynamic-html/docs/operations/PetApi.html index 64a531706da..74ea91f12fd 100644 --- a/samples/dynamic-html/docs/operations/PetApi.html +++ b/samples/dynamic-html/docs/operations/PetApi.html @@ -1,309 +1,309 @@

    -

    This is the API

    - - -

    updatePet

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/pet - -

    HTTP Method

    - PUT - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Body: - body - Pet - -

      Pet object that needs to be added to the store

      -
    • - -
    - -

    addPet

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/pet - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Body: - body - Pet - -

      Pet object that needs to be added to the store

      -
    • - -
    - -

    findPetsByStatus

    -
    -

    - -

    Multiple status values can be provided with comma seperated strings

    - -

    URL

    - http://petstore.swagger.io/v2/pet/findByStatus - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - Query: - - - status - List(String) - -

      Status values that need to be considered for filter

      -
    • - -
    - -

    findPetsByTags

    -
    -

    - -

    Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.

    - -

    URL

    - http://petstore.swagger.io/v2/pet/findByTags - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - Query: - - - tags - List(String) - -

      Tags to filter by

      -
    • - -
    - -

    getPetById

    -
    -

    - -

    Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions

    - -

    URL

    - http://petstore.swagger.io/v2/pet/{petId} - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - - Path: - - - petId - Long - -

      ID of pet that needs to be fetched

      -
    • - -
    - -

    updatePetWithForm

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/pet/{petId} - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Path: - - - petId - String - -

      ID of pet that needs to be updated

      -
    • - -
    • - Form: - - - name - String - -

      Updated name of the pet

      -
    • - -
    • - Form: - - - status - String - -

      Updated status of the pet

      -
    • - -
    - -

    deletePet

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/pet/{petId} - -

    HTTP Method

    - DELETE - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Header: - - apiKey - String - -

      -
    • - -
    • - - - Path: - - - petId - Long - -

      Pet id to delete

      -
    • - -
    - -

    uploadFile

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/pet/{petId}/uploadImage - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Path: - - - petId - Long - -

      ID of pet to update

      -
    • - -
    • - Form: - - - additionalMetadata - String - -

      Additional data to pass to server

      -
    • - -
    • - Form: - - - file - file - -

      file to upload

      -
    • - -
    - - +

    This is the API

    + + + +

    updatePet

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/pet + +

    HTTP Method

    + PUT + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + + Body: + body + Pet + +

      Pet object that needs to be added to the store

      +
    • + +
    + +

    addPet

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/pet + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + + Body: + body + Pet + +

      Pet object that needs to be added to the store

      +
    • + +
    + +

    findPetsByStatus

    +
    +

    +

    Multiple status values can be provided with comma seperated strings

    +

    URL

    + http://petstore.swagger.io/v2/pet/findByStatus + +

    HTTP Method

    + GET + +

    Response Type

    + + +

    Parameters

    +
      + +
    • + + Query: + + + + status + List(String) + +

      Status values that need to be considered for filter

      +
    • + +
    + +

    findPetsByTags

    +
    +

    +

    Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.

    +

    URL

    + http://petstore.swagger.io/v2/pet/findByTags + +

    HTTP Method

    + GET + +

    Response Type

    + + +

    Parameters

    +
      + +
    • + + Query: + + + + tags + List(String) + +

      Tags to filter by

      +
    • + +
    + +

    getPetById

    +
    +

    +

    Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions

    +

    URL

    + http://petstore.swagger.io/v2/pet/{petId} + +

    HTTP Method

    + GET + +

    Response Type

    + + +

    Parameters

    +
      + +
    • + + + Path: + + + petId + Long + +

      ID of pet that needs to be fetched

      +
    • + +
    + +

    updatePetWithForm

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/pet/{petId} + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + Path: + + + petId + String + +

      ID of pet that needs to be updated

      +
    • + +
    • + Form: + + + + + name + String + +

      Updated name of the pet

      +
    • + +
    • + Form: + + + + + status + String + +

      Updated status of the pet

      +
    • + +
    + +

    deletePet

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/pet/{petId} + +

    HTTP Method

    + DELETE + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + Header: + + apiKey + String + +

      +
    • + +
    • + + + Path: + + + petId + Long + +

      Pet id to delete

      +
    • + +
    + +

    uploadFile

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/pet/{petId}/uploadImage + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + Path: + + + petId + Long + +

      ID of pet to update

      +
    • + +
    • + Form: + + + + + additionalMetadata + String + +

      Additional data to pass to server

      +
    • + +
    • + Form: + + + + + file + file + +

      file to upload

      +
    • + +
    + +
    diff --git a/samples/dynamic-html/docs/operations/StoreApi.html b/samples/dynamic-html/docs/operations/StoreApi.html index c35400bbf2a..30d1afafe89 100644 --- a/samples/dynamic-html/docs/operations/StoreApi.html +++ b/samples/dynamic-html/docs/operations/StoreApi.html @@ -1,123 +1,117 @@

    -

    This is the API

    +

    This is the API

    + + +

    getInventory

    +
    +

    +

    Returns a map of status codes to quantities

    +

    URL

    + http://petstore.swagger.io/v2/store/inventory -

    getInventory

    -
    -

    +

    HTTP Method

    + GET -

    Returns a map of status codes to quantities

    +

    Response Type

    -

    URL

    - http://petstore.swagger.io/v2/store/inventory + +

    Parameters

    +
      + +
    + +

    placeOrder

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/store/order -

    HTTP Method

    - GET +

    HTTP Method

    + POST -

    Response Type

    +

    Response Type

    - -

    Parameters

    -
      + +

      Parameters

      +
        + +
      • + + + + + Body: + body + Order + +

        order placed for purchasing the pet

        +
      • + +
      + +

      getOrderById

      +
      +

      +

      For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions

      +

      URL

      + http://petstore.swagger.io/v2/store/order/{orderId} -
    +

    HTTP Method

    + GET -

    placeOrder

    -
    -

    +

    Response Type

    -

    + +

    Parameters

    +
      + +
    • + + + Path: + + + orderId + String + +

      ID of pet that needs to be fetched

      +
    • + +
    + +

    deleteOrder

    +
    +

    +

    For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors

    +

    URL

    + http://petstore.swagger.io/v2/store/order/{orderId} -

    URL

    - http://petstore.swagger.io/v2/store/order - -

    HTTP Method

    - POST - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - - Body: - body - Order - -

      order placed for purchasing the pet

      -
    • - -
    - -

    getOrderById

    -
    -

    - -

    For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions

    - -

    URL

    - http://petstore.swagger.io/v2/store/order/{orderId} - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - - Path: - - - orderId - String - -

      ID of pet that needs to be fetched

      -
    • - -
    - -

    deleteOrder

    -
    -

    - -

    For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API - errors

    - -

    URL

    - http://petstore.swagger.io/v2/store/order/{orderId} - -

    HTTP Method

    - DELETE - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Path: - - - orderId - String - -

      ID of the order that needs to be deleted

      -
    • - -
    +

    HTTP Method

    + DELETE +

    Response Type

    +
    +

    Parameters

    +
      + +
    • + + + Path: + + + orderId + String + +

      ID of the order that needs to be deleted

      +
    • + +
    + +
    diff --git a/samples/dynamic-html/docs/operations/UserApi.html b/samples/dynamic-html/docs/operations/UserApi.html index 9d1548ecddb..e50a483bffa 100644 --- a/samples/dynamic-html/docs/operations/UserApi.html +++ b/samples/dynamic-html/docs/operations/UserApi.html @@ -1,266 +1,261 @@

    -

    This is the API

    - - -

    createUser

    -
    -

    - -

    This can only be done by the logged in user.

    - -

    URL

    - http://petstore.swagger.io/v2/user - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Body: - body - User - -

      Created user object

      -
    • - -
    - -

    createUsersWithArrayInput

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/user/createWithArray - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Body: - body - List - -

      List of user object

      -
    • - -
    - -

    createUsersWithListInput

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/user/createWithList - -

    HTTP Method

    - POST - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Body: - body - List - -

      List of user object

      -
    • - -
    - -

    loginUser

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/user/login - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - Query: - - - username - String - -

      The user name for login

      -
    • - -
    • - - Query: - - - password - String - -

      The password for login in clear text

      -
    • - -
    - -

    logoutUser

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/user/logout - -

    HTTP Method

    - GET - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    - -

    getUserByName

    -
    -

    - -

    - -

    URL

    - http://petstore.swagger.io/v2/user/{username} - -

    HTTP Method

    - GET - -

    Response Type

    - - -

    Parameters

    -
      - -
    • - - - Path: - - - username - String - -

      The name that needs to be fetched. Use user1 for testing.

      -
    • - -
    - -

    updateUser

    -
    -

    - -

    This can only be done by the logged in user.

    - -

    URL

    - http://petstore.swagger.io/v2/user/{username} - -

    HTTP Method

    - PUT - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Path: - - - username - String - -

      name that need to be deleted

      -
    • - -
    • - - - Body: - body - User - -

      Updated user object

      -
    • - -
    - -

    deleteUser

    -
    -

    - -

    This can only be done by the logged in user.

    - -

    URL

    - http://petstore.swagger.io/v2/user/{username} - -

    HTTP Method

    - DELETE - -

    Response Type

    - -
    -

    Parameters

    -
      - -
    • - - - Path: - - - username - String - -

      The name that needs to be deleted

      -
    • - -
    - - +

    This is the API

    + + + +

    createUser

    +
    +

    +

    This can only be done by the logged in user.

    +

    URL

    + http://petstore.swagger.io/v2/user + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + + Body: + body + User + +

      Created user object

      +
    • + +
    + +

    createUsersWithArrayInput

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/user/createWithArray + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + + Body: + body + List + +

      List of user object

      +
    • + +
    + +

    createUsersWithListInput

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/user/createWithList + +

    HTTP Method

    + POST + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + + + Body: + body + List + +

      List of user object

      +
    • + +
    + +

    loginUser

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/user/login + +

    HTTP Method

    + GET + +

    Response Type

    + + +

    Parameters

    +
      + +
    • + + Query: + + + + username + String + +

      The user name for login

      +
    • + +
    • + + Query: + + + + password + String + +

      The password for login in clear text

      +
    • + +
    + +

    logoutUser

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/user/logout + +

    HTTP Method

    + GET + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    + +

    getUserByName

    +
    +

    +

    +

    URL

    + http://petstore.swagger.io/v2/user/{username} + +

    HTTP Method

    + GET + +

    Response Type

    + + +

    Parameters

    +
      + +
    • + + + Path: + + + username + String + +

      The name that needs to be fetched. Use user1 for testing.

      +
    • + +
    + +

    updateUser

    +
    +

    +

    This can only be done by the logged in user.

    +

    URL

    + http://petstore.swagger.io/v2/user/{username} + +

    HTTP Method

    + PUT + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + Path: + + + username + String + +

      name that need to be deleted

      +
    • + +
    • + + + + + Body: + body + User + +

      Updated user object

      +
    • + +
    + +

    deleteUser

    +
    +

    +

    This can only be done by the logged in user.

    +

    URL

    + http://petstore.swagger.io/v2/user/{username} + +

    HTTP Method

    + DELETE + +

    Response Type

    + +
    +

    Parameters

    +
      + +
    • + + + Path: + + + username + String + +

      The name that needs to be deleted

      +
    • + +
    + +
    diff --git a/samples/dynamic-html/package.json b/samples/dynamic-html/package.json index d728e9f0063..b777cfaa602 100644 --- a/samples/dynamic-html/package.json +++ b/samples/dynamic-html/package.json @@ -1,12 +1,12 @@ { - "name": "swagger-docs", - "version": "1.0.0", - "main": "main.js", - "engines": { - "node": ">= 0.8.x" - }, - "dependencies": { - "express": "3.x" - }, - "license": "apache 2.0" +"name": "swagger-docs", +"version": "1.0.0", +"main": "main.js", +"engines": { +"node": ">= 0.8.x" +}, +"dependencies": { +"express": "3.x" +}, +"license": "apache 2.0" } diff --git a/samples/html/index.html b/samples/html/index.html index 3b7afd05af6..32b1469bd71 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -6,1020 +6,999 @@

    Swagger Petstore

    -
    This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use - the api key \"special-key\" to test the authorization filters for -
    +
    This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters for
    -
    Contact Info: apiteam@swagger.io
    -
    Version: 1.0.0
    +
    Contact Info: apiteam@swagger.io
    +
    Version: 1.0.0
    Apache 2.0
    http://www.apache.org/licenses/LICENSE-2.0.html

    Access

    Customize this message as you see fit!

    Methods

    - - -
    -
    -
    put: /pet
    -
    -
    Pet
    -
    updatePet Update an existing pet
    -
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — Pet object that needs to be added - to the store -
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    post: /pet
    -
    -
    Pet
    -
    addPet Add a new pet to the store
    -
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — Pet object that needs to be added - to the store -
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    get: /pet/findByStatus
    -
    -
    Pet
    -
    findPetsByStatus Finds Pets by status
    -
    Multiple status values can be provided with comma seperated strings
    - -

    Parameters

    - -
    -
    status (optional)
    - -
    Query Parameter — Status values that need to be - considered for filter default: available -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    [ {
    -        "tags" : [ {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        } ],
    -        "id" : 123456789,
    -        "category" : {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        },
    -        "status" : "aeiou",
    -        "name" : "doggie",
    -        "photoUrls" : [ "aeiou" ]
    -        } ]
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    <Pet>
    -        <id>123456</id>
    -        <name>doggie</name>
    -        <photoUrls>string</photoUrls>
    -        <status>string</status>
    -        </Pet>
    - -
    - -
    - -
    -
    -
    get: /pet/findByTags
    -
    -
    Pet
    -
    findPetsByTags Finds Pets by tags
    -
    Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for - testing. -
    - -

    Parameters

    - -
    -
    tags (optional)
    - -
    Query Parameter — Tags to filter by
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    [ {
    -        "tags" : [ {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        } ],
    -        "id" : 123456789,
    -        "category" : {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        },
    -        "status" : "aeiou",
    -        "name" : "doggie",
    -        "photoUrls" : [ "aeiou" ]
    -        } ]
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    <Pet>
    -        <id>123456</id>
    -        <name>doggie</name>
    -        <photoUrls>string</photoUrls>
    -        <status>string</status>
    -        </Pet>
    - -
    - -
    - -
    -
    -
    get: /pet/{petId}
    -
    -
    Pet
    -
    getPetById Find pet by ID
    -
    Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error - conditions -
    - -

    Parameters

    - -
    -
    petId (required)
    - -
    Path Parameter — ID of pet that needs to be - fetched -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    {
    -        "tags" : [ {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        } ],
    -        "id" : 123456789,
    -        "category" : {
    -        "id" : 123456789,
    -        "name" : "aeiou"
    -        },
    -        "status" : "aeiou",
    -        "name" : "doggie",
    -        "photoUrls" : [ "aeiou" ]
    -        }
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    <Pet>
    -        <id>123456</id>
    -        <name>doggie</name>
    -        <photoUrls>string</photoUrls>
    -        <status>string</status>
    -        </Pet>
    - -
    - -
    - -
    -
    -
    post: /pet/{petId}
    -
    -
    Pet
    -
    updatePetWithForm Updates a pet in the store with form - data -
    -
    - -

    Parameters

    - -
    -
    petId (required)
    - -
    Path Parameter — ID of pet that needs to be - updated -
    -
    name (optional)
    - -
    Form Parameter — Updated name of the pet
    -
    status (optional)
    - -
    Form Parameter — Updated status of the pet
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    delete: /pet/{petId}
    -
    -
    Pet
    -
    deletePet Deletes a pet
    -
    - -

    Parameters

    - -
    -
    apiKey (optional)
    - -
    Header Parameter
    -
    petId (required)
    - -
    Path Parameter — Pet id to delete
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    post: /pet/{petId}/uploadImage
    -
    -
    Pet
    -
    uploadFile uploads an image
    -
    - -

    Parameters

    - -
    -
    petId (required)
    - -
    Path Parameter — ID of pet to update
    -
    additionalMetadata (optional)
    - -
    Form Parameter — Additional data to pass to server -
    -
    file (optional)
    - -
    Form Parameter — file to upload
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    get: /store/inventory
    -
    -
    Store
    -
    getInventory Returns pet inventories by status
    -
    Returns a map of status codes to quantities
    - -

    Parameters

    - -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    {
    -        "key" : 123
    -        }
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    not implemented io.swagger.models.properties.MapProperty@3e
    - -
    - -
    - -
    -
    -
    post: /store/order
    -
    -
    Store
    -
    placeOrder Place an order for a pet
    -
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — order placed for purchasing the - pet -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    {
    -        "id" : 123456789,
    -        "petId" : 123456789,
    -        "complete" : true,
    -        "status" : "aeiou",
    -        "quantity" : 123,
    -        "shipDate" : "2015-06-07T07:07:24.098+0000"
    -        }
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    <Order>
    -        <id>123456</id>
    -        <petId>123456</petId>
    -        <quantity>0</quantity>
    -        <shipDate>2015-06-07T00:07:24.100Z</shipDate>
    -        <status>string</status>
    -        <complete>true</complete>
    -        </Order>
    - -
    - -
    - -
    -
    -
    get: /store/order/{orderId}
    -
    -
    Store
    -
    getOrderById Find purchase order by ID
    -
    For valid response try integer IDs with value <= 5 or > 10. Other values will - generated exceptions -
    - -

    Parameters

    - -
    -
    orderId (required)
    - -
    Path Parameter — ID of pet that needs to be - fetched -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    {
    -        "id" : 123456789,
    -        "petId" : 123456789,
    -        "complete" : true,
    -        "status" : "aeiou",
    -        "quantity" : 123,
    -        "shipDate" : "2015-06-07T07:07:24.102+0000"
    -        }
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    <Order>
    -        <id>123456</id>
    -        <petId>123456</petId>
    -        <quantity>0</quantity>
    -        <shipDate>2015-06-07T00:07:24.102Z</shipDate>
    -        <status>string</status>
    -        <complete>true</complete>
    -        </Order>
    - -
    - -
    - -
    -
    -
    delete: /store/order/{orderId}
    -
    -
    Store
    -
    deleteOrder Delete purchase order by ID
    -
    For valid response try integer IDs with value < 1000. Anything above 1000 or - nonintegers will generate API errors -
    - -

    Parameters

    - -
    -
    orderId (required)
    - -
    Path Parameter — ID of the order that needs to be - deleted -
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    post: /user
    -
    -
    User
    -
    createUser Create user
    -
    This can only be done by the logged in user.
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — Created user object
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    post: /user/createWithArray
    -
    -
    User
    -
    createUsersWithArrayInput Creates list of users with given - input array -
    -
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — List of user object
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    post: /user/createWithList
    -
    -
    User
    -
    createUsersWithListInput Creates list of users with given - input array -
    -
    - -

    Parameters

    - -
    -
    body (optional)
    - -
    Body Parameter — List of user object
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    get: /user/login
    -
    -
    User
    -
    loginUser Logs user into the system
    -
    - -

    Parameters

    - -
    -
    username (optional)
    - -
    Query Parameter — The user name for login
    -
    password (optional)
    - -
    Query Parameter — The password for login in clear - text -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    "aeiou"
    - -

    Example data

    - -
    Content-Type: application/xml
    -
    string
    - -
    - -
    - -
    -
    -
    get: /user/logout
    -
    -
    User
    -
    logoutUser Logs out current logged in user session
    -
    - -

    Parameters

    - -
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    get: /user/{username}
    -
    -
    User
    -
    getUserByName Get user by user name
    -
    - -

    Parameters

    - -
    -
    username (required)
    - -
    Path Parameter — The name that needs to be - fetched. Use user1 for testing. -
    - -
    - -

    Return type

    - - - - -

    Example data

    - -
    Content-Type: application/json
    -
    {
    -        "id" : 1,
    -        "username" : "johnp",
    -        "firstName" : "John",
    -        "lastName" : "Public",
    -        "email" : "johnp@swagger.io",
    -        "password" : "-secret-",
    -        "phone" : "0123456789",
    -        "userStatus" : 0
    -        }
    - -
    - -
    - -
    -
    -
    put: /user/{username}
    -
    -
    User
    -
    updateUser Updated user
    -
    This can only be done by the logged in user.
    - -

    Parameters

    - -
    -
    username (required)
    - -
    Path Parameter — name that need to be deleted -
    -
    body (optional)
    - -
    Body Parameter — Updated user object
    - -
    - -

    Return type

    - -
    - - -
    - -
    - -
    -
    -
    delete: /user/{username}
    -
    -
    User
    -
    deleteUser Delete user
    -
    This can only be done by the logged in user.
    - -

    Parameters

    - -
    -
    username (required)
    - -
    Path Parameter — The name that needs to be deleted -
    - -
    - -

    Return type

    - -
    - - -
    - -
    - + + +
    +
    +
    put: /pet
    +
    +
    Pet
    +
    updatePet Update an existing pet
    +
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — Pet object that needs to be added to the store
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    post: /pet
    +
    +
    Pet
    +
    addPet Add a new pet to the store
    +
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — Pet object that needs to be added to the store
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    get: /pet/findByStatus
    +
    +
    Pet
    +
    findPetsByStatus Finds Pets by status
    +
    Multiple status values can be provided with comma seperated strings
    + +

    Parameters

    + +
    +
    status (optional)
    + +
    Query Parameter — Status values that need to be considered for filter + default: available
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    [ {
    +  "tags" : [ {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  } ],
    +  "id" : 123456789,
    +  "category" : {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  },
    +  "status" : "aeiou",
    +  "name" : "doggie",
    +  "photoUrls" : [ "aeiou" ]
    +} ]
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    <Pet>
    +  <id>123456</id>
    +  <name>doggie</name>
    +  <photoUrls>string</photoUrls>
    +  <status>string</status>
    +</Pet>
    + +
    + +
    + +
    +
    +
    get: /pet/findByTags
    +
    +
    Pet
    +
    findPetsByTags Finds Pets by tags
    +
    Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
    + +

    Parameters

    + +
    +
    tags (optional)
    + +
    Query Parameter — Tags to filter by
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    [ {
    +  "tags" : [ {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  } ],
    +  "id" : 123456789,
    +  "category" : {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  },
    +  "status" : "aeiou",
    +  "name" : "doggie",
    +  "photoUrls" : [ "aeiou" ]
    +} ]
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    <Pet>
    +  <id>123456</id>
    +  <name>doggie</name>
    +  <photoUrls>string</photoUrls>
    +  <status>string</status>
    +</Pet>
    + +
    + +
    + +
    +
    +
    get: /pet/{petId}
    +
    +
    Pet
    +
    getPetById Find pet by ID
    +
    Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
    + +

    Parameters

    + +
    +
    petId (required)
    + +
    Path Parameter — ID of pet that needs to be fetched
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    {
    +  "tags" : [ {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  } ],
    +  "id" : 123456789,
    +  "category" : {
    +    "id" : 123456789,
    +    "name" : "aeiou"
    +  },
    +  "status" : "aeiou",
    +  "name" : "doggie",
    +  "photoUrls" : [ "aeiou" ]
    +}
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    <Pet>
    +  <id>123456</id>
    +  <name>doggie</name>
    +  <photoUrls>string</photoUrls>
    +  <status>string</status>
    +</Pet>
    + +
    + +
    + +
    +
    +
    post: /pet/{petId}
    +
    +
    Pet
    +
    updatePetWithForm Updates a pet in the store with form data
    +
    + +

    Parameters

    + +
    +
    petId (required)
    + +
    Path Parameter — ID of pet that needs to be updated
    +
    name (optional)
    + +
    Form Parameter — Updated name of the pet
    +
    status (optional)
    + +
    Form Parameter — Updated status of the pet
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    delete: /pet/{petId}
    +
    +
    Pet
    +
    deletePet Deletes a pet
    +
    + +

    Parameters

    + +
    +
    apiKey (optional)
    + +
    Header Parameter
    +
    petId (required)
    + +
    Path Parameter — Pet id to delete
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    post: /pet/{petId}/uploadImage
    +
    +
    Pet
    +
    uploadFile uploads an image
    +
    + +

    Parameters

    + +
    +
    petId (required)
    + +
    Path Parameter — ID of pet to update
    +
    additionalMetadata (optional)
    + +
    Form Parameter — Additional data to pass to server
    +
    file (optional)
    + +
    Form Parameter — file to upload
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    get: /store/inventory
    +
    +
    Store
    +
    getInventory Returns pet inventories by status
    +
    Returns a map of status codes to quantities
    + +

    Parameters

    + +
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    {
    +  "key" : 123
    +}
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    not implemented io.swagger.models.properties.MapProperty@3e
    + +
    + +
    + +
    +
    +
    post: /store/order
    +
    +
    Store
    +
    placeOrder Place an order for a pet
    +
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — order placed for purchasing the pet
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    {
    +  "id" : 123456789,
    +  "petId" : 123456789,
    +  "complete" : true,
    +  "status" : "aeiou",
    +  "quantity" : 123,
    +  "shipDate" : "2015-06-08T03:22:06.881+0000"
    +}
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    <Order>
    +  <id>123456</id>
    +  <petId>123456</petId>
    +  <quantity>0</quantity>
    +  <shipDate>2015-06-07T20:22:06.883Z</shipDate>
    +  <status>string</status>
    +  <complete>true</complete>
    +</Order>
    + +
    + +
    + +
    +
    +
    get: /store/order/{orderId}
    +
    +
    Store
    +
    getOrderById Find purchase order by ID
    +
    For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
    + +

    Parameters

    + +
    +
    orderId (required)
    + +
    Path Parameter — ID of pet that needs to be fetched
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    {
    +  "id" : 123456789,
    +  "petId" : 123456789,
    +  "complete" : true,
    +  "status" : "aeiou",
    +  "quantity" : 123,
    +  "shipDate" : "2015-06-08T03:22:06.884+0000"
    +}
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    <Order>
    +  <id>123456</id>
    +  <petId>123456</petId>
    +  <quantity>0</quantity>
    +  <shipDate>2015-06-07T20:22:06.884Z</shipDate>
    +  <status>string</status>
    +  <complete>true</complete>
    +</Order>
    + +
    + +
    + +
    +
    +
    delete: /store/order/{orderId}
    +
    +
    Store
    +
    deleteOrder Delete purchase order by ID
    +
    For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
    + +

    Parameters

    + +
    +
    orderId (required)
    + +
    Path Parameter — ID of the order that needs to be deleted
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    post: /user
    +
    +
    User
    +
    createUser Create user
    +
    This can only be done by the logged in user.
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — Created user object
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    post: /user/createWithArray
    +
    +
    User
    +
    createUsersWithArrayInput Creates list of users with given input array
    +
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — List of user object
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    post: /user/createWithList
    +
    +
    User
    +
    createUsersWithListInput Creates list of users with given input array
    +
    + +

    Parameters

    + +
    +
    body (optional)
    + +
    Body Parameter — List of user object
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    get: /user/login
    +
    +
    User
    +
    loginUser Logs user into the system
    +
    + +

    Parameters

    + +
    +
    username (optional)
    + +
    Query Parameter — The user name for login
    +
    password (optional)
    + +
    Query Parameter — The password for login in clear text
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    "aeiou"
    + +

    Example data

    + +
    Content-Type: application/xml
    +
    string
    + +
    + +
    + +
    +
    +
    get: /user/logout
    +
    +
    User
    +
    logoutUser Logs out current logged in user session
    +
    + +

    Parameters

    + +
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    get: /user/{username}
    +
    +
    User
    +
    getUserByName Get user by user name
    +
    + +

    Parameters

    + +
    +
    username (required)
    + +
    Path Parameter — The name that needs to be fetched. Use user1 for testing.
    + +
    + +

    Return type

    + + + + +

    Example data

    + +
    Content-Type: application/json
    +
    {
    +  "id" : 1,
    +  "username" : "johnp",
    +  "firstName" : "John",
    +  "lastName" : "Public",
    +  "email" : "johnp@swagger.io",
    +  "password" : "-secret-",
    +  "phone" : "0123456789",
    +  "userStatus" : 0
    +}
    + +
    + +
    + +
    +
    +
    put: /user/{username}
    +
    +
    User
    +
    updateUser Updated user
    +
    This can only be done by the logged in user.
    + +

    Parameters

    + +
    +
    username (required)
    + +
    Path Parameter — name that need to be deleted
    +
    body (optional)
    + +
    Body Parameter — Updated user object
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +
    +
    +
    delete: /user/{username}
    +
    +
    User
    +
    deleteUser Delete user
    +
    This can only be done by the logged in user.
    + +

    Parameters

    + +
    +
    username (required)
    + +
    Path Parameter — The name that needs to be deleted
    + +
    + +

    Return type

    + +
    + + +
    + +
    + +

    Models

    + +
    +

    User

    +
    + +
    id
    +
    Long
    + +
    username
    +
    String
    + +
    firstName
    +
    String
    + +
    lastName
    +
    String
    + +
    email
    +
    String
    + +
    password
    +
    String
    + +
    phone
    +
    String
    + +
    userStatus
    +
    Integer User Status
    + +
    + +
    + + +
    +

    Category

    -
    -

    User

    +
    + +
    id
    +
    Long
    + +
    name
    +
    String
    + +
    + +
    + + +
    +

    Pet

    -
    -
    id
    -
    Long
    -
    username
    -
    String
    -
    firstName
    -
    String
    -
    lastName
    -
    String
    -
    email
    -
    String
    -
    password
    -
    String
    -
    phone
    -
    String
    -
    userStatus
    -
    Integer User Status
    - -
    - -
    - - -
    -

    Category

    - -
    -
    id
    -
    Long
    -
    name
    -
    String
    - -
    - -
    - - -
    -

    Pet

    - -
    -
    id
    -
    Long
    -
    category
    -
    Category
    -
    name
    -
    String
    -
    photoUrls
    -
    array[String]
    -
    tags
    -
    array[Tag]
    -
    status
    -
    String pet status in the store
    - -
    - -
    - - -
    -

    Tag

    - -
    -
    id
    -
    Long
    -
    name
    -
    String
    - -
    - -
    - - -
    -

    Order

    - -
    -
    id
    -
    Long
    -
    petId
    -
    Long
    -
    quantity
    -
    Integer
    -
    shipDate
    -
    Date
    -
    status
    -
    String Order Status
    -
    complete
    -
    Boolean
    - -
    - -
    +
    + +
    id
    +
    Long
    + +
    category
    +
    Category
    + +
    name
    +
    String
    + +
    photoUrls
    +
    array[String]
    + +
    tags
    +
    array[Tag]
    + +
    status
    +
    String pet status in the store
    + +
    + +
    + + +
    +

    Tag

    +
    + +
    id
    +
    Long
    + +
    name
    +
    String
    + +
    + +
    + + +
    +

    Order

    +
    + +
    id
    +
    Long
    + +
    petId
    +
    Long
    + +
    quantity
    +
    Integer
    + +
    shipDate
    +
    Date
    + +
    status
    +
    String Order Status
    + +
    complete
    +
    Boolean
    + +
    + +
    + \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/README.md b/samples/server/petstore/jaxrs/README.md index 3ffa01fb257..4a80e8480a7 100644 --- a/samples/server/petstore/jaxrs/README.md +++ b/samples/server/petstore/jaxrs/README.md @@ -1,7 +1,7 @@ # Swagger generated server ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled scalatra server. diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index e5abc039c9d..9d6ab21491a 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -1,4 +1,4 @@ - 4.0.0 io.swagger @@ -76,7 +76,8 @@ - src/gen/java + + src/gen/java diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java index 212256b8ef5..2dc5e61da1c 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java @@ -1,10 +1,9 @@ package io.swagger.api; -public class ApiException extends Exception { - private int code; - - public ApiException(int code, String msg) { - super(msg); - this.code = code; - } +public class ApiException extends Exception{ +private int code; +public ApiException (int code, String msg) { +super(msg); +this.code = code; +} } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java index cfc93d26260..e72e79a3590 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -1,24 +1,26 @@ package io.swagger.api; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + public class ApiOriginFilter implements javax.servlet.Filter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } +@Override +public void doFilter(ServletRequest request, ServletResponse response, +FilterChain chain) throws IOException, ServletException { +HttpServletResponse res = (HttpServletResponse) response; +res.addHeader("Access-Control-Allow-Origin", "*"); +res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); +res.addHeader("Access-Control-Allow-Headers", "Content-Type"); +chain.doFilter(request, response); +} - @Override - public void destroy() { - } +@Override +public void destroy() { +} - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } +@Override +public void init(FilterConfig filterConfig) throws ServletException { +} } \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java index e148ac150ee..fc0c3879294 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -4,66 +4,65 @@ import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; +public static final int ERROR = 1; +public static final int WARNING = 2; +public static final int INFO = 3; +public static final int OK = 4; +public static final int TOO_BUSY = 5; - int code; - String type; - String message; +int code; +String type; +String message; - public ApiResponseMessage() { - } +public ApiResponseMessage(){} - public ApiResponseMessage(int code, String message) { - this.code = code; - switch (code) { - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } +public ApiResponseMessage(int code, String message){ +this.code = code; +switch(code){ +case ERROR: +setType("error"); +break; +case WARNING: +setType("warning"); +break; +case INFO: +setType("info"); +break; +case OK: +setType("ok"); +break; +case TOO_BUSY: +setType("too busy"); +break; +default: +setType("unknown"); +break; +} +this.message = message; +} + +@XmlTransient +public int getCode() { +return code; +} + +public void setCode(int code) { +this.code = code; +} + +public String getType() { +return type; +} + +public void setType(String type) { +this.type = type; +} + +public String getMessage() { +return message; +} + +public void setMessage(String message) { +this.message = message; +} } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java index 55ddc9fe2a6..7273fd8ad98 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,10 +1,9 @@ package io.swagger.api; public class NotFoundException extends ApiException { - private int code; - - public NotFoundException(int code, String msg) { - super(code, msg); - this.code = code; - } +private int code; +public NotFoundException (int code, String msg) { +super(code, msg); +this.code = code; +} } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java index 74bc46e3c86..74b03664bc1 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -1,145 +1,157 @@ package io.swagger.api; +import io.swagger.model.*; +import io.swagger.api.PetApiService; +import io.swagger.api.factories.PetApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + +import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.multipart.FormDataParam; -import io.swagger.annotations.ApiParam; -import io.swagger.api.NotFoundException; -import io.swagger.api.PetApiService; -import io.swagger.api.factories.PetApiServiceFactory; -import io.swagger.model.Pet; import javax.ws.rs.core.Response; -import java.io.InputStream; -import java.util.List; +import javax.ws.rs.*; @Path("/pet") @io.swagger.annotations.Api(value = "/pet", description = "the pet API") -public class PetApi { + public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); - @PUT - - @Consumes({"application/json", "application/xml"}) - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { + + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"), - + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied")}) - - public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store") Pet body) - throws NotFoundException { + public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { return delegate.updatePet(body); - } + } + + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) - @POST - - @Consumes({"application/json", "application/xml"}) - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input")}) - - public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store") Pet body) - throws NotFoundException { + public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { return delegate.addPet(body); - } - - @GET - @Path("/findByStatus") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/findByStatus") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value")}) - - public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @QueryParam("status") List status) - throws NotFoundException { + public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status) + throws NotFoundException { return delegate.findPetsByStatus(status); - } - - @GET - @Path("/findByTags") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/findByTags") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value")}) - - public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) - throws NotFoundException { + public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) + throws NotFoundException { return delegate.findPetsByTags(tags); - } - - @GET - @Path("/{petId}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), - + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied")}) - - public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathParam("petId") Long petId) - throws NotFoundException { + public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId) + throws NotFoundException { return delegate.getPetById(petId); + } + + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) + + public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId, + @ApiParam(value = "Updated name of the pet" )@FormParam("name") String name, + @ApiParam(value = "Updated status of the pet" )@FormParam("status") String status) + throws NotFoundException { + return delegate.updatePetWithForm(petId,name,status); + } + + @DELETE + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") }) + + public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey, + @ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId) + throws NotFoundException { + return delegate.deletePet(apiKey,petId); + } + + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId, + @ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata, + @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, +@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) + throws NotFoundException { + return delegate.uploadFile(petId,additionalMetadata,fileDetail); + } + } - @POST - @Path("/{petId}") - @Consumes({"application/x-www-form-urlencoded"}) - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input")}) - - public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathParam("petId") String petId, - @ApiParam(value = "Updated name of the pet") @FormParam("name") String name, - @ApiParam(value = "Updated status of the pet") @FormParam("status") String status) - throws NotFoundException { - return delegate.updatePetWithForm(petId, name, status); - } - - @DELETE - @Path("/{petId}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value")}) - - public Response deletePet(@ApiParam(value = "") @HeaderParam("api_key") String apiKey, - @ApiParam(value = "Pet id to delete", required = true) @PathParam("petId") Long petId) - throws NotFoundException { - return delegate.deletePet(apiKey, petId); - } - - @POST - @Path("/{petId}/uploadImage") - @Consumes({"multipart/form-data"}) - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation")}) - - public Response uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathParam("petId") Long petId, - @ApiParam(value = "Additional data to pass to server") @FormParam("additionalMetadata") String additionalMetadata, - @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, - @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) - throws NotFoundException { - return delegate.uploadFile(petId, additionalMetadata, fileDetail); - } -} - diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java index 32528a0f383..801c8eab4cc 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -1,37 +1,47 @@ package io.swagger.api; -import com.sun.jersey.core.header.FormDataContentDisposition; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; -public abstract class PetApiService { - - public abstract Response updatePet(Pet body) - throws NotFoundException; - - public abstract Response addPet(Pet body) - throws NotFoundException; - - public abstract Response findPetsByStatus(List status) - throws NotFoundException; - - public abstract Response findPetsByTags(List tags) - throws NotFoundException; - - public abstract Response getPetById(Long petId) - throws NotFoundException; - - public abstract Response updatePetWithForm(String petId, String name, String status) - throws NotFoundException; - - public abstract Response deletePet(String apiKey, Long petId) - throws NotFoundException; - - public abstract Response uploadFile(Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) - throws NotFoundException; - -} + public abstract class PetApiService { + + public abstract Response updatePet(Pet body) + throws NotFoundException; + + public abstract Response addPet(Pet body) + throws NotFoundException; + + public abstract Response findPetsByStatus(List status) + throws NotFoundException; + + public abstract Response findPetsByTags(List tags) + throws NotFoundException; + + public abstract Response getPetById(Long petId) + throws NotFoundException; + + public abstract Response updatePetWithForm(String petId,String name,String status) + throws NotFoundException; + + public abstract Response deletePet(String apiKey,Long petId) + throws NotFoundException; + + public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) + throws NotFoundException; + + } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java index cffc0dc6040..8684ac669a0 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java @@ -1,79 +1,95 @@ package io.swagger.api; -import io.swagger.annotations.ApiParam; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; import io.swagger.api.StoreApiService; import io.swagger.api.factories.StoreApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; import io.swagger.model.Order; +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + import javax.ws.rs.core.Response; +import javax.ws.rs.*; @Path("/store") @io.swagger.annotations.Api(value = "/store", description = "the store API") -public class StoreApi { + public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); - @GET - @Path("/inventory") + + @GET + @Path("/inventory") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") }) - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation")}) - - public Response getInventory() - throws NotFoundException { + public Response getInventory() + throws NotFoundException { return delegate.getInventory(); - } - - @POST - @Path("/order") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @POST + @Path("/order") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order")}) - - public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet") Order body) - throws NotFoundException { + public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body) + throws NotFoundException { return delegate.placeOrder(body); - } - - @GET - @Path("/order/{orderId}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), - + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied")}) - - public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathParam("orderId") String orderId) - throws NotFoundException { + public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId) + throws NotFoundException { return delegate.getOrderById(orderId); - } - - @DELETE - @Path("/order/{orderId}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @DELETE + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied")}) - - public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathParam("orderId") String orderId) - throws NotFoundException { + public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId) + throws NotFoundException { return delegate.deleteOrder(orderId); + } + } -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java index 6d997ec73b6..876af9cd73c 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java @@ -1,23 +1,35 @@ package io.swagger.api; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; import io.swagger.model.Order; +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + import javax.ws.rs.core.Response; -public abstract class StoreApiService { - - public abstract Response getInventory() - throws NotFoundException; - - public abstract Response placeOrder(Order body) - throws NotFoundException; - - public abstract Response getOrderById(String orderId) - throws NotFoundException; - - public abstract Response deleteOrder(String orderId) - throws NotFoundException; - -} + public abstract class StoreApiService { + + public abstract Response getInventory() + throws NotFoundException; + + public abstract Response placeOrder(Order body) + throws NotFoundException; + + public abstract Response getOrderById(String orderId) + throws NotFoundException; + + public abstract Response deleteOrder(String orderId) + throws NotFoundException; + + } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java index 79b974a4089..b35e5b078a3 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java @@ -1,136 +1,151 @@ package io.swagger.api; -import io.swagger.annotations.ApiParam; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; import io.swagger.api.UserApiService; import io.swagger.api.factories.UserApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; +import javax.ws.rs.*; @Path("/user") @io.swagger.annotations.Api(value = "/user", description = "the user API") -public class UserApi { + public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); - @POST + + @POST + + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation")}) - - public Response createUser(@ApiParam(value = "Created user object") User body) - throws NotFoundException { + public Response createUser(@ApiParam(value = "Created user object" ) User body) + throws NotFoundException { return delegate.createUser(body); - } + } + + @POST + @Path("/createWithArray") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - @POST - @Path("/createWithArray") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation")}) - - public Response createUsersWithArrayInput(@ApiParam(value = "List of user object") List body) - throws NotFoundException { + public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { return delegate.createUsersWithArrayInput(body); - } + } + + @POST + @Path("/createWithList") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - @POST - @Path("/createWithList") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation")}) - - public Response createUsersWithListInput(@ApiParam(value = "List of user object") List body) - throws NotFoundException { + public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { return delegate.createUsersWithListInput(body); - } - - @GET - @Path("/login") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/login") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied")}) + public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username, + @ApiParam(value = "The password for login in clear text") @QueryParam("password") String password) + throws NotFoundException { + return delegate.loginUser(username,password); + } + + @GET + @Path("/logout") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username, - @ApiParam(value = "The password for login in clear text") @QueryParam("password") String password) - throws NotFoundException { - return delegate.loginUser(username, password); - } - - @GET - @Path("/logout") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation")}) - - public Response logoutUser() - throws NotFoundException { + public Response logoutUser() + throws NotFoundException { return delegate.logoutUser(); - } - - @GET - @Path("/{username}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @GET + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), - + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied")}) - - public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ", required = true) @PathParam("username") String username) - throws NotFoundException { + public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username) + throws NotFoundException { return delegate.getUserByName(username); - } - - @PUT - @Path("/{username}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { + } + + @PUT + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied")}) - - public Response updateUser(@ApiParam(value = "name that need to be deleted", required = true) @PathParam("username") String username, - @ApiParam(value = "Updated user object") User body) - throws NotFoundException { - return delegate.updateUser(username, body); - } - - @DELETE - @Path("/{username}") - - @Produces({"application/json", "application/xml"}) - @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { + public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username, + @ApiParam(value = "Updated user object" ) User body) + throws NotFoundException { + return delegate.updateUser(username,body); + } + + @DELETE + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied")}) - - public Response deleteUser(@ApiParam(value = "The name that needs to be deleted", required = true) @PathParam("username") String username) - throws NotFoundException { + public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username) + throws NotFoundException { return delegate.deleteUser(username); + } + } -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java index eaa4ff9c0f1..2b8e79a5c79 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java @@ -1,36 +1,47 @@ package io.swagger.api; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; -public abstract class UserApiService { - - public abstract Response createUser(User body) - throws NotFoundException; - - public abstract Response createUsersWithArrayInput(List body) - throws NotFoundException; - - public abstract Response createUsersWithListInput(List body) - throws NotFoundException; - - public abstract Response loginUser(String username, String password) - throws NotFoundException; - - public abstract Response logoutUser() - throws NotFoundException; - - public abstract Response getUserByName(String username) - throws NotFoundException; - - public abstract Response updateUser(String username, User body) - throws NotFoundException; - - public abstract Response deleteUser(String username) - throws NotFoundException; - -} + public abstract class UserApiService { + + public abstract Response createUser(User body) + throws NotFoundException; + + public abstract Response createUsersWithArrayInput(List body) + throws NotFoundException; + + public abstract Response createUsersWithListInput(List body) + throws NotFoundException; + + public abstract Response loginUser(String username,String password) + throws NotFoundException; + + public abstract Response logoutUser() + throws NotFoundException; + + public abstract Response getUserByName(String username) + throws NotFoundException; + + public abstract Response updateUser(String username,User body) + throws NotFoundException; + + public abstract Response deleteUser(String username) + throws NotFoundException; + + } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java index 8475e04680a..9ca416a8734 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java @@ -1,50 +1,51 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Category { + + private Long id = null; + private String name = null; -@ApiModel(description = "") -public class Category { - - private Long id = null; - private String name = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java index a9513d080a9..5069ecfb5d5 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java @@ -1,112 +1,112 @@ package io.swagger.model; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.Date; +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; -@ApiModel(description = "") -public class Order { + + @ApiModel(description = "") + public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + private StatusEnum status = null; + private Boolean complete = null; - private Long id = null; - private Long petId = null; - private Integer quantity = null; - private Date shipDate = null; - private StatusEnum status = null; - - ; - private Boolean complete = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("petId") - public Long getPetId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("petId") + public Long getPetId() { return petId; - } - - public void setPetId(Long petId) { + } + public void setPetId(Long petId) { this.petId = petId; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("quantity") - public Integer getQuantity() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("quantity") + public Integer getQuantity() { return quantity; - } - - public void setQuantity(Integer quantity) { + } + public void setQuantity(Integer quantity) { this.quantity = quantity; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("shipDate") - public Date getShipDate() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("shipDate") + public Date getShipDate() { return shipDate; - } - - public void setShipDate(Date shipDate) { + } + public void setShipDate(Date shipDate) { this.shipDate = shipDate; - } + } - /** - * Order Status - **/ - @ApiModelProperty(value = "Order Status") - @JsonProperty("status") - public StatusEnum getStatus() { + + /** + * Order Status + **/ + @ApiModelProperty(value = "Order Status") + @JsonProperty("status") + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("complete") - public Boolean getComplete() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("complete") + public Boolean getComplete() { return complete; - } - - public void setComplete(Boolean complete) { + } + public void setComplete(Boolean complete) { this.complete = complete; - } + } + + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - - public enum StatusEnum { - placed, approved, delivered, } -} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java index 93adbdca7b6..54d2453a773 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java @@ -1,115 +1,114 @@ package io.swagger.model; -import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.model.Category; import io.swagger.model.Tag; +import java.util.*; -import java.util.ArrayList; -import java.util.List; +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList() ; + private List tags = new ArrayList() ; + public enum StatusEnum { + available, pending, sold, + }; + private StatusEnum status = null; -@ApiModel(description = "") -public class Pet { - - private Long id = null; - private Category category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - private StatusEnum status = null; - - ; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("category") - public Category getCategory() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("category") + public Category getCategory() { return category; - } - - public void setCategory(Category category) { + } + public void setCategory(Category category) { this.category = category; - } + } - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { return photoUrls; - } - - public void setPhotoUrls(List photoUrls) { + } + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("tags") - public List getTags() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("tags") + public List getTags() { return tags; - } - - public void setTags(List tags) { + } + public void setTags(List tags) { this.tags = tags; - } + } - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } + } + + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - - public enum StatusEnum { - available, pending, sold, } -} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java index 3b745b11ea4..814c2d5b6c3 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java @@ -1,50 +1,51 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Tag { + + private Long id = null; + private String name = null; -@ApiModel(description = "") -public class Tag { - - private Long id = null; - private String name = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java index 0f4a3fde3e7..9caa8ec5a17 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java @@ -1,141 +1,136 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; -@ApiModel(description = "") -public class User { - - private Long id = null; - private String username = null; - private String firstName = null; - private String lastName = null; - private String email = null; - private String password = null; - private String phone = null; - private Integer userStatus = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("username") - public String getUsername() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("username") + public String getUsername() { return username; - } - - public void setUsername(String username) { + } + public void setUsername(String username) { this.username = username; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("firstName") - public String getFirstName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("firstName") + public String getFirstName() { return firstName; - } - - public void setFirstName(String firstName) { + } + public void setFirstName(String firstName) { this.firstName = firstName; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("lastName") - public String getLastName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("lastName") + public String getLastName() { return lastName; - } - - public void setLastName(String lastName) { + } + public void setLastName(String lastName) { this.lastName = lastName; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("email") - public String getEmail() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("email") + public String getEmail() { return email; - } - - public void setEmail(String email) { + } + public void setEmail(String email) { this.email = email; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("password") - public String getPassword() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("password") + public String getPassword() { return password; - } - - public void setPassword(String password) { + } + public void setPassword(String password) { this.password = password; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("phone") - public String getPhone() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("phone") + public String getPhone() { return phone; - } - - public void setPhone(String phone) { + } + public void setPhone(String phone) { this.phone = phone; - } + } - - /** - * User Status - **/ - @ApiModelProperty(value = "User Status") - @JsonProperty("userStatus") - public Integer getUserStatus() { + + /** + * User Status + **/ + @ApiModelProperty(value = "User Status") + @JsonProperty("userStatus") + public Integer getUserStatus() { return userStatus; - } - - public void setUserStatus(Integer userStatus) { + } + public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/server/petstore/jaxrs/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/jaxrs/src/main/webapp/WEB-INF/web.xml index 6f41497e5cd..efb853a2696 100644 --- a/samples/server/petstore/jaxrs/src/main/webapp/WEB-INF/web.xml +++ b/samples/server/petstore/jaxrs/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,7 @@ - + jersey diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index d3825616ece..1cb9510694f 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -1,4 +1,4 @@ - 4.0.0 io.swagger diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java index 212256b8ef5..2dc5e61da1c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java @@ -1,10 +1,9 @@ package io.swagger.api; -public class ApiException extends Exception { - private int code; - - public ApiException(int code, String msg) { - super(msg); - this.code = code; - } +public class ApiException extends Exception{ +private int code; +public ApiException (int code, String msg) { +super(msg); +this.code = code; +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java index cfc93d26260..e72e79a3590 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -1,24 +1,26 @@ package io.swagger.api; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + public class ApiOriginFilter implements javax.servlet.Filter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } +@Override +public void doFilter(ServletRequest request, ServletResponse response, +FilterChain chain) throws IOException, ServletException { +HttpServletResponse res = (HttpServletResponse) response; +res.addHeader("Access-Control-Allow-Origin", "*"); +res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); +res.addHeader("Access-Control-Allow-Headers", "Content-Type"); +chain.doFilter(request, response); +} - @Override - public void destroy() { - } +@Override +public void destroy() { +} - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } +@Override +public void init(FilterConfig filterConfig) throws ServletException { +} } \ No newline at end of file diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java index e148ac150ee..fc0c3879294 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -4,66 +4,65 @@ import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; +public static final int ERROR = 1; +public static final int WARNING = 2; +public static final int INFO = 3; +public static final int OK = 4; +public static final int TOO_BUSY = 5; - int code; - String type; - String message; +int code; +String type; +String message; - public ApiResponseMessage() { - } +public ApiResponseMessage(){} - public ApiResponseMessage(int code, String message) { - this.code = code; - switch (code) { - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } +public ApiResponseMessage(int code, String message){ +this.code = code; +switch(code){ +case ERROR: +setType("error"); +break; +case WARNING: +setType("warning"); +break; +case INFO: +setType("info"); +break; +case OK: +setType("ok"); +break; +case TOO_BUSY: +setType("too busy"); +break; +default: +setType("unknown"); +break; +} +this.message = message; +} + +@XmlTransient +public int getCode() { +return code; +} + +public void setCode(int code) { +this.code = code; +} + +public String getType() { +return type; +} + +public void setType(String type) { +this.type = type; +} + +public String getMessage() { +return message; +} + +public void setMessage(String message) { +this.message = message; +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java index 55ddc9fe2a6..7273fd8ad98 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java @@ -1,10 +1,9 @@ package io.swagger.api; public class NotFoundException extends ApiException { - private int code; - - public NotFoundException(int code, String msg) { - super(code, msg); - this.code = code; - } +private int code; +public NotFoundException (int code, String msg) { +super(code, msg); +this.code = code; +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 51b08ec977f..571e408814c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -1,15 +1,21 @@ package io.swagger.api; +import io.swagger.model.*; + +import io.swagger.model.Pet; +import java.io.File; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import io.swagger.model.Pet; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -24,156 +30,166 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/pet", description = "the pet API") -public class PetApi { + public class PetApi { + - - @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) - @ApiResponses(value = { + @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 405, message = "Validation exception"), @ApiResponse(code = 404, message = "Pet not found"), - @ApiResponse(code = 400, message = "Invalid ID supplied")}) - @RequestMapping(value = "", - produces = {"application/json", "application/xml"}, - consumes = {"application/json", "application/xml"}, - method = RequestMethod.PUT) - public ResponseEntity updatePet( + @ApiResponse(code = 400, message = "Invalid ID supplied") }) + @RequestMapping(value = "", + produces = { "application/json", "application/xml" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.PUT) + public ResponseEntity updatePet( - @ApiParam(value = "Pet object that needs to be added to the store") Pet body) - throws NotFoundException { +@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input")}) - @RequestMapping(value = "", - produces = {"application/json", "application/xml"}, - consumes = {"application/json", "application/xml"}, - method = RequestMethod.POST) - public ResponseEntity addPet( + @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input") }) + @RequestMapping(value = "", + produces = { "application/json", "application/xml" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.POST) + public ResponseEntity addPet( - @ApiParam(value = "Pet object that needs to be added to the store") Pet body) - throws NotFoundException { +@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") - @ApiResponses(value = { + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid status value")}) - @RequestMapping(value = "/findByStatus", - produces = {"application/json", "application/xml"}, + @ApiResponse(code = 400, message = "Invalid status value") }) + @RequestMapping(value = "/findByStatus", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List status - method = RequestMethod.GET) - public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue = "available") List status - - ) - throws NotFoundException { +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") - @ApiResponses(value = { + @ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") + @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid tag value")}) - @RequestMapping(value = "/findByTags", - produces = {"application/json", "application/xml"}, + @ApiResponse(code = 400, message = "Invalid tag value") }) + @RequestMapping(value = "/findByTags", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags - method = RequestMethod.GET) - public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags - - ) - throws NotFoundException { +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) - @ApiResponses(value = { + @ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied")}) - @RequestMapping(value = "/{petId}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.GET) - public ResponseEntity getPetById( - @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("petId") Long petId - ) - throws NotFoundException { + @ApiResponse(code = 400, message = "Invalid ID supplied") }) + @RequestMapping(value = "/{petId}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity getPetById( +@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + + + + @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input") }) + @RequestMapping(value = "/{petId}", + produces = { "application/json", "application/xml" }, + consumes = { "application/x-www-form-urlencoded" }, + method = RequestMethod.POST) + public ResponseEntity updatePetWithForm( +@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId +, + - @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input")}) - @RequestMapping(value = "/{petId}", - produces = {"application/json", "application/xml"}, - consumes = {"application/x-www-form-urlencoded"}, - method = RequestMethod.POST) - public ResponseEntity updatePetWithForm( - @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") String petId - , + @ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name, + - @ApiParam(value = "Updated name of the pet") @RequestPart(value = "name", required = false) String name, - - - @ApiParam(value = "Updated status of the pet") @RequestPart(value = "status", required = false) String status) - throws NotFoundException { + @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid pet value")}) - @RequestMapping(value = "/{petId}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.DELETE) - public ResponseEntity deletePet( - @ApiParam(value = "") @RequestHeader(value = "apiKey", required = false) String apiKey - , - - @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId - ) - throws NotFoundException { + @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid pet value") }) + @RequestMapping(value = "/{petId}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.DELETE) + public ResponseEntity deletePet( +@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey +, + +@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + + + + @ApiOperation(value = "uploads an image", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 0, message = "successful operation") }) + @RequestMapping(value = "/{petId}/uploadImage", + produces = { "application/json", "application/xml" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + public ResponseEntity uploadFile( +@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId +, + - @ApiOperation(value = "uploads an image", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation")}) - @RequestMapping(value = "/{petId}/uploadImage", - produces = {"application/json", "application/xml"}, - consumes = {"multipart/form-data"}, - method = RequestMethod.POST) - public ResponseEntity uploadFile( - @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId - , + @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, + - - @ApiParam(value = "Additional data to pass to server") @RequestPart(value = "additionalMetadata", required = false) String additionalMetadata, - - - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail) - throws NotFoundException { +@ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); + } + + } - - -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index e08fde09cf9..21dcf40236a 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -1,90 +1,105 @@ package io.swagger.api; +import io.swagger.model.*; + +import java.util.Map; +import io.swagger.model.Order; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import io.swagger.model.Order; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/store", description = "the store API") -public class StoreApi { + public class StoreApi { + - - @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation")}) - @RequestMapping(value = "/inventory", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.GET) - public ResponseEntity getInventory() - throws NotFoundException { + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/inventory", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity getInventory() + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) - @ApiResponses(value = { + @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid Order")}) - @RequestMapping(value = "/order", - produces = {"application/json", "application/xml"}, + @ApiResponse(code = 400, message = "Invalid Order") }) + @RequestMapping(value = "/order", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.POST) + public ResponseEntity placeOrder( - method = RequestMethod.POST) - public ResponseEntity placeOrder( - - @ApiParam(value = "order placed for purchasing the pet") Order body) - throws NotFoundException { +@ApiParam(value = "order placed for purchasing the pet" ) Order body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) - @ApiResponses(value = { + @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "Order not found"), @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid ID supplied")}) - @RequestMapping(value = "/order/{orderId}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.GET) - public ResponseEntity getOrderById( - @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") String orderId - ) - throws NotFoundException { + @ApiResponse(code = 400, message = "Invalid ID supplied") }) + @RequestMapping(value = "/order/{orderId}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity getOrderById( +@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) - @ApiResponses(value = { + @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "Order not found"), - @ApiResponse(code = 400, message = "Invalid ID supplied")}) - @RequestMapping(value = "/order/{orderId}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.DELETE) - public ResponseEntity deleteOrder( - @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId - ) - throws NotFoundException { + @ApiResponse(code = 400, message = "Invalid ID supplied") }) + @RequestMapping(value = "/order/{orderId}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.DELETE) + public ResponseEntity deleteOrder( +@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); + } + + } - - -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index c3b7f7f4c87..10a02df1c83 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -1,18 +1,27 @@ package io.swagger.api; +import io.swagger.model.*; + +import io.swagger.model.User; +import java.util.*; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import io.swagger.model.User; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -21,144 +30,151 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/user", description = "the user API") -public class UserApi { + public class UserApi { + + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 0, message = "successful operation") }) + @RequestMapping(value = "", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.POST) + public ResponseEntity createUser( - @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation")}) - @RequestMapping(value = "", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.POST) - public ResponseEntity createUser( - - @ApiParam(value = "Created user object") User body) - throws NotFoundException { +@ApiParam(value = "Created user object" ) User body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation")}) - @RequestMapping(value = "/createWithArray", - produces = {"application/json", "application/xml"}, + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 0, message = "successful operation") }) + @RequestMapping(value = "/createWithArray", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.POST) + public ResponseEntity createUsersWithArrayInput( - method = RequestMethod.POST) - public ResponseEntity createUsersWithArrayInput( - - @ApiParam(value = "List of user object") List body) - throws NotFoundException { +@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation")}) - @RequestMapping(value = "/createWithList", - produces = {"application/json", "application/xml"}, + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 0, message = "successful operation") }) + @RequestMapping(value = "/createWithList", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.POST) + public ResponseEntity createUsersWithListInput( - method = RequestMethod.POST) - public ResponseEntity createUsersWithListInput( - - @ApiParam(value = "List of user object") List body) - throws NotFoundException { +@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Logs user into the system", notes = "", response = String.class) - @ApiResponses(value = { + @ApiOperation(value = "Logs user into the system", notes = "", response = String.class) + @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid username/password supplied")}) - @RequestMapping(value = "/login", - produces = {"application/json", "application/xml"}, + @ApiResponse(code = 400, message = "Invalid username/password supplied") }) + @RequestMapping(value = "/login", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username - method = RequestMethod.GET) - public ResponseEntity loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username +, + @ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password - , - @ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password - - ) - throws NotFoundException { +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation")}) - @RequestMapping(value = "/logout", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.GET) - public ResponseEntity logoutUser() - throws NotFoundException { + @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 0, message = "successful operation") }) + @RequestMapping(value = "/logout", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity logoutUser() + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Get user by user name", notes = "", response = User.class) - @ApiResponses(value = { + @ApiOperation(value = "Get user by user name", notes = "", response = User.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "User not found"), @ApiResponse(code = 200, message = "successful operation"), - @ApiResponse(code = 400, message = "Invalid username supplied")}) - @RequestMapping(value = "/{username}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.GET) - public ResponseEntity getUserByName( - @ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ", required = true) @PathVariable("username") String username - ) - throws NotFoundException { + @ApiResponse(code = 400, message = "Invalid username supplied") }) + @RequestMapping(value = "/{username}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.GET) + public ResponseEntity getUserByName( +@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "User not found"), - @ApiResponse(code = 400, message = "Invalid user supplied")}) - @RequestMapping(value = "/{username}", - produces = {"application/json", "application/xml"}, + @ApiResponse(code = 400, message = "Invalid user supplied") }) + @RequestMapping(value = "/{username}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.PUT) + public ResponseEntity updateUser( +@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username +, + - method = RequestMethod.PUT) - public ResponseEntity updateUser( - @ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username - , - - - @ApiParam(value = "Updated user object") User body) - throws NotFoundException { +@ApiParam(value = "Updated user object" ) User body) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); - } + } + - @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { @ApiResponse(code = 404, message = "User not found"), - @ApiResponse(code = 400, message = "Invalid username supplied")}) - @RequestMapping(value = "/{username}", - produces = {"application/json", "application/xml"}, - - method = RequestMethod.DELETE) - public ResponseEntity deleteUser( - @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username - ) - throws NotFoundException { + @ApiResponse(code = 400, message = "Invalid username supplied") }) + @RequestMapping(value = "/{username}", + produces = { "application/json", "application/xml" }, + + method = RequestMethod.DELETE) + public ResponseEntity deleteUser( +@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username +) + throws NotFoundException { // do some magic! return new ResponseEntity(HttpStatus.OK); + } + + } - - -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java index d10dc1a3141..569148eaf37 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java @@ -3,8 +3,8 @@ package io.swagger.configuration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.Import; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; @@ -19,22 +19,22 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) public class SwaggerConfig { - @Bean - ApiInfo apiInfo() { - ApiInfo apiInfo = new ApiInfo( - "Swagger Petstore", - "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", - "1.0.0", - "", - "apiteam@swagger.io", - "Apache 2.0", - "http://www.apache.org/licenses/LICENSE-2.0.html"); - return apiInfo; - } +@Bean +ApiInfo apiInfo() { +ApiInfo apiInfo = new ApiInfo( +"Swagger Petstore", +"This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", +"1.0.0", +"", +"apiteam@swagger.io", +"Apache 2.0", +"http://www.apache.org/licenses/LICENSE-2.0.html" ); +return apiInfo; +} - @Bean - public Docket customImplementation() { - return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); - } +@Bean +public Docket customImplementation(){ +return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); +} } \ No newline at end of file diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java index 6457777ba17..54e84338d56 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -9,39 +9,38 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { - private static final String[] SERVLET_RESOURCE_LOCATIONS = {"/"}; +private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; - private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { - "classpath:/META-INF/resources/", "classpath:/resources/", - "classpath:/static/", "classpath:/public/"}; +private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { +"classpath:/META-INF/resources/", "classpath:/resources/", +"classpath:/static/", "classpath:/public/" }; - private static final String[] RESOURCE_LOCATIONS; - private static final String[] STATIC_INDEX_HTML_RESOURCES; +private static final String[] RESOURCE_LOCATIONS; +static { +RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length ++ SERVLET_RESOURCE_LOCATIONS.length]; +System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0, +SERVLET_RESOURCE_LOCATIONS.length); +System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, +SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length); +} - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - } - } +private static final String[] STATIC_INDEX_HTML_RESOURCES; +static { +STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length]; +for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) { +STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html"; +} +} - static { - RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length - + SERVLET_RESOURCE_LOCATIONS.length]; - System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0, - SERVLET_RESOURCE_LOCATIONS.length); - System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, - SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length); - } - - static { - STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length]; - for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) { - STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html"; - } - } +@Override +public void addResourceHandlers(ResourceHandlerRegistry registry) { +if (!registry.hasMappingForPattern("/webjars/**")) { +registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); +} +if (!registry.hasMappingForPattern("/**")) { +registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); +} +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java index e2a3a052d74..83801495db2 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java @@ -4,18 +4,18 @@ import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatche public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { - @Override - protected Class[] getRootConfigClasses() { - return new Class[]{SwaggerConfig.class}; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[]{WebMvcConfiguration.class}; - } - - @Override - protected String[] getServletMappings() { - return new String[]{"/"}; - } +@Override +protected Class[] getRootConfigClasses() { +return new Class[] { SwaggerConfig.class }; +} + +@Override +protected Class[] getServletConfigClasses() { +return new Class[] { WebMvcConfiguration.class }; +} + +@Override +protected String[] getServletMappings() { +return new String[] { "/" }; +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java index 206e011dd48..6bf14747453 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java @@ -4,8 +4,8 @@ import org.springframework.web.servlet.config.annotation.DefaultServletHandlerCo import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; public class WebMvcConfiguration extends WebMvcConfigurationSupport { - @Override - public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { - configurer.enable(); - } +@Override +public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { +configurer.enable(); +} } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index 8475e04680a..9ca416a8734 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -1,50 +1,51 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Category { + + private Long id = null; + private String name = null; -@ApiModel(description = "") -public class Category { - - private Long id = null; - private String name = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index a9513d080a9..5069ecfb5d5 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -1,112 +1,112 @@ package io.swagger.model; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.Date; +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; -@ApiModel(description = "") -public class Order { + + @ApiModel(description = "") + public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + private StatusEnum status = null; + private Boolean complete = null; - private Long id = null; - private Long petId = null; - private Integer quantity = null; - private Date shipDate = null; - private StatusEnum status = null; - - ; - private Boolean complete = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("petId") - public Long getPetId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("petId") + public Long getPetId() { return petId; - } - - public void setPetId(Long petId) { + } + public void setPetId(Long petId) { this.petId = petId; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("quantity") - public Integer getQuantity() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("quantity") + public Integer getQuantity() { return quantity; - } - - public void setQuantity(Integer quantity) { + } + public void setQuantity(Integer quantity) { this.quantity = quantity; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("shipDate") - public Date getShipDate() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("shipDate") + public Date getShipDate() { return shipDate; - } - - public void setShipDate(Date shipDate) { + } + public void setShipDate(Date shipDate) { this.shipDate = shipDate; - } + } - /** - * Order Status - **/ - @ApiModelProperty(value = "Order Status") - @JsonProperty("status") - public StatusEnum getStatus() { + + /** + * Order Status + **/ + @ApiModelProperty(value = "Order Status") + @JsonProperty("status") + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("complete") - public Boolean getComplete() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("complete") + public Boolean getComplete() { return complete; - } - - public void setComplete(Boolean complete) { + } + public void setComplete(Boolean complete) { this.complete = complete; - } + } + + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - - public enum StatusEnum { - placed, approved, delivered, } -} + diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 93adbdca7b6..54d2453a773 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -1,115 +1,114 @@ package io.swagger.model; -import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.model.Category; import io.swagger.model.Tag; +import java.util.*; -import java.util.ArrayList; -import java.util.List; +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList() ; + private List tags = new ArrayList() ; + public enum StatusEnum { + available, pending, sold, + }; + private StatusEnum status = null; -@ApiModel(description = "") -public class Pet { - - private Long id = null; - private Category category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - private StatusEnum status = null; - - ; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("category") - public Category getCategory() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("category") + public Category getCategory() { return category; - } - - public void setCategory(Category category) { + } + public void setCategory(Category category) { this.category = category; - } + } - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { return photoUrls; - } - - public void setPhotoUrls(List photoUrls) { + } + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; - } + } - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("tags") - public List getTags() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("tags") + public List getTags() { return tags; - } - - public void setTags(List tags) { + } + public void setTags(List tags) { this.tags = tags; - } + } - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { return status; - } - - public void setStatus(StatusEnum status) { + } + public void setStatus(StatusEnum status) { this.status = status; - } + } + + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } - - - public enum StatusEnum { - available, pending, sold, } -} + diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 3b745b11ea4..814c2d5b6c3 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -1,50 +1,51 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class Tag { + + private Long id = null; + private String name = null; -@ApiModel(description = "") -public class Tag { - - private Long id = null; - private String name = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { return name; - } - - public void setName(String name) { + } + public void setName(String name) { this.name = name; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } + diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index 0f4a3fde3e7..9caa8ec5a17 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -1,141 +1,136 @@ package io.swagger.model; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; + + @ApiModel(description = "") + public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; -@ApiModel(description = "") -public class User { - - private Long id = null; - private String username = null; - private String firstName = null; - private String lastName = null; - private String email = null; - private String password = null; - private String phone = null; - private Integer userStatus = null; - - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("id") - public Long getId() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { return id; - } - - public void setId(Long id) { + } + public void setId(Long id) { this.id = id; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("username") - public String getUsername() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("username") + public String getUsername() { return username; - } - - public void setUsername(String username) { + } + public void setUsername(String username) { this.username = username; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("firstName") - public String getFirstName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("firstName") + public String getFirstName() { return firstName; - } - - public void setFirstName(String firstName) { + } + public void setFirstName(String firstName) { this.firstName = firstName; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("lastName") - public String getLastName() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("lastName") + public String getLastName() { return lastName; - } - - public void setLastName(String lastName) { + } + public void setLastName(String lastName) { this.lastName = lastName; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("email") - public String getEmail() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("email") + public String getEmail() { return email; - } - - public void setEmail(String email) { + } + public void setEmail(String email) { this.email = email; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("password") - public String getPassword() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("password") + public String getPassword() { return password; - } - - public void setPassword(String password) { + } + public void setPassword(String password) { this.password = password; - } + } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("phone") - public String getPhone() { + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("phone") + public String getPhone() { return phone; - } - - public void setPhone(String phone) { + } + public void setPhone(String phone) { this.phone = phone; - } + } - - /** - * User Status - **/ - @ApiModelProperty(value = "User Status") - @JsonProperty("userStatus") - public Integer getUserStatus() { + + /** + * User Status + **/ + @ApiModelProperty(value = "User Status") + @JsonProperty("userStatus") + public Integer getUserStatus() { return userStatus; - } - - public void setUserStatus(Integer userStatus) { + } + public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; - } + } + @Override - public String toString() { - StringBuilder 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(); + public String toString() { + StringBuilder 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(); } -} + } +