forked from loafle/openapi-generator-original
Merge pull request #1440 from arnested/php-polymorphism-model
Add polymorphism in the PHP client
This commit is contained in:
@@ -15,7 +15,7 @@ public class CodegenOperation {
|
||||
isListContainer, isMultipart, hasMore = Boolean.TRUE,
|
||||
isResponseBinary = Boolean.FALSE, hasReference = Boolean.FALSE;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
returnContainer, summary, notes, baseName, defaultResponse, discriminator;
|
||||
public List<Map<String, String>> consumes, produces;
|
||||
public CodegenParameter bodyParam;
|
||||
public List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||
|
||||
@@ -1451,6 +1451,16 @@ public class DefaultCodegen {
|
||||
op.defaultResponse = toDefaultValue(responseProperty);
|
||||
op.returnType = cm.datatype;
|
||||
op.hasReference = definitions != null && definitions.containsKey(op.returnBaseType);
|
||||
|
||||
// lookup discriminator
|
||||
if (definitions != null) {
|
||||
Model m = definitions.get(op.returnBaseType);
|
||||
if (m != null) {
|
||||
CodegenModel cmod = fromModel(op.returnBaseType, m, definitions);
|
||||
op.discriminator = cmod.discriminator;
|
||||
}
|
||||
}
|
||||
|
||||
if (cm.isContainer != null) {
|
||||
op.returnContainer = cm.containerType;
|
||||
if ("map".equals(cm.containerType)) {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public PhpClientCodegen() {
|
||||
super();
|
||||
|
||||
supportsInheritance = true;
|
||||
outputFolder = "generated-code" + File.separator + "php";
|
||||
modelTemplateFiles.put("model.mustache", ".php");
|
||||
apiTemplateFiles.put("api.mustache", ".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') {
|
||||
@@ -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 = '\{{invokerPackage}}\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;
|
||||
|
||||
@@ -223,7 +223,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
}
|
||||
|
||||
return array(\{{invokerPackage}}\ObjectSerializer::deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader);
|
||||
return array(\{{invokerPackage}}\ObjectSerializer::deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader);
|
||||
{{/returnType}}{{^returnType}}
|
||||
return array(null, $statusCode, $httpHeader);
|
||||
{{/returnType}}
|
||||
|
||||
@@ -46,7 +46,7 @@ use \ArrayAccess;
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class {{classname}} implements ArrayAccess
|
||||
class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
@@ -57,6 +57,10 @@ class {{classname}} implements ArrayAccess
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
static function swaggerTypes() {
|
||||
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name, and the value is the original name
|
||||
* @var string[]
|
||||
@@ -66,6 +70,10 @@ class {{classname}} implements ArrayAccess
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
static function attributeMap() {
|
||||
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
* @var string[]
|
||||
@@ -75,6 +83,10 @@ class {{classname}} implements ArrayAccess
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
static function setters() {
|
||||
return {{#parent}}parent::setters() + {{/parent}}self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
* @var string[]
|
||||
@@ -84,6 +96,10 @@ class {{classname}} implements ArrayAccess
|
||||
{{/hasMore}}{{/vars}}
|
||||
);
|
||||
|
||||
static function getters() {
|
||||
return {{#parent}}parent::getters() + {{/parent}}self::$getters;
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
/**
|
||||
* ${{name}} {{#description}}{{{description}}}{{/description}}
|
||||
|
||||
@@ -175,6 +175,17 @@ public class CodegenTest {
|
||||
Assert.assertTrue(op.responses.get(0).isBinary);
|
||||
}
|
||||
|
||||
@Test(description = "discriminator is present")
|
||||
public void discriminatorTest() {
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/discriminatorTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/pets";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
final CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions());
|
||||
|
||||
Assert.assertEquals(op.discriminator, "className");
|
||||
}
|
||||
|
||||
@Test(description = "use operation consumes and produces")
|
||||
public void localConsumesAndProducesTest() {
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client::getDefaultConfiguration->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
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client::getDefaultConfiguration->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
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client::getDefaultConfiguration->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
|
||||
|
||||
|
||||
@@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// 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');
|
||||
// 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
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ObjectReturn
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package Swagger\Client
|
||||
* @author http://github.com/swagger-api/swagger-codegen
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
/**
|
||||
* Copyright 2016 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace Swagger\Client\Model;
|
||||
|
||||
use \ArrayAccess;
|
||||
/**
|
||||
* ObjectReturn Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description
|
||||
* @package Swagger\Client
|
||||
* @author http://github.com/swagger-api/swagger-codegen
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class ObjectReturn implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
* @var string[]
|
||||
*/
|
||||
static $swaggerTypes = array(
|
||||
'return' => '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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* ObjectReturnTest
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package Swagger\Client
|
||||
* @author http://github.com/swagger-api/swagger-codegen
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
/**
|
||||
* Copyright 2016 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen
|
||||
* Please update the test case below to test the model.
|
||||
*/
|
||||
|
||||
namespace Swagger\Client\Model;
|
||||
|
||||
/**
|
||||
* ObjectReturnTest Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description
|
||||
* @package Swagger\Client
|
||||
* @author http://github.com/swagger-api/swagger-codegen
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
|
||||
* @link https://github.com/swagger-api/swagger-codegen
|
||||
*/
|
||||
class ObjectReturnTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup before running each test case
|
||||
*/
|
||||
public static function setUpBeforeClass() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after running each test case
|
||||
*/
|
||||
public static function tearDownAfterClass() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ObjectReturn
|
||||
*/
|
||||
public function testObjectReturn() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user