forked from loafle/openapi-generator-original
[PHP][Symfony] Further enhancements (#7001)
* Further enchancements for PHP-Symfony. Fixes issues described in #6999 * Ran shell script to update petstore sample
This commit is contained in:
committed by
William Cheng
parent
a565a94a06
commit
5d59dd10ec
@@ -70,6 +70,8 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function addPet(Pet $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -83,6 +85,8 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -123,7 +127,7 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return Swagger\Server\Model\Pet
|
||||
* @return Swagger\Server\Model\Pet[]
|
||||
*
|
||||
*/
|
||||
public function getPetById($petId, &$responseCode, array &$responseHeaders);
|
||||
@@ -137,6 +141,8 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function updatePet(Pet $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -151,6 +157,8 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -165,7 +173,7 @@ interface PetApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return Swagger\Server\Model\ApiResponse
|
||||
* @return Swagger\Server\Model\ApiResponse[]
|
||||
*
|
||||
*/
|
||||
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -60,6 +60,8 @@ interface StoreApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -71,7 +73,7 @@ interface StoreApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return int[]
|
||||
* @return int
|
||||
*
|
||||
*/
|
||||
public function getInventory(&$responseCode, array &$responseHeaders);
|
||||
@@ -85,7 +87,7 @@ interface StoreApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return Swagger\Server\Model\Order
|
||||
* @return Swagger\Server\Model\Order[]
|
||||
*
|
||||
*/
|
||||
public function getOrderById($orderId, &$responseCode, array &$responseHeaders);
|
||||
@@ -99,7 +101,7 @@ interface StoreApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return Swagger\Server\Model\Order
|
||||
* @return Swagger\Server\Model\Order[]
|
||||
*
|
||||
*/
|
||||
public function placeOrder(Order $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -51,6 +51,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function createUser(User $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -63,6 +65,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function createUsersWithArrayInput(array $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -75,6 +79,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function createUsersWithListInput(array $body, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -87,6 +93,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function deleteUser($username, &$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -99,7 +107,7 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return Swagger\Server\Model\User
|
||||
* @return Swagger\Server\Model\User[]
|
||||
*
|
||||
*/
|
||||
public function getUserByName($username, &$responseCode, array &$responseHeaders);
|
||||
@@ -127,6 +135,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function logoutUser(&$responseCode, array &$responseHeaders);
|
||||
|
||||
@@ -140,6 +150,8 @@ interface UserApiInterface
|
||||
* @param integer $responseCode The HTTP response code to return
|
||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function updateUser($username, User $body, &$responseCode, array &$responseHeaders);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@ class PetController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\Pet', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
@@ -162,17 +161,12 @@ class PetController extends Controller
|
||||
$securitypetstore_auth = $request->headers->get('authorization');
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
$apiKey = $request->headers->get('apiKey');
|
||||
$apiKey = $request->headers->get('api_key');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$petId = $this->deserialize($petId, 'int', 'string');
|
||||
$apiKey = $request->headers->get('apiKey');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$apiKey = $this->deserialize($apiKey, 'string', 'string');
|
||||
|
||||
// Validate the input values
|
||||
@@ -258,7 +252,7 @@ class PetController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$status = $this->deserialize($status, 'array<csv>', 'string');
|
||||
$status = $this->deserialize($status, 'array<csv,string>', 'string');
|
||||
|
||||
// Validate the input values
|
||||
$asserts = [];
|
||||
@@ -345,7 +339,7 @@ class PetController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$tags = $this->deserialize($tags, 'array<csv>', 'string');
|
||||
$tags = $this->deserialize($tags, 'array<csv,string>', 'string');
|
||||
|
||||
// Validate the input values
|
||||
$asserts = [];
|
||||
@@ -521,7 +515,6 @@ class PetController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\Pet', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
@@ -609,19 +602,7 @@ class PetController extends Controller
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$petId = $this->deserialize($petId, 'int', 'string');
|
||||
$name = $request->request->get('name');
|
||||
$status = $request->request->get('status');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$name = $this->deserialize($name, 'string', 'string');
|
||||
$name = $request->request->get('name');
|
||||
$status = $request->request->get('status');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$status = $this->deserialize($status, 'string', 'string');
|
||||
|
||||
// Validate the input values
|
||||
@@ -715,19 +696,7 @@ class PetController extends Controller
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$petId = $this->deserialize($petId, 'int', 'string');
|
||||
$additionalMetadata = $request->request->get('additionalMetadata');
|
||||
$file = $request->files->get('file');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$additionalMetadata = $this->deserialize($additionalMetadata, 'string', 'string');
|
||||
$additionalMetadata = $request->request->get('additionalMetadata');
|
||||
$file = $request->files->get('file');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
// Validate the input values
|
||||
$asserts = [];
|
||||
|
||||
@@ -150,6 +150,10 @@ class StoreController extends Controller
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
// Validate the input values
|
||||
|
||||
|
||||
@@ -306,7 +310,6 @@ class StoreController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\Order', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
|
||||
@@ -83,7 +83,6 @@ class UserController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
@@ -166,14 +165,13 @@ class UserController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\User[]', $inputFormat);
|
||||
$body = $this->deserialize($body, 'array<Swagger\Server\Model\User>', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
$asserts = [];
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\All([
|
||||
new Assert\Type("Swagger\Server\Model\User[]")
|
||||
new Assert\Type("Swagger\Server\Model\User")
|
||||
]);
|
||||
$response = $this->validate($body, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
@@ -251,14 +249,13 @@ class UserController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\User[]', $inputFormat);
|
||||
$body = $this->deserialize($body, 'array<Swagger\Server\Model\User>', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
$asserts = [];
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\All([
|
||||
new Assert\Type("Swagger\Server\Model\User[]")
|
||||
new Assert\Type("Swagger\Server\Model\User")
|
||||
]);
|
||||
$response = $this->validate($body, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
@@ -485,12 +482,6 @@ class UserController extends Controller
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$username = $this->deserialize($username, 'string', 'string');
|
||||
$username = $request->query->get('username');
|
||||
$password = $request->query->get('password');
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
$password = $this->deserialize($password, 'string', 'string');
|
||||
|
||||
// Validate the input values
|
||||
@@ -571,6 +562,10 @@ class UserController extends Controller
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
// Validate the input values
|
||||
|
||||
|
||||
@@ -644,14 +639,7 @@ class UserController extends Controller
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat);
|
||||
$body = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
|
||||
$username = $this->deserialize($username, 'string', 'string');
|
||||
$body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat);
|
||||
|
||||
// Validate the input values
|
||||
|
||||
@@ -203,7 +203,7 @@ class Pet
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhotoUrls(array $photoUrls)
|
||||
public function setPhotoUrls($photoUrls)
|
||||
{
|
||||
$this->photoUrls = $photoUrls;
|
||||
|
||||
@@ -227,7 +227,7 @@ class Pet
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTags(array $tags = null)
|
||||
public function setTags(Tag $tags = null)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ void (empty response body)
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **findPetsByStatus**
|
||||
> Swagger\Server\Model\Pet[] findPetsByStatus($status)
|
||||
> Swagger\Server\Model\Pet findPetsByStatus($status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
@@ -196,11 +196,11 @@ class PetApi implements PetApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**string[]**](../Model/string.md)| Status values that need to be considered for filter |
|
||||
**status** | [**string**](../Model/string.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Swagger\Server\Model\Pet[]**](../Model/Pet.md)
|
||||
[**Swagger\Server\Model\Pet**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -214,7 +214,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **findPetsByTags**
|
||||
> Swagger\Server\Model\Pet[] findPetsByTags($tags)
|
||||
> Swagger\Server\Model\Pet findPetsByTags($tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
@@ -258,11 +258,11 @@ class PetApi implements PetApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**string[]**](../Model/string.md)| Tags to filter by |
|
||||
**tags** | [**string**](../Model/string.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Swagger\Server\Model\Pet[]**](../Model/Pet.md)
|
||||
[**Swagger\Server\Model\Pet**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **getInventory**
|
||||
> int[] getInventory()
|
||||
> int getInventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
@@ -122,7 +122,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**int[]**
|
||||
**int**
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class UserApi implements UserApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Swagger\Server\Model\User[]**](../Model/User.md)| List of user object |
|
||||
**body** | [**Swagger\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -171,7 +171,7 @@ class UserApi implements UserApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Swagger\Server\Model\User[]**](../Model/User.md)| List of user object |
|
||||
**body** | [**Swagger\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ Name | Type | Description | Notes
|
||||
**id** | **int** | | [optional]
|
||||
**category** | [**Swagger\Server\Model\Category**](Category.md) | | [optional]
|
||||
**name** | **string** | |
|
||||
**photoUrls** | **string[]** | |
|
||||
**tags** | [**Swagger\Server\Model\Tag[]**](Tag.md) | | [optional]
|
||||
**photoUrls** | **string** | |
|
||||
**tags** | [**Swagger\Server\Model\Tag**](Tag.md) | | [optional]
|
||||
**status** | **string** | pet status in the store | [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)
|
||||
|
||||
@@ -49,6 +49,11 @@ class JmsSerializer implements SerializerInterface
|
||||
|
||||
private function deserializeString($data, $type)
|
||||
{
|
||||
// Figure out if we have an array format
|
||||
if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) {
|
||||
return $this->deserializeArrayString($matches[1], $matches[2], $data);
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'int':
|
||||
case 'integer':
|
||||
@@ -74,17 +79,37 @@ class JmsSerializer implements SerializerInterface
|
||||
}
|
||||
|
||||
break;
|
||||
case 'array<csv>':
|
||||
return explode(',', $data);
|
||||
case 'array<ssv>':
|
||||
return explode(' ', $data);
|
||||
case 'array<tsv>':
|
||||
return explode("\t", $data);
|
||||
case 'array<pipes>':
|
||||
return explode('|', $data);
|
||||
}
|
||||
|
||||
// If we end up here, just return data
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function deserializeArrayString($format, $type, $data)
|
||||
{
|
||||
// Parse the string using the correct separator
|
||||
switch ($format) {
|
||||
case 'csv':
|
||||
$data = explode(',', $data);
|
||||
break;
|
||||
case 'ssv':
|
||||
$data = explode(' ', $data);
|
||||
break;
|
||||
case 'tsv':
|
||||
$data = explode("\t", $data);
|
||||
break;
|
||||
case 'pipes':
|
||||
$data = explode('|', $data);
|
||||
break;
|
||||
default;
|
||||
$data = [];
|
||||
}
|
||||
|
||||
// Deserialize each of the array elements
|
||||
foreach ($data as $key => $item) {
|
||||
$data[$key] = $this->deserializeString($item, $type);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user