Merge pull request #3256 from arnested/php-expose-path-to-callapi

[PHP] Add path without expanded path parameters to callApi
This commit is contained in:
wing328 2016-06-30 16:37:09 +08:00 committed by GitHub
commit 7c5b583751
19 changed files with 101 additions and 153 deletions

View File

@ -123,11 +123,12 @@ class ApiClient
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint
* @param string $endpointPath path to method endpoint before expanding parameters
*
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null)
{
$headers = array();

View File

@ -266,8 +266,14 @@ use \{{invokerPackage}}\ObjectSerializer;
'{{httpMethod}}',
$queryParams,
$httpBody,
$headerParams{{#returnType}},
'{{returnType}}'{{/returnType}}
$headerParams,
{{#returnType}}
'{{returnType}}',
{{/returnType}}
{{^returnType}}
null,
{{/returnType}}
'{{path}}'
);
{{#returnType}}

View File

@ -4,7 +4,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 ' \" =end
- Build date: 2016-06-28T12:21:23.533+08:00
- Build date: 2016-06-30T07:09:53.488+02:00
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
## Requirements
@ -71,7 +71,7 @@ try {
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
@ -86,12 +86,6 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **Location**: HTTP header
## petstore_auth
- **Type**: OAuth
@ -101,6 +95,12 @@ Class | Method | HTTP request | Description
- **write:pets**: modify pets in your account */ ' " =end
- **read:pets**: read your pets */ ' " =end
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **Location**: HTTP header
## Author

View File

@ -1,6 +1,6 @@
# Swagger\Client\FakeApi
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -73,7 +73,7 @@ class FakeApi
{
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('https://petstore.swagger.io */ ' " =end/v2 */ ' " =end');
$apiClient->getConfig()->setHost('https://petstore.swagger.io ' \" =end/v2 ' \" =end');
}
$this->apiClient = $apiClient;
@ -161,7 +161,9 @@ class FakeApi
'PUT',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/fake'
);
return array(null, $statusCode, $httpHeader);

View File

@ -144,11 +144,12 @@ class ApiClient
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint
* @param string $endpointPath path to method endpoint before expanding parameters
*
* @throws \Swagger\Client\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null)
{
$headers = array();

View File

@ -102,7 +102,7 @@ class Configuration
*
* @var string
*/
protected $host = 'https://petstore.swagger.io */ ' " =end/v2 */ ' " =end';
protected $host = 'https://petstore.swagger.io ' \" =end/v2 ' \" =end';
/**
* Timeout (second) of the HTTP request, by default set to 0, no timeout

View File

@ -264,7 +264,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') {

View File

@ -4,7 +4,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0
- Build date: 2016-06-28T14:37:09.979+08:00
- Build date: 2016-06-30T07:09:58.112+02:00
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
## Requirements
@ -133,12 +133,6 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## petstore_auth
- **Type**: OAuth
@ -148,6 +142,12 @@ Class | Method | HTTP request | Description
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Author

View File

@ -6,7 +6,6 @@ Name | Type | Description | Notes
**array_of_string** | **string[]** | | [optional]
**array_array_of_integer** | [**int[][]**](array.md) | | [optional]
**array_array_of_model** | [**\Swagger\Client\Model\ReadOnlyFirst[][]**](array.md) | | [optional]
**array_of_enum** | **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)

View File

@ -4,7 +4,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_map_of_string** | [**map[string,map[string,string]]**](map.md) | | [optional]
**map_map_of_enum** | [**map[string,map[string,string]]**](map.md) | | [optional]
**map_of_enum_string** | **map[string,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)

View File

@ -161,7 +161,9 @@ class FakeApi
'PUT',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/fake'
);
return array(null, $statusCode, $httpHeader);
@ -357,7 +359,9 @@ class FakeApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/fake'
);
return array(null, $statusCode, $httpHeader);
@ -440,7 +444,9 @@ class FakeApi
'GET',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/fake'
);
return array(null, $statusCode, $httpHeader);

View File

@ -170,7 +170,9 @@ class PetApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/pet'
);
return array(null, $statusCode, $httpHeader);
@ -259,7 +261,9 @@ class PetApi
'DELETE',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/pet/{petId}'
);
return array(null, $statusCode, $httpHeader);
@ -342,7 +346,8 @@ class PetApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\Pet[]'
'\Swagger\Client\Model\Pet[]',
'/pet/findByStatus'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
@ -429,7 +434,8 @@ class PetApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\Pet[]'
'\Swagger\Client\Model\Pet[]',
'/pet/findByTags'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
@ -518,7 +524,8 @@ class PetApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\Pet'
'\Swagger\Client\Model\Pet',
'/pet/{petId}'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader);
@ -602,7 +609,9 @@ class PetApi
'PUT',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/pet'
);
return array(null, $statusCode, $httpHeader);
@ -697,7 +706,9 @@ class PetApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/pet/{petId}'
);
return array(null, $statusCode, $httpHeader);
@ -799,7 +810,8 @@ class PetApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\ApiResponse'
'\Swagger\Client\Model\ApiResponse',
'/pet/{petId}/uploadImage'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\ApiResponse', $httpHeader), $statusCode, $httpHeader);

View File

@ -173,7 +173,9 @@ class StoreApi
'DELETE',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/store/order/{orderId}'
);
return array(null, $statusCode, $httpHeader);
@ -244,7 +246,8 @@ class StoreApi
$queryParams,
$httpBody,
$headerParams,
'map[string,int]'
'map[string,int]',
'/store/inventory'
);
return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader);
@ -335,7 +338,8 @@ class StoreApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\Order'
'\Swagger\Client\Model\Order',
'/store/order/{orderId}'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
@ -416,7 +420,8 @@ class StoreApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\Order'
'\Swagger\Client\Model\Order',
'/store/order'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);

View File

@ -166,7 +166,9 @@ class UserApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user'
);
return array(null, $statusCode, $httpHeader);
@ -242,7 +244,9 @@ class UserApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user/createWithArray'
);
return array(null, $statusCode, $httpHeader);
@ -318,7 +322,9 @@ class UserApi
'POST',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user/createWithList'
);
return array(null, $statusCode, $httpHeader);
@ -397,7 +403,9 @@ class UserApi
'DELETE',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user/{username}'
);
return array(null, $statusCode, $httpHeader);
@ -477,7 +485,8 @@ class UserApi
$queryParams,
$httpBody,
$headerParams,
'\Swagger\Client\Model\User'
'\Swagger\Client\Model\User',
'/user/{username}'
);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader);
@ -567,7 +576,8 @@ class UserApi
$queryParams,
$httpBody,
$headerParams,
'string'
'string',
'/user/login'
);
return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
@ -636,7 +646,9 @@ class UserApi
'GET',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user/logout'
);
return array(null, $statusCode, $httpHeader);
@ -726,7 +738,9 @@ class UserApi
'PUT',
$queryParams,
$httpBody,
$headerParams
$headerParams,
null,
'/user/{username}'
);
return array(null, $statusCode, $httpHeader);

View File

@ -144,11 +144,12 @@ class ApiClient
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint
* @param string $endpointPath path to method endpoint before expanding parameters
*
* @throws \Swagger\Client\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null)
{
$headers = array();

View File

@ -68,8 +68,7 @@ class ArrayTest implements ArrayAccess
protected static $swaggerTypes = array(
'array_of_string' => 'string[]',
'array_array_of_integer' => 'int[][]',
'array_array_of_model' => '\Swagger\Client\Model\ReadOnlyFirst[][]',
'array_of_enum' => 'string[]'
'array_array_of_model' => '\Swagger\Client\Model\ReadOnlyFirst[][]'
);
public static function swaggerTypes()
@ -84,8 +83,7 @@ class ArrayTest implements ArrayAccess
protected static $attributeMap = array(
'array_of_string' => 'array_of_string',
'array_array_of_integer' => 'array_array_of_integer',
'array_array_of_model' => 'array_array_of_model',
'array_of_enum' => 'array_of_enum'
'array_array_of_model' => 'array_array_of_model'
);
public static function attributeMap()
@ -100,8 +98,7 @@ class ArrayTest implements ArrayAccess
protected static $setters = array(
'array_of_string' => 'setArrayOfString',
'array_array_of_integer' => 'setArrayArrayOfInteger',
'array_array_of_model' => 'setArrayArrayOfModel',
'array_of_enum' => 'setArrayOfEnum'
'array_array_of_model' => 'setArrayArrayOfModel'
);
public static function setters()
@ -116,8 +113,7 @@ class ArrayTest implements ArrayAccess
protected static $getters = array(
'array_of_string' => 'getArrayOfString',
'array_array_of_integer' => 'getArrayArrayOfInteger',
'array_array_of_model' => 'getArrayArrayOfModel',
'array_of_enum' => 'getArrayOfEnum'
'array_array_of_model' => 'getArrayArrayOfModel'
);
public static function getters()
@ -128,17 +124,6 @@ class ArrayTest implements ArrayAccess
/**
* Gets allowable values of the enum
* @return string[]
*/
public function getArrayOfEnumAllowableValues()
{
return [
];
}
/**
* Associative array for storing property values
@ -155,7 +140,6 @@ class ArrayTest implements ArrayAccess
$this->container['array_of_string'] = isset($data['array_of_string']) ? $data['array_of_string'] : null;
$this->container['array_array_of_integer'] = isset($data['array_array_of_integer']) ? $data['array_array_of_integer'] : null;
$this->container['array_array_of_model'] = isset($data['array_array_of_model']) ? $data['array_array_of_model'] : null;
$this->container['array_of_enum'] = isset($data['array_of_enum']) ? $data['array_of_enum'] : null;
}
/**
@ -166,10 +150,6 @@ class ArrayTest implements ArrayAccess
public function listInvalidProperties()
{
$invalid_properties = array();
$allowed_values = array();
if (!in_array($this->container['array_of_enum'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'array_of_enum', must be one of #{allowed_values}.";
}
return $invalid_properties;
}
@ -181,10 +161,6 @@ class ArrayTest implements ArrayAccess
*/
public function valid()
{
$allowed_values = array();
if (!in_array($this->container['array_of_enum'], $allowed_values)) {
return false;
}
return true;
}
@ -251,31 +227,6 @@ class ArrayTest implements ArrayAccess
return $this;
}
/**
* Gets array_of_enum
* @return string[]
*/
public function getArrayOfEnum()
{
return $this->container['array_of_enum'];
}
/**
* Sets array_of_enum
* @param string[] $array_of_enum
* @return $this
*/
public function setArrayOfEnum($array_of_enum)
{
$allowed_values = array();
if (!in_array($array_of_enum, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'array_of_enum', must be one of ");
}
$this->container['array_of_enum'] = $array_of_enum;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset

View File

@ -67,7 +67,6 @@ class MapTest implements ArrayAccess
*/
protected static $swaggerTypes = array(
'map_map_of_string' => 'map[string,map[string,string]]',
'map_map_of_enum' => 'map[string,map[string,string]]',
'map_of_enum_string' => 'map[string,string]'
);
@ -82,7 +81,6 @@ class MapTest implements ArrayAccess
*/
protected static $attributeMap = array(
'map_map_of_string' => 'map_map_of_string',
'map_map_of_enum' => 'map_map_of_enum',
'map_of_enum_string' => 'map_of_enum_string'
);
@ -97,7 +95,6 @@ class MapTest implements ArrayAccess
*/
protected static $setters = array(
'map_map_of_string' => 'setMapMapOfString',
'map_map_of_enum' => 'setMapMapOfEnum',
'map_of_enum_string' => 'setMapOfEnumString'
);
@ -112,7 +109,6 @@ class MapTest implements ArrayAccess
*/
protected static $getters = array(
'map_map_of_string' => 'getMapMapOfString',
'map_map_of_enum' => 'getMapMapOfEnum',
'map_of_enum_string' => 'getMapOfEnumString'
);
@ -124,17 +120,6 @@ class MapTest implements ArrayAccess
/**
* Gets allowable values of the enum
* @return string[]
*/
public function getMapMapOfEnumAllowableValues()
{
return [
];
}
/**
* Gets allowable values of the enum
* @return string[]
@ -160,7 +145,6 @@ class MapTest implements ArrayAccess
public function __construct(array $data = null)
{
$this->container['map_map_of_string'] = isset($data['map_map_of_string']) ? $data['map_map_of_string'] : null;
$this->container['map_map_of_enum'] = isset($data['map_map_of_enum']) ? $data['map_map_of_enum'] : null;
$this->container['map_of_enum_string'] = isset($data['map_of_enum_string']) ? $data['map_of_enum_string'] : null;
}
@ -173,10 +157,6 @@ class MapTest implements ArrayAccess
{
$invalid_properties = array();
$allowed_values = array();
if (!in_array($this->container['map_map_of_enum'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'map_map_of_enum', must be one of #{allowed_values}.";
}
$allowed_values = array();
if (!in_array($this->container['map_of_enum_string'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'map_of_enum_string', must be one of #{allowed_values}.";
}
@ -191,10 +171,6 @@ class MapTest implements ArrayAccess
*/
public function valid()
{
$allowed_values = array();
if (!in_array($this->container['map_map_of_enum'], $allowed_values)) {
return false;
}
$allowed_values = array();
if (!in_array($this->container['map_of_enum_string'], $allowed_values)) {
return false;
@ -224,31 +200,6 @@ class MapTest implements ArrayAccess
return $this;
}
/**
* Gets map_map_of_enum
* @return map[string,map[string,string]]
*/
public function getMapMapOfEnum()
{
return $this->container['map_map_of_enum'];
}
/**
* Sets map_map_of_enum
* @param map[string,map[string,string]] $map_map_of_enum
* @return $this
*/
public function setMapMapOfEnum($map_map_of_enum)
{
$allowed_values = array();
if (!in_array($map_map_of_enum, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'map_map_of_enum', must be one of ");
}
$this->container['map_map_of_enum'] = $map_map_of_enum;
return $this;
}
/**
* Gets map_of_enum_string
* @return map[string,string]

View File

@ -264,7 +264,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') {