From 652099ab71c000cbdc62edc1a9352b8cea98d8b7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 19 Mar 2016 17:02:51 +0800 Subject: [PATCH 01/16] update perl readme --- .../src/main/resources/perl/README.mustache | 10 +++++++--- samples/client/petstore/perl/README.md | 9 +++++---- samples/client/petstore/perl/docs/Name.md | 1 + .../perl/lib/WWW/SwaggerClient/Object/Name.pm | 13 +++++++++++-- .../petstore/perl/lib/WWW/SwaggerClient/Role.pm | 4 ++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index e4271d94936..b7641ecea8c 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -2,15 +2,19 @@ {{moduleName}}::Role - a Moose role for the {{appName}} -## {{appName}} version: {{appVersion}} +{{#appDescription}}{{{appDescription}}}{{/appDescription}} # VERSION -Automatically generated by the Perl Swagger Codegen project: +Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: +- API verion: {{appVersion}} +- Package version: {{moduleVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} -- Codegen version: +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} ## A note on Moose diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index c240e99a10d..6ebfc0dcb76 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -2,15 +2,16 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore -## Swagger Petstore version: 1.0.0 +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 # VERSION -Automatically generated by the Perl Swagger Codegen project: +Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- Build date: 2016-03-17T15:41:15.325+08:00 +- API verion: 1.0.0 +- Package version: 1.0.0 +- Build date: 2016-03-19T16:59:31.367+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen -- Codegen version: ## A note on Moose diff --git a/samples/client/petstore/perl/docs/Name.md b/samples/client/petstore/perl/docs/Name.md index 91d0a056ab8..13b5d0dde82 100644 --- a/samples/client/petstore/perl/docs/Name.md +++ b/samples/client/petstore/perl/docs/Name.md @@ -9,6 +9,7 @@ use WWW::SwaggerClient::Object::Name; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | [optional] +**snake_case** | **int** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm index 2413c55650d..f136a7f031e 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm @@ -110,15 +110,24 @@ __PACKAGE__->method_documentation({ format => '', read_only => '', }, + 'snake_case' => { + datatype => 'int', + base_name => 'snake_case', + description => '', + format => '', + read_only => '', + }, }); __PACKAGE__->swagger_types( { - 'name' => 'int' + 'name' => 'int', + 'snake_case' => 'int' } ); __PACKAGE__->attribute_map( { - 'name' => 'name' + 'name' => 'name', + 'snake_case' => 'snake_case' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 3f09db6f1d5..0b3e7bd5de7 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-03-17T15:41:15.325+08:00', + generated_date => '2016-03-19T16:59:31.367+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-03-17T15:41:15.325+08:00 +=item Build date: 2016-03-19T16:59:31.367+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen From eb69db5720d784299e7610bc4397631307c2c727 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 23 Mar 2016 21:47:38 +0800 Subject: [PATCH 02/16] add kuary --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 05ae20b06b9..3b3e6726b78 100644 --- a/README.md +++ b/README.md @@ -740,6 +740,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [FH Münster - University of Applied Sciences](http://www.fh-muenster.de) - [LANDR Audio](https://www.landr.com/) - [LiveAgent](https://www.ladesk.com/) +- [Kuary](https://kuary.com/) - [nViso](http://www.nviso.ch/) - [Okiok](https://www.okiok.com) - [OSDN](https://osdn.jp) From eb5c689fac2f4213aec2b694e966bf6d98ad2a30 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 24 Mar 2016 19:54:25 +0800 Subject: [PATCH 03/16] update js sample --- .../petstore/javascript-promise/README.md | 69 ++++++++++--------- .../docs/InlineResponse200.md | 1 - .../petstore/javascript-promise/docs/Name.md | 1 + .../javascript-promise/docs/PetApi.md | 45 ++++++------ .../javascript-promise/docs/StoreApi.md | 25 ++++--- .../javascript-promise/docs/UserApi.md | 32 ++++----- .../javascript-promise/src/api/PetApi.js | 4 +- .../javascript-promise/src/api/StoreApi.js | 9 +-- .../javascript-promise/src/api/UserApi.js | 12 +--- .../javascript-promise/src/model/Name.js | 9 +++ samples/client/petstore/javascript/README.md | 2 +- .../client/petstore/javascript/docs/Name.md | 1 + .../petstore/javascript/src/api/PetApi.js | 8 --- .../petstore/javascript/src/model/Name.js | 9 +++ 14 files changed, 114 insertions(+), 113 deletions(-) diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 2c2f6f169b6..478bc4657ca 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -1,69 +1,76 @@ # swagger-petstore SwaggerPetstore - JavaScript client for 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 +This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -Version: 1.0.0 - -Automatically generated by the JavaScript Swagger Codegen project: - -- Build date: 2016-03-18T15:44:17.513Z +- API verion: 1.0.0 +- Package version: 1.0.0 +- Build date: 2016-03-24T19:50:42.301+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation -### Use in [Node.js](https://nodejs.org/) +### For [Node.js](https://nodejs.org/) -The generated client is valid [npm](https://www.npmjs.com/) package, you can publish it as described -in [Publishing npm packages](https://docs.npmjs.com/getting-started/publishing-npm-packages). +#### npm -After that, you can install it into your project via: +To publish the library as a [npm](https://www.npmjs.com/), +please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages). + +Then install it via: ```shell npm install swagger-petstore --save ``` -You can also host the generated client as a git repository on github, e.g. -https://github.com/YOUR_USERNAME/swagger-petstore - -Then you can install it via: +#### git +# +If the library is hosted at a git repository, e.g. +https://github.com/YOUR_USERNAME/YOUR_GIT_REPO_ID +then install it via: ```shell -npm install YOUR_USERNAME/swagger-petstore --save +npm install YOUR_USERNAME/YOUR_GIT_REPO_ID --save ``` -### Use in browser with [browserify](http://browserify.org/) +### For browser -The client also works in browser environment via npm and browserify. After following +The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following the above steps with Node.js and installing browserify with `npm install -g browserify`, -you can do this in your project (assuming *main.js* is your entry file): +perform the following (assuming *main.js* is your entry file): ```shell browserify main.js > bundle.js ``` -The generated *bundle.js* can now be included in your HTML pages. +Then include *bundle.js* in the HTML pages. ## Getting Started +Please follow the [installation](#installation) instruction and execute the following JS code: + ```javascript var SwaggerPetstore = require('swagger-petstore'); var defaultClient = SwaggerPetstore.ApiClient.default; -defaultClient.timeout = 10 * 1000; -defaultClient.defaultHeaders['Test-Header'] = 'test_value'; -// Assuming there's a `PetApi` containing a `getPetById` method -// which returns a model object: -var api = new SwaggerPetstore.PetApi(); -api.getPetById(2, function(err, pet, resp) { - console.log('HTTP status code: ' + resp.status); - console.log('Response Content-Type: ' + resp.get('Content-Type')); - if (err) { - console.error(err); - } else { - console.log(pet); - } +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store +}; +api.addPet(opts).then(function() { + console.log('API called successfully.'); +}, function(error) { + console.error(error); }); + + ``` ## Documentation for API Endpoints diff --git a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md b/samples/client/petstore/javascript-promise/docs/InlineResponse200.md index 66a4605e2c4..bbb11067e9a 100644 --- a/samples/client/petstore/javascript-promise/docs/InlineResponse200.md +++ b/samples/client/petstore/javascript-promise/docs/InlineResponse200.md @@ -1,4 +1,3 @@ - # SwaggerPetstore.InlineResponse200 ## Properties diff --git a/samples/client/petstore/javascript-promise/docs/Name.md b/samples/client/petstore/javascript-promise/docs/Name.md index 114d6dc980e..5086f6c5a3e 100644 --- a/samples/client/petstore/javascript-promise/docs/Name.md +++ b/samples/client/petstore/javascript-promise/docs/Name.md @@ -4,5 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**snakeCase** | **Integer** | | [optional] diff --git a/samples/client/petstore/javascript-promise/docs/PetApi.md b/samples/client/petstore/javascript-promise/docs/PetApi.md index 9e14ea0c815..77d9630f888 100644 --- a/samples/client/petstore/javascript-promise/docs/PetApi.md +++ b/samples/client/petstore/javascript-promise/docs/PetApi.md @@ -1,4 +1,3 @@ - # SwaggerPetstore.PetApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -35,12 +34,12 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var opts = { 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store }; -api.addPet(opts).then(function() { +apiInstance.addPet(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -84,12 +83,12 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var opts = { 'body': "B" // {String} Pet object in the form of byte array }; -api.addPetUsingByteArray(opts).then(function() { +apiInstance.addPetUsingByteArray(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -133,14 +132,14 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = 789; // {Integer} Pet id to delete var opts = { 'apiKey': "apiKey_example" // {String} }; -api.deletePet(petId, opts).then(function() { +apiInstance.deletePet(petId, opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -185,12 +184,12 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var opts = { 'status': ["available"] // {[String]} Status values that need to be considered for query }; -api.findPetsByStatus(opts).then(function(data) { +apiInstance.findPetsByStatus(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -234,12 +233,12 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var opts = { 'tags': ["tags_example"] // {[String]} Tags to filter by }; -api.findPetsByTags(opts).then(function(data) { +apiInstance.findPetsByTags(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -289,11 +288,11 @@ api_key.apiKey = "YOUR API KEY" var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = 789; // {Integer} ID of pet that needs to be fetched -api.getPetById(petId).then(function(data) { +apiInstance.getPetById(petId).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -343,11 +342,11 @@ api_key.apiKey = "YOUR API KEY" var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = 789; // {Integer} ID of pet that needs to be fetched -api.getPetByIdInObject(petId).then(function(data) { +apiInstance.getPetByIdInObject(petId).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -397,11 +396,11 @@ api_key.apiKey = "YOUR API KEY" var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = 789; // {Integer} ID of pet that needs to be fetched -api.petPetIdtestingByteArraytrueGet(petId).then(function(data) { +apiInstance.petPetIdtestingByteArraytrueGet(petId).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -445,12 +444,12 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var opts = { 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store }; -api.updatePet(opts).then(function() { +apiInstance.updatePet(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -494,7 +493,7 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = "petId_example"; // {String} ID of pet that needs to be updated @@ -502,7 +501,7 @@ var opts = { 'name': "name_example", // {String} Updated name of the pet 'status': "status_example" // {String} Updated status of the pet }; -api.updatePetWithForm(petId, opts).then(function() { +apiInstance.updatePetWithForm(petId, opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -548,7 +547,7 @@ var defaultClient = SwaggerPetstore.ApiClient.default; var petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = "YOUR ACCESS TOKEN" -var api = new SwaggerPetstore.PetApi() +var apiInstance = new SwaggerPetstore.PetApi() var petId = 789; // {Integer} ID of pet to update @@ -556,7 +555,7 @@ var opts = { 'additionalMetadata': "additionalMetadata_example", // {String} Additional data to pass to server 'file': "/path/to/file.txt" // {File} file to upload }; -api.uploadFile(petId, opts).then(function() { +apiInstance.uploadFile(petId, opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); diff --git a/samples/client/petstore/javascript-promise/docs/StoreApi.md b/samples/client/petstore/javascript-promise/docs/StoreApi.md index 53e4ffd5bc2..930586a96f5 100644 --- a/samples/client/petstore/javascript-promise/docs/StoreApi.md +++ b/samples/client/petstore/javascript-promise/docs/StoreApi.md @@ -1,4 +1,3 @@ - # SwaggerPetstore.StoreApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -25,11 +24,11 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.StoreApi() +var apiInstance = new SwaggerPetstore.StoreApi() var orderId = "orderId_example"; // {String} ID of the order that needs to be deleted -api.deleteOrder(orderId).then(function() { +apiInstance.deleteOrder(orderId).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -81,12 +80,12 @@ test_api_client_secret.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //test_api_client_secret.apiKeyPrefix['x-test_api_client_secret'] = "Token" -var api = new SwaggerPetstore.StoreApi() +var apiInstance = new SwaggerPetstore.StoreApi() var opts = { 'status': "placed" // {String} Status value that needs to be considered for query }; -api.findOrdersByStatus(opts).then(function(data) { +apiInstance.findOrdersByStatus(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -132,8 +131,8 @@ api_key.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix['api_key'] = "Token" -var api = new SwaggerPetstore.StoreApi() -api.getInventory().then(function(data) { +var apiInstance = new SwaggerPetstore.StoreApi() +apiInstance.getInventory().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -176,8 +175,8 @@ api_key.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix['api_key'] = "Token" -var api = new SwaggerPetstore.StoreApi() -api.getInventoryInObject().then(function(data) { +var apiInstance = new SwaggerPetstore.StoreApi() +apiInstance.getInventoryInObject().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -226,11 +225,11 @@ test_api_key_query.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token" -var api = new SwaggerPetstore.StoreApi() +var apiInstance = new SwaggerPetstore.StoreApi() var orderId = "orderId_example"; // {String} ID of pet that needs to be fetched -api.getOrderById(orderId).then(function(data) { +apiInstance.getOrderById(orderId).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -282,12 +281,12 @@ test_api_client_secret.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //test_api_client_secret.apiKeyPrefix['x-test_api_client_secret'] = "Token" -var api = new SwaggerPetstore.StoreApi() +var apiInstance = new SwaggerPetstore.StoreApi() var opts = { 'body': new SwaggerPetstore.Order() // {Order} order placed for purchasing the pet }; -api.placeOrder(opts).then(function(data) { +apiInstance.placeOrder(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); diff --git a/samples/client/petstore/javascript-promise/docs/UserApi.md b/samples/client/petstore/javascript-promise/docs/UserApi.md index 1a401b698db..1c14b708231 100644 --- a/samples/client/petstore/javascript-promise/docs/UserApi.md +++ b/samples/client/petstore/javascript-promise/docs/UserApi.md @@ -26,12 +26,12 @@ This can only be done by the logged in user. ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var opts = { 'body': new SwaggerPetstore.User() // {User} Created user object }; -api.createUser(opts).then(function() { +apiInstance.createUser(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -70,12 +70,12 @@ Creates list of users with given input array ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var opts = { 'body': [new SwaggerPetstore.User()] // {[User]} List of user object }; -api.createUsersWithArrayInput(opts).then(function() { +apiInstance.createUsersWithArrayInput(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -114,12 +114,12 @@ Creates list of users with given input array ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var opts = { 'body': [new SwaggerPetstore.User()] // {[User]} List of user object }; -api.createUsersWithListInput(opts).then(function() { +apiInstance.createUsersWithListInput(opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -164,11 +164,11 @@ var test_http_basic = defaultClient.authentications['test_http_basic']; test_http_basic.username = 'YOUR USERNAME' test_http_basic.password = 'YOUR PASSWORD' -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var username = "username_example"; // {String} The name that needs to be deleted -api.deleteUser(username).then(function() { +apiInstance.deleteUser(username).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -207,11 +207,11 @@ Get user by user name ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var username = "username_example"; // {String} The name that needs to be fetched. Use user1 for testing. -api.getUserByName(username).then(function(data) { +apiInstance.getUserByName(username).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -250,13 +250,13 @@ Logs user into the system ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var opts = { 'username': "username_example", // {String} The user name for login 'password': "password_example" // {String} The password for login in clear text }; -api.loginUser(opts).then(function(data) { +apiInstance.loginUser(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); @@ -296,8 +296,8 @@ Logs out current logged in user session ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() -api.logoutUser().then(function() { +var apiInstance = new SwaggerPetstore.UserApi() +apiInstance.logoutUser().then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); @@ -333,14 +333,14 @@ This can only be done by the logged in user. ```javascript var SwaggerPetstore = require('swagger-petstore'); -var api = new SwaggerPetstore.UserApi() +var apiInstance = new SwaggerPetstore.UserApi() var username = "username_example"; // {String} name that need to be deleted var opts = { 'body': new SwaggerPetstore.User() // {User} Updated user object }; -api.updateUser(username, opts).then(function() { +apiInstance.updateUser(username, opts).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index 6166cf35cb1..520791b3f0a 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -25,7 +25,7 @@ * Constructs a new PetApi. * @alias module:api/PetApi * @class - * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance} + * @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance} * if unspecified. */ var exports = function(apiClient) { @@ -144,7 +144,7 @@ * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param {Object} opts Optional parameters - * @param {Array.} opts.status Status values that need to be considered for query + * @param {Array.} opts.status Status values that need to be considered for query (default to available) * data is of type: {Array.} */ this.findPetsByStatus = function(opts) { diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index c94b6c8169c..32a6dce47e9 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -25,7 +25,7 @@ * Constructs a new StoreApi. * @alias module:api/StoreApi * @class - * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance} + * @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance} * if unspecified. */ var exports = function(apiClient) { @@ -40,11 +40,6 @@ */ this.deleteOrder = function(orderId) { var postBody = null; - // verify the required parameter 'orderId' is set - if (orderId == null) { - throw "Missing the required parameter 'orderId' when calling deleteOrder"; - } - // verify the required parameter 'orderId' is set if (orderId == undefined || orderId == null) { @@ -79,7 +74,7 @@ * Finds orders by status * A single status value can be provided as a string * @param {Object} opts Optional parameters - * @param {module:model/String} opts.status Status value that needs to be considered for query + * @param {module:model/String} opts.status Status value that needs to be considered for query (default to placed) * data is of type: {Array.} */ this.findOrdersByStatus = function(opts) { diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index b869274285c..8914d9c883d 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -25,7 +25,7 @@ * Constructs a new UserApi. * @alias module:api/UserApi * @class - * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance} + * @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance} * if unspecified. */ var exports = function(apiClient) { @@ -139,11 +139,6 @@ */ this.deleteUser = function(username) { var postBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw "Missing the required parameter 'username' when calling deleteUser"; - } - // verify the required parameter 'username' is set if (username == undefined || username == null) { @@ -182,11 +177,6 @@ */ this.getUserByName = function(username) { var postBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw "Missing the required parameter 'username' when calling getUserByName"; - } - // verify the required parameter 'username' is set if (username == undefined || username == null) { diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js index 20aa186bd97..a5a070025f7 100644 --- a/samples/client/petstore/javascript-promise/src/model/Name.js +++ b/samples/client/petstore/javascript-promise/src/model/Name.js @@ -29,6 +29,7 @@ var exports = function() { + }; /** @@ -45,6 +46,9 @@ if (data.hasOwnProperty('name')) { obj['name'] = ApiClient.convertToType(data['name'], 'Integer'); } + if (data.hasOwnProperty('snake_case')) { + obj['snake_case'] = ApiClient.convertToType(data['snake_case'], 'Integer'); + } } return obj; } @@ -55,6 +59,11 @@ */ exports.prototype['name'] = undefined; + /** + * @member {Integer} snake_case + */ + exports.prototype['snake_case'] = undefined; + diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 268b09738f5..2f3f0edb897 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API verion: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-18T18:26:17.121+08:00 +- Build date: 2016-03-24T19:50:27.240+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation diff --git a/samples/client/petstore/javascript/docs/Name.md b/samples/client/petstore/javascript/docs/Name.md index 114d6dc980e..5086f6c5a3e 100644 --- a/samples/client/petstore/javascript/docs/Name.md +++ b/samples/client/petstore/javascript/docs/Name.md @@ -4,5 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | [optional] +**snakeCase** | **Integer** | | [optional] diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index dc847f464cf..3bfc6ffd4f0 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -25,11 +25,7 @@ * Constructs a new PetApi. * @alias module:api/PetApi * @class -<<<<<<< HEAD - * @param {module:ApiClient} apiClient Optional API client implementation to use, defaulting to {@link module:ApiClient#instance} -======= * @param {module:ApiClient} apiClient Optional API client implementation to use, default to {@link module:ApiClient#instance} ->>>>>>> update js doc * if unspecified. */ var exports = function(apiClient) { @@ -179,11 +175,7 @@ * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param {Object} opts Optional parameters -<<<<<<< HEAD - * @param {Array.} opts.status Status values that need to be considered for query -======= * @param {Array.} opts.status Status values that need to be considered for query (default to available) ->>>>>>> update js doc * @param {module:api/PetApi~findPetsByStatusCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {Array.} */ diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js index 20aa186bd97..a5a070025f7 100644 --- a/samples/client/petstore/javascript/src/model/Name.js +++ b/samples/client/petstore/javascript/src/model/Name.js @@ -29,6 +29,7 @@ var exports = function() { + }; /** @@ -45,6 +46,9 @@ if (data.hasOwnProperty('name')) { obj['name'] = ApiClient.convertToType(data['name'], 'Integer'); } + if (data.hasOwnProperty('snake_case')) { + obj['snake_case'] = ApiClient.convertToType(data['snake_case'], 'Integer'); + } } return obj; } @@ -55,6 +59,11 @@ */ exports.prototype['name'] = undefined; + /** + * @member {Integer} snake_case + */ + exports.prototype['snake_case'] = undefined; + From cd0633a04f641785895959771369780656e6642d Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Thu, 24 Mar 2016 13:27:47 -0700 Subject: [PATCH 04/16] Updated to release version of swagger-parser --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f7342ca3140..c308b2dfacb 100644 --- a/pom.xml +++ b/pom.xml @@ -559,7 +559,7 @@ - 1.0.18-SNAPSHOT + 1.0.18 2.11.1 2.3.4 1.5.8 From 00c97c8ff6a0b50027d6805d78b1b0f185c174e3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 25 Mar 2016 17:35:21 +0800 Subject: [PATCH 05/16] update build.gradle for android (default, volley) --- .../src/main/resources/android/build.mustache | 20 ++++++++++--------- .../libraries/volley/apiInvoker.mustache | 3 ++- .../android/libraries/volley/build.mustache | 9 +++++---- .../petstore/android/default/build.gradle | 20 ++++++++++--------- .../java/io/swagger/client/model/Name.java | 14 +++++++++++++ .../petstore/android/volley/build.gradle | 4 ++-- .../java/io/swagger/client/ApiInvoker.java | 3 ++- .../java/io/swagger/client/model/Name.java | 14 +++++++++++++ 8 files changed, 61 insertions(+), 26 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/android/build.mustache b/modules/swagger-codegen/src/main/resources/android/build.mustache index dff18970462..41c9a2dfbb1 100644 --- a/modules/swagger-codegen/src/main/resources/android/build.mustache +++ b/modules/swagger-codegen/src/main/resources/android/build.mustache @@ -8,9 +8,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.android.tools.build:gradle:1.5.+' {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' {{/useAndroidMavenGradlePlugin}} } } @@ -28,11 +28,12 @@ apply plugin: 'com.github.dcendents.android-maven' {{/useAndroidMavenGradlePlugin}} android { - compileSdkVersion 22 - buildToolsVersion '22.0.0' + compileSdkVersion 23 + buildToolsVersion '23.0.2' + useLibrary 'org.apache.http.legacy' defaultConfig { minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 23 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 @@ -55,16 +56,17 @@ android { ext { swagger_annotations_version = "1.5.0" gson_version = "2.3.1" - httpclient_version = "4.3.3" - junit_version = "4.8.1" + httpclient_version = "4.5.2" + httpcore_version = "4.4.4" + junit_version = "4.12" } dependencies { compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "com.google.code.gson:gson:$gson_version" - compile "org.apache.httpcomponents:httpcore:$httpclient_version" + compile "org.apache.httpcomponents:httpcore:$httpcore_version" compile "org.apache.httpcomponents:httpclient:$httpclient_version" - compile ("org.apache.httpcomponents:httpcore:$httpclient_version") { + compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache index 4369613449d..e76bf1357e1 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache @@ -197,7 +197,8 @@ public class ApiInvoker { INSTANCE.authentications.put("{{name}}", new HttpBasicAuth()); {{/isBasic}} {{#isOAuth}} - INSTANCE.authentications.put("{{name}}", new OAuth()); + // TODO: comment out below as OAuth does not exist + //INSTANCE.authentications.put("{{name}}", new OAuth()); {{/isOAuth}} {{/authMethods}} // Prevent the authentications from being modified. diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache index 197dd32b7c1..fabdd14a6d6 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/build.mustache @@ -8,9 +8,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.android.tools.build:gradle:1.5.+' {{#useAndroidMavenGradlePlugin}} - classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' {{/useAndroidMavenGradlePlugin}} } } @@ -59,9 +59,10 @@ android { ext { swagger_annotations_version = "1.5.0" gson_version = "2.3.1" - httpclient_version = "4.3.3" + httpclient_version = "4.5.2" + httpcore_version = "4.4.4" volley_version = "1.0.19" - junit_version = "4.8.1" + junit_version = "4.12" robolectric_version = "3.0" concurrent_unit_version = "0.4.2" } diff --git a/samples/client/petstore/android/default/build.gradle b/samples/client/petstore/android/default/build.gradle index 417503cb51e..e48f72b3138 100644 --- a/samples/client/petstore/android/default/build.gradle +++ b/samples/client/petstore/android/default/build.gradle @@ -6,9 +6,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.android.tools.build:gradle:1.5.+' - classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' } } @@ -24,11 +24,12 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 22 - buildToolsVersion '22.0.0' + compileSdkVersion 23 + buildToolsVersion '23.0.2' + useLibrary 'org.apache.http.legacy' defaultConfig { minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 23 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 @@ -51,16 +52,17 @@ android { ext { swagger_annotations_version = "1.5.0" gson_version = "2.3.1" - httpclient_version = "4.3.3" - junit_version = "4.8.1" + httpclient_version = "4.5.2" + httpcore_version = "4.4.4" + junit_version = "4.12" } dependencies { compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "com.google.code.gson:gson:$gson_version" - compile "org.apache.httpcomponents:httpcore:$httpclient_version" + compile "org.apache.httpcomponents:httpcore:$httpcore_version" compile "org.apache.httpcomponents:httpclient:$httpclient_version" - compile ("org.apache.httpcomponents:httpcore:$httpclient_version") { + compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java index 5c308de749f..9763aca7b34 100644 --- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java @@ -10,6 +10,8 @@ public class Name { @SerializedName("name") private Integer name = null; + @SerializedName("snake_case") + private Integer snakeCase = null; /** @@ -23,6 +25,17 @@ public class Name { } + /** + **/ + @ApiModelProperty(value = "") + public Integer getSnakeCase() { + return snakeCase; + } + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + @Override public String toString() { @@ -30,6 +43,7 @@ public class Name { sb.append("class Name {\n"); sb.append(" name: ").append(name).append("\n"); + sb.append(" snakeCase: ").append(snakeCase).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/samples/client/petstore/android/volley/build.gradle b/samples/client/petstore/android/volley/build.gradle index 799f9309a25..e678620cb00 100644 --- a/samples/client/petstore/android/volley/build.gradle +++ b/samples/client/petstore/android/volley/build.gradle @@ -6,9 +6,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.2' + classpath 'com.android.tools.build:gradle:1.5.0' - classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java index 86a0d6cb2d5..21ee5f36286 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java @@ -229,7 +229,8 @@ public class ApiInvoker { - INSTANCE.authentications.put("petstore_auth", new OAuth()); + // TODO: comment out below as OAuth does not exist + //INSTANCE.authentications.put("petstore_auth", new OAuth()); // Prevent the authentications from being modified. diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Name.java index 5c308de749f..9763aca7b34 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/model/Name.java @@ -10,6 +10,8 @@ public class Name { @SerializedName("name") private Integer name = null; + @SerializedName("snake_case") + private Integer snakeCase = null; /** @@ -23,6 +25,17 @@ public class Name { } + /** + **/ + @ApiModelProperty(value = "") + public Integer getSnakeCase() { + return snakeCase; + } + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + @Override public String toString() { @@ -30,6 +43,7 @@ public class Name { sb.append("class Name {\n"); sb.append(" name: ").append(name).append("\n"); + sb.append(" snakeCase: ").append(snakeCase).append("\n"); sb.append("}\n"); return sb.toString(); } From 5d5a6e049cb999aa4de5cc2023f678cba6b03c94 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 26 Mar 2016 10:59:08 +0800 Subject: [PATCH 06/16] update maven version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b3e6726b78..79ee9a6975d 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ To build from source, you need the following installed and available in your $PA * [Java 7 or 8](http://java.oracle.com) -* [Apache maven 3.0.3 or greater](http://maven.apache.org/) +* [Apache maven 3.3.3 or greater](http://maven.apache.org/) #### OS X Users Don't forget to install Java 7 or 8. You probably have 1.6. From 0196cdd5586819d01eb86acc3b7e63688b4ecab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 23 Mar 2016 10:59:32 +0100 Subject: [PATCH 07/16] [PHP] Use parent constructor when inheriting --- .../src/main/resources/php/model.mustache | 1 + .../src/test/resources/2_0/petstore.json | 36 +++++++++++++++++++ .../SwaggerClient-php/tests/PetApiTest.php | 27 ++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index 0793335193e..b58af994c24 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -114,6 +114,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA */ public function __construct(array $data = null) { + {{#parent}}parent::__construct($data);{{/parent}} if ($data != null) { {{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}} {{/hasMore}}{{/vars}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index ad042ee3879..f248a42a49d 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -1339,6 +1339,42 @@ "xml": { "name": "Name" } + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/definitions/Animal" + }, { + "type" : "object", + "properties" : { + "breed" : { + "type" : "string" + } + } + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/definitions/Animal" + }, { + "type" : "object", + "properties" : { + "declawed" : { + "type" : "boolean" + } + } + } ] + }, + "Animal" : { + "type" : "object", + "discriminator": "className", + "required": [ + "className" + ], + "properties" : { + "className" : { + "type" : "string" + } + } } } } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index a01f384d68e..3af1064f711 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -375,6 +375,33 @@ class PetApiTest extends \PHPUnit_Framework_TestCase } + // test inheritance in the model + public function testInheritance() + { + $new_dog = new Swagger\Client\Model\Dog; + // the object should be an instance of the derived class + $this->assertInstanceOf('Swagger\Client\Model\Dog', $new_dog); + // the object should also be an instance of the parent class + $this->assertInstanceOf('Swagger\Client\Model\Animal', $new_dog); + } + + // test inheritance constructor is working with data + // initialization + public function testInheritanceConstructorDataInitialization() + { + // initialize the object with data in the constructor + $data = array( + 'class_name' => 'Dog', + 'breed' => 'Great Dane' + ); + $new_dog = new Swagger\Client\Model\Dog($data); + + // the property on the derived class should be set + $this->assertSame('Great Dane', $new_dog->getBreed()); + // the property on the parent class should be set + $this->assertSame('Dog', $new_dog->getClassName()); + } + } ?> From da518d55d2963ead91b111cdcb685d4c5870d1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Mon, 28 Mar 2016 10:48:44 +0200 Subject: [PATCH 08/16] Regenerate PHP petstore sample --- .../petstore/php/SwaggerClient-php/README.md | 47 +++-- .../php/SwaggerClient-php/docs/Animal.md | 10 + .../php/SwaggerClient-php/docs/Cat.md | 10 + .../php/SwaggerClient-php/docs/Dog.md | 10 + .../docs/InlineResponse200.md | 6 +- .../php/SwaggerClient-php/docs/PetApi.md | 18 +- .../php/SwaggerClient-php/docs/StoreApi.md | 10 +- .../php/SwaggerClient-php/lib/Api/PetApi.php | 30 +-- .../SwaggerClient-php/lib/Api/StoreApi.php | 8 +- .../SwaggerClient-php/lib/Model/Animal.php | 191 ++++++++++++++++++ .../php/SwaggerClient-php/lib/Model/Cat.php | 191 ++++++++++++++++++ .../SwaggerClient-php/lib/Model/Category.php | 1 + .../php/SwaggerClient-php/lib/Model/Dog.php | 191 ++++++++++++++++++ .../lib/Model/InlineResponse200.php | 169 ++++++++-------- .../lib/Model/Model200Response.php | 1 + .../lib/Model/ModelReturn.php | 1 + .../php/SwaggerClient-php/lib/Model/Name.php | 1 + .../php/SwaggerClient-php/lib/Model/Order.php | 1 + .../php/SwaggerClient-php/lib/Model/Pet.php | 1 + .../lib/Model/SpecialModelName.php | 1 + .../php/SwaggerClient-php/lib/Model/Tag.php | 1 + .../php/SwaggerClient-php/lib/Model/User.php | 1 + .../lib/ObjectSerializer.php | 2 +- .../lib/Tests/AnimalTest.php | 70 +++++++ .../SwaggerClient-php/lib/Tests/CatTest.php | 70 +++++++ .../SwaggerClient-php/lib/Tests/DogTest.php | 70 +++++++ 26 files changed, 969 insertions(+), 143 deletions(-) create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Animal.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Cat.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Dog.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Tests/AnimalTest.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Tests/CatTest.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Tests/DogTest.php diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 7fe80fb8a06..ab466f9a557 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API verion: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-19T16:11:03.465+08:00 +- Build date: 2016-03-28T11:19:00.169+02:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -108,7 +108,10 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [Dog](docs/Dog.md) - [InlineResponse200](docs/InlineResponse200.md) - [Model200Response](docs/Model200Response.md) - [ModelReturn](docs/ModelReturn.md) @@ -123,10 +126,25 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## test_api_key_header +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + +## test_api_client_id - **Type**: API key -- **API key parameter name**: test_api_key_header +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret - **Location**: HTTP header ## api_key @@ -139,32 +157,17 @@ Class | Method | HTTP request | Description - **Type**: HTTP basic authentication -## test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -## test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - ## test_api_key_query - **Type**: API key - **API key parameter name**: test_api_key_query - **Location**: URL query string -## petstore_auth +## test_api_key_header -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account - - **read:pets**: read your pets +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header ## Author diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Animal.md b/samples/client/petstore/php/SwaggerClient-php/docs/Animal.md new file mode 100644 index 00000000000..948a992f502 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Animal.md @@ -0,0 +1,10 @@ +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Cat.md b/samples/client/petstore/php/SwaggerClient-php/docs/Cat.md new file mode 100644 index 00000000000..8d30565d014 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Cat.md @@ -0,0 +1,10 @@ +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Dog.md b/samples/client/petstore/php/SwaggerClient-php/docs/Dog.md new file mode 100644 index 00000000000..3c04bdf4cf7 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Dog.md @@ -0,0 +1,10 @@ +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md index 1c0b9237453..f24bffc16fa 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md @@ -3,12 +3,12 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] +**photo_urls** | **string[]** | | [optional] +**name** | **string** | | [optional] **id** | **int** | | **category** | **object** | | [optional] +**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] **status** | **string** | pet status in the store | [optional] -**name** | **string** | | [optional] -**photo_urls** | **string[]** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index b21d4b595b1..c511fb1082f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -299,7 +299,7 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) ### HTTP reuqest headers @@ -320,12 +320,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -351,7 +351,7 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) ### HTTP reuqest headers @@ -372,12 +372,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -403,7 +403,7 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) ### HTTP reuqest headers diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md index a414755a82d..9f075a56754 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge setApiKey('test_api_key_header', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_header', 'BEARER'); // Configure API key authorization: test_api_key_query Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_query', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_query', 'BEARER'); +// Configure API key authorization: test_api_key_header +Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_header', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_header', 'BEARER'); $api_instance = new Swagger\Client\Api\StoreApi(); $order_id = "order_id_example"; // string | ID of pet that needs to be fetched @@ -247,7 +247,7 @@ Name | Type | Description | Notes ### Authorization -[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) +[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) ### HTTP reuqest headers diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 5c2c0564c70..26ec521f584 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -618,6 +618,11 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -625,11 +630,6 @@ class PetApi } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -725,6 +725,11 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -732,11 +737,6 @@ class PetApi } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -832,6 +832,11 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -839,11 +844,6 @@ class PetApi } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index b510b4a3b6e..3b6b2aa43b6 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -525,16 +525,16 @@ class StoreApi } // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header'); + $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); if (strlen($apiKey) !== 0) { - $headerParams['test_api_key_header'] = $apiKey; + $queryParams['test_api_key_query'] = $apiKey; } // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); + $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header'); if (strlen($apiKey) !== 0) { - $queryParams['test_api_key_query'] = $apiKey; + $headerParams['test_api_key_header'] = $apiKey; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php new file mode 100644 index 00000000000..eaaa566f3be --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php @@ -0,0 +1,191 @@ + 'string' + ); + + static function swaggerTypes() { + return self::$swaggerTypes; + } + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'class_name' => 'className' + ); + + static function attributeMap() { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'class_name' => 'setClassName' + ); + + static function setters() { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'class_name' => 'getClassName' + ); + + static function getters() { + return self::$getters; + } + + + /** + * $class_name + * @var string + */ + protected $class_name; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + + if ($data != null) { + $this->class_name = $data["class_name"]; + } + } + + /** + * Gets class_name + * @return string + */ + public function getClassName() + { + return $this->class_name; + } + + /** + * Sets class_name + * @param string $class_name + * @return $this + */ + public function setClassName($class_name) + { + + $this->class_name = $class_name; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php new file mode 100644 index 00000000000..962f8ec00b6 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php @@ -0,0 +1,191 @@ + 'bool' + ); + + static function swaggerTypes() { + return self::$swaggerTypes + parent::swaggerTypes(); + } + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'declawed' => 'declawed' + ); + + static function attributeMap() { + return parent::attributeMap() + self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'declawed' => 'setDeclawed' + ); + + static function setters() { + return parent::setters() + self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'declawed' => 'getDeclawed' + ); + + static function getters() { + return parent::getters() + self::$getters; + } + + + /** + * $declawed + * @var bool + */ + protected $declawed; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + parent::__construct($data); + if ($data != null) { + $this->declawed = $data["declawed"]; + } + } + + /** + * Gets declawed + * @return bool + */ + public function getDeclawed() + { + return $this->declawed; + } + + /** + * Sets declawed + * @param bool $declawed + * @return $this + */ + public function setDeclawed($declawed) + { + + $this->declawed = $declawed; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php index 7730aeca6ff..65d736ce9d9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php @@ -118,6 +118,7 @@ class Category implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->id = $data["id"]; $this->name = $data["name"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php new file mode 100644 index 00000000000..2aef5757fe3 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php @@ -0,0 +1,191 @@ + 'string' + ); + + static function swaggerTypes() { + return self::$swaggerTypes + parent::swaggerTypes(); + } + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'breed' => 'breed' + ); + + static function attributeMap() { + return parent::attributeMap() + self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'breed' => 'setBreed' + ); + + static function setters() { + return parent::setters() + self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'breed' => 'getBreed' + ); + + static function getters() { + return parent::getters() + self::$getters; + } + + + /** + * $breed + * @var string + */ + protected $breed; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + parent::__construct($data); + if ($data != null) { + $this->breed = $data["breed"]; + } + } + + /** + * Gets breed + * @return string + */ + public function getBreed() + { + return $this->breed; + } + + /** + * Sets breed + * @param string $breed + * @return $this + */ + public function setBreed($breed) + { + + $this->breed = $breed; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php index 6d3fc1259bf..009b633b5a9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -51,12 +51,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $swaggerTypes = array( - 'tags' => '\Swagger\Client\Model\Tag[]', + 'photo_urls' => 'string[]', + 'name' => 'string', 'id' => 'int', 'category' => 'object', - 'status' => 'string', - 'name' => 'string', - 'photo_urls' => 'string[]' + 'tags' => '\Swagger\Client\Model\Tag[]', + 'status' => 'string' ); static function swaggerTypes() { @@ -68,12 +68,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $attributeMap = array( - 'tags' => 'tags', + 'photo_urls' => 'photoUrls', + 'name' => 'name', 'id' => 'id', 'category' => 'category', - 'status' => 'status', - 'name' => 'name', - 'photo_urls' => 'photoUrls' + 'tags' => 'tags', + 'status' => 'status' ); static function attributeMap() { @@ -85,12 +85,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $setters = array( - 'tags' => 'setTags', + 'photo_urls' => 'setPhotoUrls', + 'name' => 'setName', 'id' => 'setId', 'category' => 'setCategory', - 'status' => 'setStatus', - 'name' => 'setName', - 'photo_urls' => 'setPhotoUrls' + 'tags' => 'setTags', + 'status' => 'setStatus' ); static function setters() { @@ -102,12 +102,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $getters = array( - 'tags' => 'getTags', + 'photo_urls' => 'getPhotoUrls', + 'name' => 'getName', 'id' => 'getId', 'category' => 'getCategory', - 'status' => 'getStatus', - 'name' => 'getName', - 'photo_urls' => 'getPhotoUrls' + 'tags' => 'getTags', + 'status' => 'getStatus' ); static function getters() { @@ -116,10 +116,16 @@ class InlineResponse200 implements ArrayAccess /** - * $tags - * @var \Swagger\Client\Model\Tag[] + * $photo_urls + * @var string[] */ - protected $tags; + protected $photo_urls; + + /** + * $name + * @var string + */ + protected $name; /** * $id @@ -133,24 +139,18 @@ class InlineResponse200 implements ArrayAccess */ protected $category; + /** + * $tags + * @var \Swagger\Client\Model\Tag[] + */ + protected $tags; + /** * $status pet status in the store * @var string */ protected $status; - /** - * $name - * @var string - */ - protected $name; - - /** - * $photo_urls - * @var string[] - */ - protected $photo_urls; - /** * Constructor @@ -158,34 +158,56 @@ class InlineResponse200 implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { - $this->tags = $data["tags"]; + $this->photo_urls = $data["photo_urls"]; + $this->name = $data["name"]; $this->id = $data["id"]; $this->category = $data["category"]; + $this->tags = $data["tags"]; $this->status = $data["status"]; - $this->name = $data["name"]; - $this->photo_urls = $data["photo_urls"]; } } /** - * Gets tags - * @return \Swagger\Client\Model\Tag[] + * Gets photo_urls + * @return string[] */ - public function getTags() + public function getPhotoUrls() { - return $this->tags; + return $this->photo_urls; } /** - * Sets tags - * @param \Swagger\Client\Model\Tag[] $tags + * Sets photo_urls + * @param string[] $photo_urls * @return $this */ - public function setTags($tags) + public function setPhotoUrls($photo_urls) { - $this->tags = $tags; + $this->photo_urls = $photo_urls; + return $this; + } + + /** + * Gets name + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name + * @param string $name + * @return $this + */ + public function setName($name) + { + + $this->name = $name; return $this; } @@ -231,6 +253,27 @@ class InlineResponse200 implements ArrayAccess return $this; } + /** + * Gets tags + * @return \Swagger\Client\Model\Tag[] + */ + public function getTags() + { + return $this->tags; + } + + /** + * Sets tags + * @param \Swagger\Client\Model\Tag[] $tags + * @return $this + */ + public function setTags($tags) + { + + $this->tags = $tags; + return $this; + } + /** * Gets status * @return string @@ -255,48 +298,6 @@ class InlineResponse200 implements ArrayAccess return $this; } - /** - * Gets name - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Sets name - * @param string $name - * @return $this - */ - public function setName($name) - { - - $this->name = $name; - return $this; - } - - /** - * Gets photo_urls - * @return string[] - */ - public function getPhotoUrls() - { - return $this->photo_urls; - } - - /** - * Sets photo_urls - * @param string[] $photo_urls - * @return $this - */ - public function setPhotoUrls($photo_urls) - { - - $this->photo_urls = $photo_urls; - return $this; - } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php index 409ad91987d..57cb31c084b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php @@ -108,6 +108,7 @@ class Model200Response implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->name = $data["name"]; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php index 810de6aa856..fd8d1479ca0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -108,6 +108,7 @@ class ModelReturn implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->return = $data["return"]; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php index ee1b6097eae..9b52f9a6c00 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -118,6 +118,7 @@ class Name implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->name = $data["name"]; $this->snake_case = $data["snake_case"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php index b99f8a90600..1c114a8392c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -158,6 +158,7 @@ class Order implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->id = $data["id"]; $this->pet_id = $data["pet_id"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php index 8817c7e6e08..39735aaa428 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -158,6 +158,7 @@ class Pet implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->id = $data["id"]; $this->category = $data["category"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php index 843eb09c2d3..0ce073a43aa 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -108,6 +108,7 @@ class SpecialModelName implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->special_property_name = $data["special_property_name"]; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php index 718f2331c24..129206e9650 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php @@ -118,6 +118,7 @@ class Tag implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->id = $data["id"]; $this->name = $data["name"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php index aa2d62af135..662983d61b9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php @@ -178,6 +178,7 @@ class User implements ArrayAccess */ public function __construct(array $data = null) { + if ($data != null) { $this->id = $data["id"]; $this->username = $data["username"]; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index e0a0efc03ca..7dbd6a55c46 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -257,7 +257,7 @@ class ObjectSerializer } else { $deserialized = null; } - } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { + } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/AnimalTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/AnimalTest.php new file mode 100644 index 00000000000..f66fc54f211 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/AnimalTest.php @@ -0,0 +1,70 @@ + Date: Tue, 29 Mar 2016 00:01:31 -0700 Subject: [PATCH 09/16] fixed output path --- .../java/io/swagger/generator/online/Generator.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java index 9b721d36a4f..0ecd2756fbe 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java @@ -90,10 +90,19 @@ public class Generator { throw new BadRequestException("The swagger specification supplied was not valid"); } + String destPath = null; + + if(opts != null && opts.getOptions() != null) { + destPath = opts.getOptions().get("outputFolder"); + } + if(destPath == null) { + destPath = language + "-" + + type.getTypeName(); + } + ClientOptInput clientOptInput = new ClientOptInput(); ClientOpts clientOpts = new ClientOpts(); - String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-" - + type.getTypeName(); + String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + destPath; String outputFilename = outputFolder + "-bundle.zip"; clientOptInput From d16ae16551757ac981ab762ad4e83d9f0ddad644 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Tue, 29 Mar 2016 23:46:36 -0700 Subject: [PATCH 10/16] updated versions --- modules/swagger-codegen/src/main/resources/Java/pom.mustache | 2 +- .../src/main/resources/JavaInflector/pom.mustache | 2 +- .../src/main/resources/JavaJaxRS/jersey1_18/pom.mustache | 2 +- .../src/main/resources/JavaJaxRS/resteasy/pom.mustache | 2 +- .../src/main/resources/JavaSpringMVC/pom-j8-async.mustache | 2 +- .../src/main/resources/JavaSpringMVC/pom.mustache | 2 +- .../swagger-codegen/src/main/resources/akka-scala/pom.mustache | 2 +- modules/swagger-codegen/src/main/resources/scala/pom.mustache | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 42d6a1299e0..f0dd8c213b0 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -171,7 +171,7 @@ UTF-8 - 1.5.4 + 1.5.8 1.18 2.4.2 2.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache index 491d800923d..a46b1960a67 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache @@ -111,7 +111,7 @@ 1.0.0 - 1.0.4-SNAPSHOT + 1.0.4 9.2.9.v20150224 1.0.1 4.8.2 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache index 14bbfaecb99..180450ce73f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/pom.mustache @@ -168,7 +168,7 @@ - 1.5.7 + 1.5.8 9.2.9.v20150224 1.18.1 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache index ad4c4e7655f..3373c53b2ce 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/pom.mustache @@ -145,7 +145,7 @@ - 1.5.7 + 1.5.8 9.2.9.v20150224 3.0.11.Final 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache index dc18ee3b7fd..257a4611db5 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom-j8-async.mustache @@ -159,7 +159,7 @@ - 1.5.7 + 1.5.8 9.2.9.v20150224 1.13 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index 4d5bceecc68..8cb969102e1 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -118,7 +118,7 @@ - 1.5.7 + 1.5.8 9.2.9.v20150224 1.13 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache index a547542ff21..b7bd04afffb 100644 --- a/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache @@ -217,7 +217,7 @@ 2.3.9 1.2 2.2 - 1.5.7 + 1.5.8 1.0.0 4.8.1 diff --git a/modules/swagger-codegen/src/main/resources/scala/pom.mustache b/modules/swagger-codegen/src/main/resources/scala/pom.mustache index b3260b9fd62..51256c42491 100644 --- a/modules/swagger-codegen/src/main/resources/scala/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/pom.mustache @@ -210,7 +210,7 @@ 1.2 2.2 1.19 - 1.5.7 + 1.5.8 1.0.5 1.0.0 2.4.2 From 20f1e97df3de01658cc52ee6cb308422498a4f1d Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Mar 2016 20:58:18 +0800 Subject: [PATCH 11/16] fix typo in readme --- .../main/resources/Javascript/README.mustache | 2 +- .../src/main/resources/perl/README.mustache | 2 +- .../src/main/resources/php/README.mustache | 2 +- .../src/main/resources/ruby/README.mustache | 2 +- .../petstore/javascript-promise/README.md | 7 +- .../petstore/javascript-promise/src/index.js | 21 ++- samples/client/petstore/javascript/README.md | 7 +- .../client/petstore/javascript/src/index.js | 21 ++- samples/client/petstore/perl/README.md | 13 +- .../perl/lib/WWW/SwaggerClient/Role.pm | 4 +- .../petstore/php/SwaggerClient-php/README.md | 46 ++--- .../docs/InlineResponse200.md | 6 +- .../php/SwaggerClient-php/docs/PetApi.md | 18 +- .../php/SwaggerClient-php/docs/StoreApi.md | 10 +- .../php/SwaggerClient-php/lib/Api/PetApi.php | 30 ++-- .../SwaggerClient-php/lib/Api/StoreApi.php | 8 +- .../lib/Model/InlineResponse200.php | 168 +++++++++--------- .../lib/ObjectSerializer.php | 2 +- samples/client/petstore/ruby/README.md | 7 +- samples/client/petstore/ruby/lib/petstore.rb | 3 + 20 files changed, 215 insertions(+), 164 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache index 767e2a849fd..633f2f0aebb 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache @@ -6,7 +6,7 @@ {{/appDescription}} This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{projectVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index 185859ec4a3..630a0a5979b 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -8,7 +8,7 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{moduleVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index 4088ddf1fbe..8275c4c9d7c 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{artifactVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index 3566329c244..164285e1533 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{gemVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 478bc4657ca..3fc0c158a2a 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -4,9 +4,9 @@ SwaggerPetstore - JavaScript client for 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 This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: 1.0.0 +- API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-24T19:50:42.301+08:00 +- Build date: 2016-03-30T20:58:13.565+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -108,7 +108,10 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [SwaggerPetstore.Animal](docs/Animal.md) + - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.Dog](docs/Dog.md) - [SwaggerPetstore.InlineResponse200](docs/InlineResponse200.md) - [SwaggerPetstore.Model200Response](docs/Model200Response.md) - [SwaggerPetstore.ModelReturn](docs/ModelReturn.md) diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index 4c0cd3040c7..da193f80e4d 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -1,12 +1,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['./ApiClient', './model/Category', './model/InlineResponse200', './model/Model200Response', './model/ModelReturn', './model/Name', './model/Order', './model/Pet', './model/SpecialModelName', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory); + define(['./ApiClient', './model/Animal', './model/Cat', './model/Category', './model/Dog', './model/InlineResponse200', './model/Model200Response', './model/ModelReturn', './model/Name', './model/Order', './model/Pet', './model/SpecialModelName', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/InlineResponse200'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/InlineResponse200'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Category, InlineResponse200, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) { +}(function(ApiClient, Animal, Cat, Category, Dog, InlineResponse200, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -46,11 +46,26 @@ * @property {module:ApiClient} */ ApiClient: ApiClient, + /** + * The Animal model constructor. + * @property {module:model/Animal} + */ + Animal: Animal, + /** + * The Cat model constructor. + * @property {module:model/Cat} + */ + Cat: Cat, /** * The Category model constructor. * @property {module:model/Category} */ Category: Category, + /** + * The Dog model constructor. + * @property {module:model/Dog} + */ + Dog: Dog, /** * The InlineResponse200 model constructor. * @property {module:model/InlineResponse200} diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 2f3f0edb897..0867d3ec1d5 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -4,9 +4,9 @@ SwaggerPetstore - JavaScript client for 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 This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: 1.0.0 +- API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-24T19:50:27.240+08:00 +- Build date: 2016-03-30T20:58:07.996+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -111,7 +111,10 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [SwaggerPetstore.Animal](docs/Animal.md) + - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.Dog](docs/Dog.md) - [SwaggerPetstore.InlineResponse200](docs/InlineResponse200.md) - [SwaggerPetstore.Model200Response](docs/Model200Response.md) - [SwaggerPetstore.ModelReturn](docs/ModelReturn.md) diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 4c0cd3040c7..da193f80e4d 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -1,12 +1,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['./ApiClient', './model/Category', './model/InlineResponse200', './model/Model200Response', './model/ModelReturn', './model/Name', './model/Order', './model/Pet', './model/SpecialModelName', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory); + define(['./ApiClient', './model/Animal', './model/Cat', './model/Category', './model/Dog', './model/InlineResponse200', './model/Model200Response', './model/ModelReturn', './model/Name', './model/Order', './model/Pet', './model/SpecialModelName', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/InlineResponse200'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/InlineResponse200'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Category, InlineResponse200, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) { +}(function(ApiClient, Animal, Cat, Category, Dog, InlineResponse200, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -46,11 +46,26 @@ * @property {module:ApiClient} */ ApiClient: ApiClient, + /** + * The Animal model constructor. + * @property {module:model/Animal} + */ + Animal: Animal, + /** + * The Cat model constructor. + * @property {module:model/Cat} + */ + Cat: Cat, /** * The Category model constructor. * @property {module:model/Category} */ Category: Category, + /** + * The Dog model constructor. + * @property {module:model/Dog} + */ + Dog: Dog, /** * The InlineResponse200 model constructor. * @property {module:model/InlineResponse200} diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 138e62684ab..72fc2e26429 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,9 +8,9 @@ This is a sample server Petstore server. You can find out more about Swagger at Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: 1.0.0 +- API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-19T17:46:21.048+08:00 +- Build date: 2016-03-30T20:57:51.908+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen ## A note on Moose @@ -231,7 +231,10 @@ use WWW::SwaggerClient::UserApi; To load the models: ```perl +use WWW::SwaggerClient::Object::Animal; +use WWW::SwaggerClient::Object::Cat; use WWW::SwaggerClient::Object::Category; +use WWW::SwaggerClient::Object::Dog; use WWW::SwaggerClient::Object::InlineResponse200; use WWW::SwaggerClient::Object::Model200Response; use WWW::SwaggerClient::Object::ModelReturn; @@ -257,7 +260,10 @@ use WWW::SwaggerClient::StoreApi; use WWW::SwaggerClient::UserApi; # load the models +use WWW::SwaggerClient::Object::Animal; +use WWW::SwaggerClient::Object::Cat; use WWW::SwaggerClient::Object::Category; +use WWW::SwaggerClient::Object::Dog; use WWW::SwaggerClient::Object::InlineResponse200; use WWW::SwaggerClient::Object::Model200Response; use WWW::SwaggerClient::Object::ModelReturn; @@ -320,7 +326,10 @@ Class | Method | HTTP request | Description # DOCUMENTATION FOR MODELS + - [WWW::SwaggerClient::Object::Animal](docs/Animal.md) + - [WWW::SwaggerClient::Object::Cat](docs/Cat.md) - [WWW::SwaggerClient::Object::Category](docs/Category.md) + - [WWW::SwaggerClient::Object::Dog](docs/Dog.md) - [WWW::SwaggerClient::Object::InlineResponse200](docs/InlineResponse200.md) - [WWW::SwaggerClient::Object::Model200Response](docs/Model200Response.md) - [WWW::SwaggerClient::Object::ModelReturn](docs/ModelReturn.md) diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 15fb410e8a5..4b1f63cbb2e 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-03-19T17:46:21.048+08:00', + generated_date => '2016-03-30T20:57:51.908+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-03-19T17:46:21.048+08:00 +=item Build date: 2016-03-30T20:57:51.908+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index ab466f9a557..79dbf6ee5bf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -3,9 +3,9 @@ This is a sample server Petstore server. You can find out more about Swagger at This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: 1.0.0 +- API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-28T11:19:00.169+02:00 +- Build date: 2016-03-30T20:57:56.803+08:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -126,25 +126,10 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account - - **read:pets**: read your pets - -## test_api_client_id +## test_api_key_header - **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -## test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret +- **API key parameter name**: test_api_key_header - **Location**: HTTP header ## api_key @@ -157,17 +142,32 @@ Class | Method | HTTP request | Description - **Type**: HTTP basic authentication +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +## test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + ## test_api_key_query - **Type**: API key - **API key parameter name**: test_api_key_query - **Location**: URL query string -## test_api_key_header +## petstore_auth -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets ## Author diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md index f24bffc16fa..1c0b9237453 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md @@ -3,12 +3,12 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**photo_urls** | **string[]** | | [optional] -**name** | **string** | | [optional] +**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] **id** | **int** | | **category** | **object** | | [optional] -**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] **status** | **string** | pet status in the store | [optional] +**name** | **string** | | [optional] +**photo_urls** | **string[]** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index c511fb1082f..b21d4b595b1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -299,7 +299,7 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) ### HTTP reuqest headers @@ -320,12 +320,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -351,7 +351,7 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) ### HTTP reuqest headers @@ -372,12 +372,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond setAccessToken('YOUR_ACCESS_TOKEN'); // Configure API key authorization: api_key Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); +// Configure OAuth2 access token for authorization: petstore_auth +Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); $pet_id = 789; // int | ID of pet that needs to be fetched @@ -403,7 +403,7 @@ Name | Type | Description | Notes ### Authorization -[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) ### HTTP reuqest headers diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md index 9f075a56754..a414755a82d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge setApiKey('test_api_key_query', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_query', 'BEARER'); // Configure API key authorization: test_api_key_header Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_header', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_header', 'BEARER'); +// Configure API key authorization: test_api_key_query +Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_query', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_query', 'BEARER'); $api_instance = new Swagger\Client\Api\StoreApi(); $order_id = "order_id_example"; // string | ID of pet that needs to be fetched @@ -247,7 +247,7 @@ Name | Type | Description | Notes ### Authorization -[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) +[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) ### HTTP reuqest headers diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 26ec521f584..5c2c0564c70 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -618,11 +618,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -630,6 +625,11 @@ class PetApi } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -725,11 +725,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -737,6 +732,11 @@ class PetApi } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -832,11 +832,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (strlen($apiKey) !== 0) { @@ -844,6 +839,11 @@ class PetApi } + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 3b6b2aa43b6..b510b4a3b6e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -525,16 +525,16 @@ class StoreApi } // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); + $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header'); if (strlen($apiKey) !== 0) { - $queryParams['test_api_key_query'] = $apiKey; + $headerParams['test_api_key_header'] = $apiKey; } // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header'); + $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); if (strlen($apiKey) !== 0) { - $headerParams['test_api_key_header'] = $apiKey; + $queryParams['test_api_key_query'] = $apiKey; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php index 009b633b5a9..8efea4018b1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -51,12 +51,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $swaggerTypes = array( - 'photo_urls' => 'string[]', - 'name' => 'string', + 'tags' => '\Swagger\Client\Model\Tag[]', 'id' => 'int', 'category' => 'object', - 'tags' => '\Swagger\Client\Model\Tag[]', - 'status' => 'string' + 'status' => 'string', + 'name' => 'string', + 'photo_urls' => 'string[]' ); static function swaggerTypes() { @@ -68,12 +68,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $attributeMap = array( - 'photo_urls' => 'photoUrls', - 'name' => 'name', + 'tags' => 'tags', 'id' => 'id', 'category' => 'category', - 'tags' => 'tags', - 'status' => 'status' + 'status' => 'status', + 'name' => 'name', + 'photo_urls' => 'photoUrls' ); static function attributeMap() { @@ -85,12 +85,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $setters = array( - 'photo_urls' => 'setPhotoUrls', - 'name' => 'setName', + 'tags' => 'setTags', 'id' => 'setId', 'category' => 'setCategory', - 'tags' => 'setTags', - 'status' => 'setStatus' + 'status' => 'setStatus', + 'name' => 'setName', + 'photo_urls' => 'setPhotoUrls' ); static function setters() { @@ -102,12 +102,12 @@ class InlineResponse200 implements ArrayAccess * @var string[] */ static $getters = array( - 'photo_urls' => 'getPhotoUrls', - 'name' => 'getName', + 'tags' => 'getTags', 'id' => 'getId', 'category' => 'getCategory', - 'tags' => 'getTags', - 'status' => 'getStatus' + 'status' => 'getStatus', + 'name' => 'getName', + 'photo_urls' => 'getPhotoUrls' ); static function getters() { @@ -116,16 +116,10 @@ class InlineResponse200 implements ArrayAccess /** - * $photo_urls - * @var string[] + * $tags + * @var \Swagger\Client\Model\Tag[] */ - protected $photo_urls; - - /** - * $name - * @var string - */ - protected $name; + protected $tags; /** * $id @@ -139,18 +133,24 @@ class InlineResponse200 implements ArrayAccess */ protected $category; - /** - * $tags - * @var \Swagger\Client\Model\Tag[] - */ - protected $tags; - /** * $status pet status in the store * @var string */ protected $status; + /** + * $name + * @var string + */ + protected $name; + + /** + * $photo_urls + * @var string[] + */ + protected $photo_urls; + /** * Constructor @@ -160,54 +160,33 @@ class InlineResponse200 implements ArrayAccess { if ($data != null) { - $this->photo_urls = $data["photo_urls"]; - $this->name = $data["name"]; + $this->tags = $data["tags"]; $this->id = $data["id"]; $this->category = $data["category"]; - $this->tags = $data["tags"]; $this->status = $data["status"]; + $this->name = $data["name"]; + $this->photo_urls = $data["photo_urls"]; } } /** - * Gets photo_urls - * @return string[] + * Gets tags + * @return \Swagger\Client\Model\Tag[] */ - public function getPhotoUrls() + public function getTags() { - return $this->photo_urls; + return $this->tags; } /** - * Sets photo_urls - * @param string[] $photo_urls + * Sets tags + * @param \Swagger\Client\Model\Tag[] $tags * @return $this */ - public function setPhotoUrls($photo_urls) + public function setTags($tags) { - $this->photo_urls = $photo_urls; - return $this; - } - - /** - * Gets name - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Sets name - * @param string $name - * @return $this - */ - public function setName($name) - { - - $this->name = $name; + $this->tags = $tags; return $this; } @@ -253,27 +232,6 @@ class InlineResponse200 implements ArrayAccess return $this; } - /** - * Gets tags - * @return \Swagger\Client\Model\Tag[] - */ - public function getTags() - { - return $this->tags; - } - - /** - * Sets tags - * @param \Swagger\Client\Model\Tag[] $tags - * @return $this - */ - public function setTags($tags) - { - - $this->tags = $tags; - return $this; - } - /** * Gets status * @return string @@ -298,6 +256,48 @@ class InlineResponse200 implements ArrayAccess return $this; } + /** + * Gets name + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name + * @param string $name + * @return $this + */ + public function setName($name) + { + + $this->name = $name; + return $this; + } + + /** + * Gets photo_urls + * @return string[] + */ + public function getPhotoUrls() + { + return $this->photo_urls; + } + + /** + * Sets photo_urls + * @param string[] $photo_urls + * @return $this + */ + public function setPhotoUrls($photo_urls) + { + + $this->photo_urls = $photo_urls; + return $this; + } + /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 7dbd6a55c46..e0a0efc03ca 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -257,7 +257,7 @@ class ObjectSerializer } else { $deserialized = null; } - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index fceba1fc085..9f04158f439 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -6,9 +6,9 @@ This is a sample server Petstore server. You can find out more about Swagger at This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: 1.0.0 +- API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-19T11:13:14.822+08:00 +- Build date: 2016-03-30T20:58:00.549+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -110,7 +110,10 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [Petstore::Animal](docs/Animal.md) + - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) + - [Petstore::Dog](docs/Dog.md) - [Petstore::InlineResponse200](docs/InlineResponse200.md) - [Petstore::Model200Response](docs/Model200Response.md) - [Petstore::ModelReturn](docs/ModelReturn.md) diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index cb1abccf30a..4b848d0c3a0 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -21,7 +21,10 @@ require 'petstore/version' require 'petstore/configuration' # Models +require 'petstore/models/animal' +require 'petstore/models/cat' require 'petstore/models/category' +require 'petstore/models/dog' require 'petstore/models/inline_response_200' require 'petstore/models/model_200_response' require 'petstore/models/model_return' From 2104ef319288bb3e6e3e004b801bcfde868b7ccb Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Mar 2016 21:09:34 +0800 Subject: [PATCH 12/16] doc for new models --- .../client/petstore/javascript/docs/Animal.md | 8 ++++++++ samples/client/petstore/javascript/docs/Cat.md | 8 ++++++++ samples/client/petstore/javascript/docs/Dog.md | 8 ++++++++ samples/client/petstore/perl/docs/Animal.md | 15 +++++++++++++++ samples/client/petstore/perl/docs/Cat.md | 16 ++++++++++++++++ samples/client/petstore/perl/docs/Dog.md | 16 ++++++++++++++++ .../php/SwaggerClient-php/docs/200Response.md | 10 ++++++++++ samples/client/petstore/ruby/docs/Animal.md | 8 ++++++++ samples/client/petstore/ruby/docs/Cat.md | 9 +++++++++ samples/client/petstore/ruby/docs/Dog.md | 9 +++++++++ 10 files changed, 107 insertions(+) create mode 100644 samples/client/petstore/javascript/docs/Animal.md create mode 100644 samples/client/petstore/javascript/docs/Cat.md create mode 100644 samples/client/petstore/javascript/docs/Dog.md create mode 100644 samples/client/petstore/perl/docs/Animal.md create mode 100644 samples/client/petstore/perl/docs/Cat.md create mode 100644 samples/client/petstore/perl/docs/Dog.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/200Response.md create mode 100644 samples/client/petstore/ruby/docs/Animal.md create mode 100644 samples/client/petstore/ruby/docs/Cat.md create mode 100644 samples/client/petstore/ruby/docs/Dog.md diff --git a/samples/client/petstore/javascript/docs/Animal.md b/samples/client/petstore/javascript/docs/Animal.md new file mode 100644 index 00000000000..c37d95695a0 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Animal.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | + + diff --git a/samples/client/petstore/javascript/docs/Cat.md b/samples/client/petstore/javascript/docs/Cat.md new file mode 100644 index 00000000000..8cd391bc911 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Cat.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **Boolean** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/Dog.md b/samples/client/petstore/javascript/docs/Dog.md new file mode 100644 index 00000000000..9253eace011 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Dog.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **String** | | [optional] + + diff --git a/samples/client/petstore/perl/docs/Animal.md b/samples/client/petstore/perl/docs/Animal.md new file mode 100644 index 00000000000..d243a90905d --- /dev/null +++ b/samples/client/petstore/perl/docs/Animal.md @@ -0,0 +1,15 @@ +# WWW::SwaggerClient::Object::Animal + +## Load the model package +```perl +use WWW::SwaggerClient::Object::Animal; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/Cat.md b/samples/client/petstore/perl/docs/Cat.md new file mode 100644 index 00000000000..978e4202394 --- /dev/null +++ b/samples/client/petstore/perl/docs/Cat.md @@ -0,0 +1,16 @@ +# WWW::SwaggerClient::Object::Cat + +## Load the model package +```perl +use WWW::SwaggerClient::Object::Cat; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | +**declawed** | **boolean** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/Dog.md b/samples/client/petstore/perl/docs/Dog.md new file mode 100644 index 00000000000..16e399c3aae --- /dev/null +++ b/samples/client/petstore/perl/docs/Dog.md @@ -0,0 +1,16 @@ +# WWW::SwaggerClient::Object::Dog + +## Load the model package +```perl +use WWW::SwaggerClient::Object::Dog; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | +**breed** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/200Response.md b/samples/client/petstore/php/SwaggerClient-php/docs/200Response.md new file mode 100644 index 00000000000..284a8795c61 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/200Response.md @@ -0,0 +1,10 @@ +# 200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/ruby/docs/Animal.md b/samples/client/petstore/ruby/docs/Animal.md new file mode 100644 index 00000000000..0e262c78726 --- /dev/null +++ b/samples/client/petstore/ruby/docs/Animal.md @@ -0,0 +1,8 @@ +# Petstore::Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | + + diff --git a/samples/client/petstore/ruby/docs/Cat.md b/samples/client/petstore/ruby/docs/Cat.md new file mode 100644 index 00000000000..6b7dfb710df --- /dev/null +++ b/samples/client/petstore/ruby/docs/Cat.md @@ -0,0 +1,9 @@ +# Petstore::Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | +**declawed** | **BOOLEAN** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/Dog.md b/samples/client/petstore/ruby/docs/Dog.md new file mode 100644 index 00000000000..7af6f549d5d --- /dev/null +++ b/samples/client/petstore/ruby/docs/Dog.md @@ -0,0 +1,9 @@ +# Petstore::Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | +**breed** | **String** | | [optional] + + From f23031fc967c9245c2c840496e30154b23b3bfc3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Mar 2016 21:54:38 +0800 Subject: [PATCH 13/16] add new files for JS --- .../javascript-promise/docs/Animal.md | 8 +++ .../petstore/javascript-promise/docs/Cat.md | 8 +++ .../petstore/javascript-promise/docs/Dog.md | 8 +++ .../javascript-promise/src/model/Animal.js | 63 +++++++++++++++++ .../javascript-promise/src/model/Cat.js | 67 +++++++++++++++++++ .../javascript-promise/src/model/Dog.js | 67 +++++++++++++++++++ .../petstore/javascript/src/model/Animal.js | 63 +++++++++++++++++ .../petstore/javascript/src/model/Cat.js | 67 +++++++++++++++++++ .../petstore/javascript/src/model/Dog.js | 67 +++++++++++++++++++ 9 files changed, 418 insertions(+) create mode 100644 samples/client/petstore/javascript-promise/docs/Animal.md create mode 100644 samples/client/petstore/javascript-promise/docs/Cat.md create mode 100644 samples/client/petstore/javascript-promise/docs/Dog.md create mode 100644 samples/client/petstore/javascript-promise/src/model/Animal.js create mode 100644 samples/client/petstore/javascript-promise/src/model/Cat.js create mode 100644 samples/client/petstore/javascript-promise/src/model/Dog.js create mode 100644 samples/client/petstore/javascript/src/model/Animal.js create mode 100644 samples/client/petstore/javascript/src/model/Cat.js create mode 100644 samples/client/petstore/javascript/src/model/Dog.js diff --git a/samples/client/petstore/javascript-promise/docs/Animal.md b/samples/client/petstore/javascript-promise/docs/Animal.md new file mode 100644 index 00000000000..c37d95695a0 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/Animal.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | + + diff --git a/samples/client/petstore/javascript-promise/docs/Cat.md b/samples/client/petstore/javascript-promise/docs/Cat.md new file mode 100644 index 00000000000..8cd391bc911 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/Cat.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **Boolean** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/Dog.md b/samples/client/petstore/javascript-promise/docs/Dog.md new file mode 100644 index 00000000000..9253eace011 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/Dog.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/src/model/Animal.js b/samples/client/petstore/javascript-promise/src/model/Animal.js new file mode 100644 index 00000000000..674471a30ee --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/Animal.js @@ -0,0 +1,63 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Animal = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + /** + * The Animal model module. + * @module model/Animal + * @version 1.0.0 + */ + + /** + * Constructs a new Animal. + * @alias module:model/Animal + * @class + * @param className + */ + var exports = function(className) { + + this['className'] = className; + }; + + /** + * Constructs a Animal from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Animal} obj Optional instance to populate. + * @return {module:model/Animal} The populated Animal instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('className')) { + obj['className'] = ApiClient.convertToType(data['className'], 'String'); + } + } + return obj; + } + + + /** + * @member {String} className + */ + exports.prototype['className'] = undefined; + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript-promise/src/model/Cat.js b/samples/client/petstore/javascript-promise/src/model/Cat.js new file mode 100644 index 00000000000..c878af6edec --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/Cat.js @@ -0,0 +1,67 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient', './Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Cat = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + /** + * The Cat model module. + * @module model/Cat + * @version 1.0.0 + */ + + /** + * Constructs a new Cat. + * @alias module:model/Cat + * @class + * @extends module:model/Animal + * @param className + */ + var exports = function(className) { + Animal.call(this, className); + + }; + + /** + * Constructs a Cat from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Cat} obj Optional instance to populate. + * @return {module:model/Cat} The populated Cat instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + Animal.constructFromObject(data, obj); + if (data.hasOwnProperty('declawed')) { + obj['declawed'] = ApiClient.convertToType(data['declawed'], 'Boolean'); + } + } + return obj; + } + + exports.prototype = Object.create(Animal.prototype); + exports.prototype.constructor = exports; + + + /** + * @member {Boolean} declawed + */ + exports.prototype['declawed'] = undefined; + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript-promise/src/model/Dog.js b/samples/client/petstore/javascript-promise/src/model/Dog.js new file mode 100644 index 00000000000..e5e55581a70 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/Dog.js @@ -0,0 +1,67 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient', './Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Dog = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + /** + * The Dog model module. + * @module model/Dog + * @version 1.0.0 + */ + + /** + * Constructs a new Dog. + * @alias module:model/Dog + * @class + * @extends module:model/Animal + * @param className + */ + var exports = function(className) { + Animal.call(this, className); + + }; + + /** + * Constructs a Dog from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Dog} obj Optional instance to populate. + * @return {module:model/Dog} The populated Dog instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + Animal.constructFromObject(data, obj); + if (data.hasOwnProperty('breed')) { + obj['breed'] = ApiClient.convertToType(data['breed'], 'String'); + } + } + return obj; + } + + exports.prototype = Object.create(Animal.prototype); + exports.prototype.constructor = exports; + + + /** + * @member {String} breed + */ + exports.prototype['breed'] = undefined; + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript/src/model/Animal.js b/samples/client/petstore/javascript/src/model/Animal.js new file mode 100644 index 00000000000..674471a30ee --- /dev/null +++ b/samples/client/petstore/javascript/src/model/Animal.js @@ -0,0 +1,63 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Animal = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + /** + * The Animal model module. + * @module model/Animal + * @version 1.0.0 + */ + + /** + * Constructs a new Animal. + * @alias module:model/Animal + * @class + * @param className + */ + var exports = function(className) { + + this['className'] = className; + }; + + /** + * Constructs a Animal from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Animal} obj Optional instance to populate. + * @return {module:model/Animal} The populated Animal instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('className')) { + obj['className'] = ApiClient.convertToType(data['className'], 'String'); + } + } + return obj; + } + + + /** + * @member {String} className + */ + exports.prototype['className'] = undefined; + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript/src/model/Cat.js b/samples/client/petstore/javascript/src/model/Cat.js new file mode 100644 index 00000000000..c878af6edec --- /dev/null +++ b/samples/client/petstore/javascript/src/model/Cat.js @@ -0,0 +1,67 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient', './Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Cat = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + /** + * The Cat model module. + * @module model/Cat + * @version 1.0.0 + */ + + /** + * Constructs a new Cat. + * @alias module:model/Cat + * @class + * @extends module:model/Animal + * @param className + */ + var exports = function(className) { + Animal.call(this, className); + + }; + + /** + * Constructs a Cat from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Cat} obj Optional instance to populate. + * @return {module:model/Cat} The populated Cat instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + Animal.constructFromObject(data, obj); + if (data.hasOwnProperty('declawed')) { + obj['declawed'] = ApiClient.convertToType(data['declawed'], 'Boolean'); + } + } + return obj; + } + + exports.prototype = Object.create(Animal.prototype); + exports.prototype.constructor = exports; + + + /** + * @member {Boolean} declawed + */ + exports.prototype['declawed'] = undefined; + + + + + return exports; +})); diff --git a/samples/client/petstore/javascript/src/model/Dog.js b/samples/client/petstore/javascript/src/model/Dog.js new file mode 100644 index 00000000000..e5e55581a70 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/Dog.js @@ -0,0 +1,67 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient', './Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Dog = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + /** + * The Dog model module. + * @module model/Dog + * @version 1.0.0 + */ + + /** + * Constructs a new Dog. + * @alias module:model/Dog + * @class + * @extends module:model/Animal + * @param className + */ + var exports = function(className) { + Animal.call(this, className); + + }; + + /** + * Constructs a Dog from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/Dog} obj Optional instance to populate. + * @return {module:model/Dog} The populated Dog instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + Animal.constructFromObject(data, obj); + if (data.hasOwnProperty('breed')) { + obj['breed'] = ApiClient.convertToType(data['breed'], 'String'); + } + } + return obj; + } + + exports.prototype = Object.create(Animal.prototype); + exports.prototype.constructor = exports; + + + /** + * @member {String} breed + */ + exports.prototype['breed'] = undefined; + + + + + return exports; +})); From eef07f4d844938eb3f02adac127bbbf18c8ab146 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Mar 2016 22:38:53 +0800 Subject: [PATCH 14/16] add new files for perl, php, ruby --- .../lib/WWW/SwaggerClient/Object/Animal.pm | 127 +++++++++++++ .../perl/lib/WWW/SwaggerClient/Object/Cat.pm | 136 ++++++++++++++ .../perl/lib/WWW/SwaggerClient/Object/Dog.pm | 136 ++++++++++++++ samples/client/petstore/perl/t/AnimalTest.t | 17 ++ samples/client/petstore/perl/t/CatTest.t | 17 ++ samples/client/petstore/perl/t/DogTest.t | 17 ++ .../petstore/php/SwaggerClient-php/petstore | 0 .../ruby/lib/petstore/models/animal.rb | 165 +++++++++++++++++ .../petstore/ruby/lib/petstore/models/cat.rb | 175 ++++++++++++++++++ .../petstore/ruby/lib/petstore/models/dog.rb | 175 ++++++++++++++++++ .../petstore/ruby/spec/models/animal_spec.rb | 50 +++++ .../petstore/ruby/spec/models/cat_spec.rb | 60 ++++++ .../petstore/ruby/spec/models/dog_spec.rb | 60 ++++++ 13 files changed, 1135 insertions(+) create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm create mode 100644 samples/client/petstore/perl/t/AnimalTest.t create mode 100644 samples/client/petstore/perl/t/CatTest.t create mode 100644 samples/client/petstore/perl/t/DogTest.t create mode 100644 samples/client/petstore/php/SwaggerClient-php/petstore create mode 100644 samples/client/petstore/ruby/lib/petstore/models/animal.rb create mode 100644 samples/client/petstore/ruby/lib/petstore/models/cat.rb create mode 100644 samples/client/petstore/ruby/lib/petstore/models/dog.rb create mode 100644 samples/client/petstore/ruby/spec/models/animal_spec.rb create mode 100644 samples/client/petstore/ruby/spec/models/cat_spec.rb create mode 100644 samples/client/petstore/ruby/spec/models/dog_spec.rb diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm new file mode 100644 index 00000000000..c2e124ad8b4 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm @@ -0,0 +1,127 @@ +package WWW::SwaggerClient::Object::Animal; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +# +# +#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# + +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => '', + class => 'Animal', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'class_name' => { + datatype => 'string', + base_name => 'className', + description => '', + format => '', + read_only => '', + }, + +}); + +__PACKAGE__->swagger_types( { + 'class_name' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'class_name' => 'className' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm new file mode 100644 index 00000000000..05500d61ad0 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm @@ -0,0 +1,136 @@ +package WWW::SwaggerClient::Object::Cat; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +# +# +#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# + +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => '', + class => 'Cat', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'class_name' => { + datatype => 'string', + base_name => 'className', + description => '', + format => '', + read_only => '', + }, + 'declawed' => { + datatype => 'boolean', + base_name => 'declawed', + description => '', + format => '', + read_only => '', + }, + +}); + +__PACKAGE__->swagger_types( { + 'class_name' => 'string', + 'declawed' => 'boolean' +} ); + +__PACKAGE__->attribute_map( { + 'class_name' => 'className', + 'declawed' => 'declawed' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm new file mode 100644 index 00000000000..b4192ec71cd --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm @@ -0,0 +1,136 @@ +package WWW::SwaggerClient::Object::Dog; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +# +# +#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# + +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => '', + class => 'Dog', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'class_name' => { + datatype => 'string', + base_name => 'className', + description => '', + format => '', + read_only => '', + }, + 'breed' => { + datatype => 'string', + base_name => 'breed', + description => '', + format => '', + read_only => '', + }, + +}); + +__PACKAGE__->swagger_types( { + 'class_name' => 'string', + 'breed' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'class_name' => 'className', + 'breed' => 'breed' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/t/AnimalTest.t b/samples/client/petstore/perl/t/AnimalTest.t new file mode 100644 index 00000000000..7d608e30803 --- /dev/null +++ b/samples/client/petstore/perl/t/AnimalTest.t @@ -0,0 +1,17 @@ +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test case below to test the model. + +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::Animal'); + +my $instance = WWW::SwaggerClient::Object::Animal->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::Animal'); + diff --git a/samples/client/petstore/perl/t/CatTest.t b/samples/client/petstore/perl/t/CatTest.t new file mode 100644 index 00000000000..cc1569cab40 --- /dev/null +++ b/samples/client/petstore/perl/t/CatTest.t @@ -0,0 +1,17 @@ +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test case below to test the model. + +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::Cat'); + +my $instance = WWW::SwaggerClient::Object::Cat->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::Cat'); + diff --git a/samples/client/petstore/perl/t/DogTest.t b/samples/client/petstore/perl/t/DogTest.t new file mode 100644 index 00000000000..d99225a0592 --- /dev/null +++ b/samples/client/petstore/perl/t/DogTest.t @@ -0,0 +1,17 @@ +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test case below to test the model. + +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::Dog'); + +my $instance = WWW::SwaggerClient::Object::Dog->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::Dog'); + diff --git a/samples/client/petstore/php/SwaggerClient-php/petstore b/samples/client/petstore/php/SwaggerClient-php/petstore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb new file mode 100644 index 00000000000..cf5fa7c1c94 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -0,0 +1,165 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'date' + +module Petstore + class Animal + attr_accessor :class_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + + :'class_name' => :'className' + + } + end + + # Attribute type mapping. + def self.swagger_types + { + :'class_name' => :'String' + + } + end + + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'className'] + self.class_name = attributes[:'className'] + end + + end + + # Check equality by comparing each attribute. + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name + end + + # @see the `==` method + def eql?(o) + self == o + end + + # Calculate hash code according to all attributes. + def hash + [class_name].hash + 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 :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /^(true|t|yes|y|1)$/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + _model = Petstore.const_get(type).new + _model.build_from_hash(value) + end + end + + def to_s + to_hash.to_s + end + + # to_body is an alias to to_body (backward compatibility)) + def to_body + to_hash + end + + # return the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + 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.is_a?(Array) + value.compact.map{ |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb new file mode 100644 index 00000000000..db40e8eab2c --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -0,0 +1,175 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'date' + +module Petstore + class Cat + attr_accessor :class_name + + attr_accessor :declawed + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + + :'class_name' => :'className', + + :'declawed' => :'declawed' + + } + end + + # Attribute type mapping. + def self.swagger_types + { + :'class_name' => :'String', + :'declawed' => :'BOOLEAN' + + } + end + + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'className'] + self.class_name = attributes[:'className'] + end + + if attributes[:'declawed'] + self.declawed = attributes[:'declawed'] + end + + end + + # Check equality by comparing each attribute. + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name && + declawed == o.declawed + end + + # @see the `==` method + def eql?(o) + self == o + end + + # Calculate hash code according to all attributes. + def hash + [class_name, declawed].hash + 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 :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /^(true|t|yes|y|1)$/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + _model = Petstore.const_get(type).new + _model.build_from_hash(value) + end + end + + def to_s + to_hash.to_s + end + + # to_body is an alias to to_body (backward compatibility)) + def to_body + to_hash + end + + # return the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + 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.is_a?(Array) + value.compact.map{ |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb new file mode 100644 index 00000000000..a7f19f2b913 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -0,0 +1,175 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'date' + +module Petstore + class Dog + attr_accessor :class_name + + attr_accessor :breed + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + + :'class_name' => :'className', + + :'breed' => :'breed' + + } + end + + # Attribute type mapping. + def self.swagger_types + { + :'class_name' => :'String', + :'breed' => :'String' + + } + end + + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'className'] + self.class_name = attributes[:'className'] + end + + if attributes[:'breed'] + self.breed = attributes[:'breed'] + end + + end + + # Check equality by comparing each attribute. + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name && + breed == o.breed + end + + # @see the `==` method + def eql?(o) + self == o + end + + # Calculate hash code according to all attributes. + def hash + [class_name, breed].hash + 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 :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /^(true|t|yes|y|1)$/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + _model = Petstore.const_get(type).new + _model.build_from_hash(value) + end + end + + def to_s + to_hash.to_s + end + + # to_body is an alias to to_body (backward compatibility)) + def to_body + to_hash + end + + # return the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + 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.is_a?(Array) + value.compact.map{ |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/samples/client/petstore/ruby/spec/models/animal_spec.rb b/samples/client/petstore/ruby/spec/models/animal_spec.rb new file mode 100644 index 00000000000..ddbfeca85f9 --- /dev/null +++ b/samples/client/petstore/ruby/spec/models/animal_spec.rb @@ -0,0 +1,50 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Animal +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Animal' do + before do + # run before each test + @instance = Petstore::Animal.new + end + + after do + # run after each test + end + + describe 'test an instance of Animal' do + it 'should create an instact of Animal' do + @instance.should be_a(Petstore::Animal) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end + diff --git a/samples/client/petstore/ruby/spec/models/cat_spec.rb b/samples/client/petstore/ruby/spec/models/cat_spec.rb new file mode 100644 index 00000000000..220a37dfebe --- /dev/null +++ b/samples/client/petstore/ruby/spec/models/cat_spec.rb @@ -0,0 +1,60 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Cat +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Cat' do + before do + # run before each test + @instance = Petstore::Cat.new + end + + after do + # run after each test + end + + describe 'test an instance of Cat' do + it 'should create an instact of Cat' do + @instance.should be_a(Petstore::Cat) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + describe 'test attribute "declawed"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end + diff --git a/samples/client/petstore/ruby/spec/models/dog_spec.rb b/samples/client/petstore/ruby/spec/models/dog_spec.rb new file mode 100644 index 00000000000..23b1b9a83f7 --- /dev/null +++ b/samples/client/petstore/ruby/spec/models/dog_spec.rb @@ -0,0 +1,60 @@ +=begin +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 + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Dog +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Dog' do + before do + # run before each test + @instance = Petstore::Dog.new + end + + after do + # run after each test + end + + describe 'test an instance of Dog' do + it 'should create an instact of Dog' do + @instance.should be_a(Petstore::Dog) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + describe 'test attribute "breed"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end + From f521d6e166ba820793c4d008b3548d9dbe03d26f Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 31 Mar 2016 16:52:00 +0800 Subject: [PATCH 15/16] minor fix to docstring in csharp --- .../resources/csharp/Configuration.mustache | 1 + .../main/resources/csharp/enumClass.mustache | 4 ++-- .../src/main/resources/csharp/model.mustache | 8 ++++++-- .../Lib/SwaggerClient.Test/NameTests.cs | 9 +++++++++ .../csharp/IO/Swagger/Client/Configuration.cs | 1 + .../IO/Swagger/Model/InlineResponse200.cs | 5 +++++ .../src/main/csharp/IO/Swagger/Model/Name.cs | 19 ++++++++++++++++++- .../src/main/csharp/IO/Swagger/Model/Order.cs | 5 +++++ .../src/main/csharp/IO/Swagger/Model/Pet.cs | 5 +++++ .../SwaggerClientTest.userprefs | 2 +- 10 files changed, 53 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index c9636d2ffda..f9c492a28ec 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -25,6 +25,7 @@ namespace {{packageName}}.Client /// Temp folder path /// DateTime format string /// HTTP connection timeout (in milliseconds) + /// HTTP user agent public Configuration(ApiClient apiClient = null, Dictionary defaultHeader = null, string username = null, diff --git a/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache b/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache index 3a2a93cd109..d882e33595c 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache @@ -1,6 +1,6 @@ -public enum {{vendorExtensions.plainDatatypeWithEnum}} { + public enum {{vendorExtensions.plainDatatypeWithEnum}} { {{#allowableValues}}{{#enumVars}} [EnumMember(Value = "{{jsonname}}")] {{name}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}{{/allowableValues}} - } \ No newline at end of file + } diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index f1f9b7c9753..347834f329a 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -20,9 +20,13 @@ namespace {{packageName}}.Model public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}> { {{#vars}}{{#isEnum}} + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + /// {{#description}} + /// {{{description}}}{{/description}} [JsonConverter(typeof(StringEnumConverter))] - {{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} - {{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}} +{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} +{{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}} {{#vars}}{{#isEnum}} /// /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs index 4937b2affa2..561197ab9f1 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs @@ -60,6 +60,15 @@ namespace IO.Swagger.Test // TODO: unit test for the property '_Name' } + /// + /// Test the property 'SnakeCase' + /// + [Test] + public void SnakeCaseTest() + { + // TODO: unit test for the property 'SnakeCase' + } + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs index 3e9ea2c036c..4d04d5770ec 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs @@ -25,6 +25,7 @@ namespace IO.Swagger.Client /// Temp folder path /// DateTime format string /// HTTP connection timeout (in milliseconds) + /// HTTP user agent public Configuration(ApiClient apiClient = null, Dictionary defaultHeader = null, string username = null, diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs index 53d161c1ab6..8889cdae0a7 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/InlineResponse200.cs @@ -18,6 +18,10 @@ namespace IO.Swagger.Model public partial class InlineResponse200 : IEquatable { + /// + /// pet status in the store + /// + /// pet status in the store [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { @@ -30,6 +34,7 @@ namespace IO.Swagger.Model [EnumMember(Value = "sold")] Sold } + /// /// pet status in the store diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs index 3c8ccadcedd..55fd01dfb97 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs @@ -23,10 +23,12 @@ namespace IO.Swagger.Model /// Initializes a new instance of the class. /// /// _Name. + /// SnakeCase. - public Name(int? _Name = null) + public Name(int? _Name = null, int? SnakeCase = null) { this._Name = _Name; + this.SnakeCase = SnakeCase; } @@ -37,6 +39,12 @@ namespace IO.Swagger.Model [DataMember(Name="name", EmitDefaultValue=false)] public int? _Name { get; set; } + /// + /// Gets or Sets SnakeCase + /// + [DataMember(Name="snake_case", EmitDefaultValue=false)] + public int? SnakeCase { get; set; } + /// /// Returns the string presentation of the object /// @@ -46,6 +54,7 @@ namespace IO.Swagger.Model var sb = new StringBuilder(); sb.Append("class Name {\n"); sb.Append(" _Name: ").Append(_Name).Append("\n"); + sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -87,6 +96,11 @@ namespace IO.Swagger.Model this._Name == other._Name || this._Name != null && this._Name.Equals(other._Name) + ) && + ( + this.SnakeCase == other.SnakeCase || + this.SnakeCase != null && + this.SnakeCase.Equals(other.SnakeCase) ); } @@ -105,6 +119,9 @@ namespace IO.Swagger.Model if (this._Name != null) hash = hash * 59 + this._Name.GetHashCode(); + if (this.SnakeCase != null) + hash = hash * 59 + this.SnakeCase.GetHashCode(); + return hash; } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs index 4fc561c6786..db712c98181 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs @@ -18,6 +18,10 @@ namespace IO.Swagger.Model public partial class Order : IEquatable { + /// + /// Order Status + /// + /// Order Status [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { @@ -30,6 +34,7 @@ namespace IO.Swagger.Model [EnumMember(Value = "delivered")] Delivered } + /// /// Order Status diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs index b206c3fa550..5d30c24af78 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs @@ -18,6 +18,10 @@ namespace IO.Swagger.Model public partial class Pet : IEquatable { + /// + /// pet status in the store + /// + /// pet status in the store [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum { @@ -30,6 +34,7 @@ namespace IO.Swagger.Model [EnumMember(Value = "sold")] Sold } + /// /// pet status in the store diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index e92a0ffc060..c507559e57d 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,7 +2,7 @@ - + From 13712ee5bc03ba989044f1fbd6841cfaf4b43ba3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 31 Mar 2016 16:53:12 +0800 Subject: [PATCH 16/16] add new model in csharp --- .../main/csharp/IO/Swagger/Model/Animal.cs | 121 +++++++++++++++ .../src/main/csharp/IO/Swagger/Model/Cat.cs | 138 ++++++++++++++++++ .../src/main/csharp/IO/Swagger/Model/Dog.cs | 138 ++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs create mode 100644 samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs create mode 100644 samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs new file mode 100644 index 00000000000..0d5bbd4aa60 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Animal.cs @@ -0,0 +1,121 @@ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public partial class Animal : IEquatable + { + + /// + /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + /// ClassName (required). + + public Animal(string ClassName = null) + { + // to ensure "ClassName" is required (not null) + if (ClassName == null) + { + throw new InvalidDataException("ClassName is a required property for Animal and cannot be null"); + } + else + { + this.ClassName = ClassName; + } + + } + + + /// + /// Gets or Sets ClassName + /// + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as Animal); + } + + /// + /// Returns true if Animal instances are equal + /// + /// Instance of Animal to be compared + /// Boolean + public bool Equals(Animal other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.ClassName == other.ClassName || + this.ClassName != null && + this.ClassName.Equals(other.ClassName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + + if (this.ClassName != null) + hash = hash * 59 + this.ClassName.GetHashCode(); + + return hash; + } + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs new file mode 100644 index 00000000000..8d62273892c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Cat.cs @@ -0,0 +1,138 @@ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public partial class Cat : Animal, IEquatable + { + + /// + /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + /// ClassName (required). + /// Declawed. + + public Cat(string ClassName = null, bool? Declawed = null) + { + // to ensure "ClassName" is required (not null) + if (ClassName == null) + { + throw new InvalidDataException("ClassName is a required property for Cat and cannot be null"); + } + else + { + this.ClassName = ClassName; + } + this.Declawed = Declawed; + + } + + + /// + /// Gets or Sets ClassName + /// + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Declawed + /// + [DataMember(Name="declawed", EmitDefaultValue=false)] + public bool? Declawed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as Cat); + } + + /// + /// Returns true if Cat instances are equal + /// + /// Instance of Cat to be compared + /// Boolean + public bool Equals(Cat other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.ClassName == other.ClassName || + this.ClassName != null && + this.ClassName.Equals(other.ClassName) + ) && + ( + this.Declawed == other.Declawed || + this.Declawed != null && + this.Declawed.Equals(other.Declawed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + + if (this.ClassName != null) + hash = hash * 59 + this.ClassName.GetHashCode(); + + if (this.Declawed != null) + hash = hash * 59 + this.Declawed.GetHashCode(); + + return hash; + } + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs new file mode 100644 index 00000000000..2308b7488f1 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Dog.cs @@ -0,0 +1,138 @@ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public partial class Dog : Animal, IEquatable + { + + /// + /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + /// ClassName (required). + /// Breed. + + public Dog(string ClassName = null, string Breed = null) + { + // to ensure "ClassName" is required (not null) + if (ClassName == null) + { + throw new InvalidDataException("ClassName is a required property for Dog and cannot be null"); + } + else + { + this.ClassName = ClassName; + } + this.Breed = Breed; + + } + + + /// + /// Gets or Sets ClassName + /// + [DataMember(Name="className", EmitDefaultValue=false)] + public string ClassName { get; set; } + + /// + /// Gets or Sets Breed + /// + [DataMember(Name="breed", EmitDefaultValue=false)] + public string Breed { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as Dog); + } + + /// + /// Returns true if Dog instances are equal + /// + /// Instance of Dog to be compared + /// Boolean + public bool Equals(Dog other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.ClassName == other.ClassName || + this.ClassName != null && + this.ClassName.Equals(other.ClassName) + ) && + ( + this.Breed == other.Breed || + this.Breed != null && + this.Breed.Equals(other.Breed) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + + if (this.ClassName != null) + hash = hash * 59 + this.ClassName.GetHashCode(); + + if (this.Breed != null) + hash = hash * 59 + this.Breed.GetHashCode(); + + return hash; + } + } + + } +}