diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 39f43b94dbb6..c756dda55686 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,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-17T17:35:57.786+08:00 +- Build date: 2016-03-18T00:51:26.562+01:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -121,10 +121,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 @@ -137,32 +152,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 1c0b9237453b..f24bffc16fa6 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 3f37b7a41498..ab24be1f1525 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::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\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::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\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::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\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 cc4a5600f044..a33154ee754e 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::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER'); // Configure API key authorization: test_api_key_query Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_query', 'BEARER'); +// Configure API key authorization: test_api_key_header +Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER'); $api_instance = new Swagger\Client\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 5c2c0564c709..26ec521f5840 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 b510b4a3b6e4..3b6b2aa43b67 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/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php index 723617198b5d..7730aeca6ffe 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php @@ -55,6 +55,10 @@ class Category implements ArrayAccess 'name' => '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[] @@ -64,6 +68,10 @@ class Category implements ArrayAccess 'name' => 'name' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -73,6 +81,10 @@ class Category implements ArrayAccess 'name' => 'setName' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -82,6 +94,10 @@ class Category implements ArrayAccess 'name' => 'getName' ); + static function getters() { + return self::$getters; + } + /** * $id 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 321f400d0f4f..a3acd422e2cf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -51,59 +51,81 @@ 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() { + 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( - '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() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @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() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @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() { + return self::$getters; + } + /** - * $tags - * @var \Swagger\Client\Model\Tag[] + * $photo_urls + * @var string[] */ - protected $tags; + protected $photo_urls; + + /** + * $name + * @var string + */ + protected $name; /** * $id @@ -117,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 @@ -143,33 +159,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; } @@ -215,6 +252,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 @@ -239,48 +297,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 d4c1c9a69e2a..409ad91987de 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php @@ -54,6 +54,10 @@ class Model200Response implements ArrayAccess 'name' => 'int' ); + 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[] @@ -62,6 +66,10 @@ class Model200Response implements ArrayAccess 'name' => 'name' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -70,6 +78,10 @@ class Model200Response implements ArrayAccess 'name' => 'setName' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -78,6 +90,10 @@ class Model200Response implements ArrayAccess 'name' => 'getName' ); + static function getters() { + return self::$getters; + } + /** * $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 7c5bcf97f3f7..810de6aa8569 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -54,6 +54,10 @@ class ModelReturn implements ArrayAccess 'return' => 'int' ); + 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[] @@ -62,6 +66,10 @@ class ModelReturn implements ArrayAccess 'return' => 'return' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -70,6 +78,10 @@ class ModelReturn implements ArrayAccess 'return' => 'setReturn' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -78,6 +90,10 @@ class ModelReturn implements ArrayAccess 'return' => 'getReturn' ); + static function getters() { + return self::$getters; + } + /** * $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 025984924c38..f4e6f1b14a7f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -54,6 +54,10 @@ class Name implements ArrayAccess 'name' => 'int' ); + 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[] @@ -62,6 +66,10 @@ class Name implements ArrayAccess 'name' => 'name' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -70,6 +78,10 @@ class Name implements ArrayAccess 'name' => 'setName' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -78,6 +90,10 @@ class Name implements ArrayAccess 'name' => 'getName' ); + static function getters() { + return self::$getters; + } + /** * $name diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php deleted file mode 100644 index bb0dd8427060..000000000000 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php +++ /dev/null @@ -1,174 +0,0 @@ - 'int' - ); - - /** - * Array of attributes where the key is the local name, and the value is the original name - * @var string[] - */ - static $attributeMap = array( - 'return' => 'return' - ); - - /** - * Array of attributes to setter functions (for deserialization of responses) - * @var string[] - */ - static $setters = array( - 'return' => 'setReturn' - ); - - /** - * Array of attributes to getter functions (for serialization of requests) - * @var string[] - */ - static $getters = array( - 'return' => 'getReturn' - ); - - - /** - * $return - * @var int - */ - protected $return; - - - /** - * Constructor - * @param mixed[] $data Associated array of property value initalizing the model - */ - public function __construct(array $data = null) - { - if ($data != null) { - $this->return = $data["return"]; - } - } - - /** - * Gets return - * @return int - */ - public function getReturn() - { - return $this->return; - } - - /** - * Sets return - * @param int $return - * @return $this - */ - public function setReturn($return) - { - - $this->return = $return; - 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/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php index f2540992e2df..b99f8a90600c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -59,6 +59,10 @@ class Order implements ArrayAccess 'complete' => 'bool' ); + 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[] @@ -72,6 +76,10 @@ class Order implements ArrayAccess 'complete' => 'complete' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -85,6 +93,10 @@ class Order implements ArrayAccess 'complete' => 'setComplete' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -98,6 +110,10 @@ class Order implements ArrayAccess 'complete' => 'getComplete' ); + static function getters() { + return self::$getters; + } + /** * $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 aa8c6d67a8f5..8817c7e6e086 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -59,6 +59,10 @@ class Pet implements ArrayAccess 'status' => '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[] @@ -72,6 +76,10 @@ class Pet implements ArrayAccess 'status' => 'status' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -85,6 +93,10 @@ class Pet implements ArrayAccess 'status' => 'setStatus' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -98,6 +110,10 @@ class Pet implements ArrayAccess 'status' => 'getStatus' ); + static function getters() { + return self::$getters; + } + /** * $id 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 52de7d068632..843eb09c2d37 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -54,6 +54,10 @@ class SpecialModelName implements ArrayAccess 'special_property_name' => 'int' ); + 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[] @@ -62,6 +66,10 @@ class SpecialModelName implements ArrayAccess 'special_property_name' => '$special[property.name]' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -70,6 +78,10 @@ class SpecialModelName implements ArrayAccess 'special_property_name' => 'setSpecialPropertyName' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -78,6 +90,10 @@ class SpecialModelName implements ArrayAccess 'special_property_name' => 'getSpecialPropertyName' ); + static function getters() { + return self::$getters; + } + /** * $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 7288e39eff93..718f2331c24f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php @@ -55,6 +55,10 @@ class Tag implements ArrayAccess 'name' => '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[] @@ -64,6 +68,10 @@ class Tag implements ArrayAccess 'name' => 'name' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -73,6 +81,10 @@ class Tag implements ArrayAccess 'name' => 'setName' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -82,6 +94,10 @@ class Tag implements ArrayAccess 'name' => 'getName' ); + static function getters() { + return self::$getters; + } + /** * $id 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 7de225ec7442..aa2d62af135f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php @@ -61,6 +61,10 @@ class User implements ArrayAccess 'user_status' => 'int' ); + 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[] @@ -76,6 +80,10 @@ class User implements ArrayAccess 'user_status' => 'userStatus' ); + static function attributeMap() { + return self::$attributeMap; + } + /** * Array of attributes to setter functions (for deserialization of responses) * @var string[] @@ -91,6 +99,10 @@ class User implements ArrayAccess 'user_status' => 'setUserStatus' ); + static function setters() { + return self::$setters; + } + /** * Array of attributes to getter functions (for serialization of requests) * @var string[] @@ -106,6 +118,10 @@ class User implements ArrayAccess 'user_status' => 'getUserStatus' ); + static function getters() { + return self::$getters; + } + /** * $id diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 480e0845fa0d..7dbd6a55c467 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -65,10 +65,10 @@ class ObjectSerializer $sanitized = $data; } elseif (is_object($data)) { $values = array(); - foreach (array_keys($data::$swaggerTypes) as $property) { - $getter = $data::$getters[$property]; + foreach (array_keys($data::swaggerTypes()) as $property) { + $getter = $data::getters()[$property]; if ($data->$getter() !== null) { - $values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter()); + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->$getter()); } } $sanitized = (object)$values; @@ -214,13 +214,14 @@ class ObjectSerializer /** * Deserialize a JSON string into an object * - * @param mixed $data object or primitive to be deserialized - * @param string $class class name is passed as a string - * @param string $httpHeaders HTTP headers + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string $httpHeaders HTTP headers + * @param string $discriminator discriminator if polymorphism is used * * @return object an instance of $class */ - public static function deserialize($data, $class, $httpHeaders=null) + public static function deserialize($data, $class, $httpHeaders=null, $discriminator=null) { if (null === $data) { $deserialized = null; @@ -231,14 +232,14 @@ class ObjectSerializer $subClass_array = explode(',', $inner, 2); $subClass = $subClass_array[1]; foreach ($data as $key => $value) { - $deserialized[$key] = self::deserialize($value, $subClass); + $deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator); } } } elseif (strcasecmp(substr($class, -2), '[]') == 0) { $subClass = substr($class, 0, -2); $values = array(); foreach ($data as $key => $value) { - $values[] = self::deserialize($value, $subClass); + $values[] = self::deserialize($value, $subClass, null, $discriminator); } $deserialized = $values; } elseif ($class === 'object') { @@ -256,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') { @@ -271,17 +272,24 @@ class ObjectSerializer error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile()); } else { + // If a discriminator is defined and points to a valid subclass, use it. + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\Swagger\Client\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } $instance = new $class(); - foreach ($instance::$swaggerTypes as $property => $type) { - $propertySetter = $instance::$setters[$property]; + foreach ($instance::swaggerTypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; - if (!isset($propertySetter) || !isset($data->{$instance::$attributeMap[$property]})) { + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { continue; } - $propertyValue = $data->{$instance::$attributeMap[$property]}; + $propertyValue = $data->{$instance::attributeMap()[$property]}; if (isset($propertyValue)) { - $instance->$propertySetter(self::deserialize($propertyValue, $type)); + $instance->$propertySetter(self::deserialize($propertyValue, $type, null, $discriminator)); } } $deserialized = $instance; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ObjectReturnTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ObjectReturnTest.php deleted file mode 100644 index de06d6e7a9d4..000000000000 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ObjectReturnTest.php +++ /dev/null @@ -1,70 +0,0 @@ -