From 65d677c3856841c129b0baaae8e03877316e18c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Mon, 28 Mar 2016 22:39:22 +0200 Subject: [PATCH 1/2] Set discriminator property in constructor When using inheritance let the constructor set the discriminator property to the model name. This avoids redundant and error prone stuff like: ``` $animal = new \Swagger\Client\Model\Dog(); $animal->setClassName('Dog'); ``` --- .../src/main/resources/php/model.mustache | 11 +++++++++++ .../php/SwaggerClient-php/tests/PetApiTest.php | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index f19787f50b0..6f292e854af 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -48,6 +48,12 @@ use \ArrayAccess; */ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = '{{name}}'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -115,6 +121,11 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA public function __construct(array $data = null) { {{#parent}}parent::__construct($data);{{/parent}} + {{#discriminator}}// Initialize discriminator property with the model name. + $discrimintor = array_search('{{discriminator}}', self::$attributeMap); + $this->{$discrimintor} = static::$swaggerModelName; + {{/discriminator}} + if ($data != null) { {{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}} {{/hasMore}}{{/vars}} diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 3af1064f711..240f32eca4f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -402,6 +402,13 @@ class PetApiTest extends \PHPUnit_Framework_TestCase $this->assertSame('Dog', $new_dog->getClassName()); } + // test if discriminator is initialized automatically + public function testDiscriminatorInitialization() + { + $new_dog = new Swagger\Client\Model\Dog(); + $this->assertSame('Dog', $new_dog->getClassName()); + } + } ?> From 747f6ba0bb6a3aa6d7d5f494ab965ca9b8386425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 9 Apr 2016 21:05:45 +0200 Subject: [PATCH 2/2] Regenerate PHP petstore sample --- .../petstore/php/SwaggerClient-php/README.md | 45 ++--- .../docs/InlineResponse200.md | 6 +- .../php/SwaggerClient-php/docs/Name.md | 2 +- .../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 | 10 ++ .../php/SwaggerClient-php/lib/Model/Cat.php | 7 + .../SwaggerClient-php/lib/Model/Category.php | 7 + .../php/SwaggerClient-php/lib/Model/Dog.php | 7 + .../lib/Model/InlineResponse200.php | 167 +++++++++--------- .../lib/Model/Model200Response.php | 7 + .../lib/Model/ModelReturn.php | 7 + .../php/SwaggerClient-php/lib/Model/Name.php | 7 + .../php/SwaggerClient-php/lib/Model/Order.php | 7 + .../php/SwaggerClient-php/lib/Model/Pet.php | 7 + .../lib/Model/SpecialModelName.php | 7 + .../php/SwaggerClient-php/lib/Model/Tag.php | 7 + .../php/SwaggerClient-php/lib/Model/User.php | 7 + .../lib/ObjectSerializer.php | 2 +- 21 files changed, 235 insertions(+), 140 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 37f92af6e6f..7d6270ded9d 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 version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-09T18:00:55.578+08:00 +- Build date: 2016-04-09T21:05:22.902+02:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -112,6 +112,7 @@ Class | Method | HTTP request | Description - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [Dog](docs/Dog.md) + - [FormatTest](docs/FormatTest.md) - [InlineResponse200](docs/InlineResponse200.md) - [Model200Response](docs/Model200Response.md) - [ModelReturn](docs/ModelReturn.md) @@ -126,10 +127,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 @@ -142,32 +158,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/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/Name.md b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md index 26473221c32..905680a7d30 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **int** | | [optional] +**name** | **int** | | **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/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index 9164cd27876..0b7399a9de4 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 c60ac603299..6d5ff246add 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 4661a5b3bd8..c3349d738f5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -593,17 +593,17 @@ 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) { $headerParams['api_key'] = $apiKey; } - - // 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( @@ -695,17 +695,17 @@ 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) { $headerParams['api_key'] = $apiKey; } - - // 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( @@ -797,17 +797,17 @@ 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) { $headerParams['api_key'] = $apiKey; } - - // 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 387cd476c55..e3c77f44c9b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -506,16 +506,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; } // make the API Call diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php index c267c81b18e..3f01e789547 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Animal implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Animal'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,10 @@ class Animal implements ArrayAccess public function __construct(array $data = null) { + // Initialize discriminator property with the model name. + $discrimintor = array_search('className', self::$attributeMap); + $this->{$discrimintor} = static::$swaggerModelName; + if ($data != null) { $this->class_name = $data["class_name"]; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php index 79acd0d1f22..e0eaf7a106d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Cat extends Animal implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Cat'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,7 @@ class Cat extends Animal implements ArrayAccess public function __construct(array $data = null) { parent::__construct($data); + if ($data != null) { $this->declawed = $data["declawed"]; } 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 0f359589d0e..fb6eed3af29 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Category implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Category'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -116,6 +122,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 index d12bde293fd..6fd43d3a944 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Dog extends Animal implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Dog'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,7 @@ class Dog extends Animal implements ArrayAccess public function __construct(array $data = null) { parent::__construct($data); + if ($data != null) { $this->breed = $data["breed"]; } 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 c3bb9d03315..481702a6905 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -46,17 +46,23 @@ use \ArrayAccess; */ class InlineResponse200 implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'inline_response_200'; + /** * Array of property to type mappings. Used for (de)serialization * @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 +74,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 +91,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 +108,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() { @@ -115,10 +121,15 @@ 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 * @var int @@ -129,21 +140,16 @@ class InlineResponse200 implements ArrayAccess * @var object */ 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 @@ -152,33 +158,54 @@ 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; } /** @@ -221,6 +248,26 @@ class InlineResponse200 implements ArrayAccess $this->category = $category; 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 @@ -244,46 +291,6 @@ class InlineResponse200 implements ArrayAccess $this->status = $status; 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 a2b4d7691ed..8d62f9531ec 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Model200Response implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = '200_response'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,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 d92e61cdcd6..d4660e118fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class ModelReturn implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Return'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,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 dbe1349ab88..c44cda7b709 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Name implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Name'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -116,6 +122,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 ae29bd61271..a2dfe600950 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Order implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Order'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -152,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 7a790869349..3a9e46cd3fb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Pet implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Pet'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -152,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 25248d949cf..fb748811cf2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class SpecialModelName implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = '$special[model.name]'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -107,6 +113,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 8396a774e80..4bb56401c48 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class Tag implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'Tag'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -116,6 +122,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 6e5c7de36f3..da9cc20ff4c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php @@ -46,6 +46,12 @@ use \ArrayAccess; */ class User implements ArrayAccess { + /** + * The original name of the model. + * @var string + */ + static $swaggerModelName = 'User'; + /** * Array of property to type mappings. Used for (de)serialization * @var string[] @@ -170,6 +176,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 3adaa899f5f..ac63c18fbd5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -256,7 +256,7 @@ class ObjectSerializer } else { return 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); return $data; } elseif ($class === '\SplFileObject') {