From 652099ab71c000cbdc62edc1a9352b8cea98d8b7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 19 Mar 2016 17:02:51 +0800 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] [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 8/9] 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 9/9] 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