Merge remote-tracking branch 'origin/master' into 7.0.x

This commit is contained in:
William Cheng
2022-07-19 11:54:20 +08:00
2800 changed files with 126318 additions and 33030 deletions

View File

@@ -29,6 +29,8 @@
namespace OpenAPI\Server\Api;
use Symfony\Component\DependencyInjection\Reference;
/**
* ApiServer Class Doc Comment
*
@@ -45,7 +47,7 @@ class ApiServer
/**
* @var array
*/
private $apis = array();
private array $apis = array();
/**
* Adds an API handler to the server.
@@ -53,7 +55,7 @@ class ApiServer
* @param string $api An API name of the handle
* @param mixed $handler A handler to set for the given API
*/
public function addApiHandler($api, $handler)
public function addApiHandler(string $api, $handler): void
{
if (isset($this->apis[$api])) {
throw new \InvalidArgumentException('API has already a handler: '.$api);
@@ -69,7 +71,7 @@ class ApiServer
* @return mixed Returns a handler
* @throws \InvalidArgumentException When no such handler exists
*/
public function getApiHandler($api)
public function getApiHandler(string $api)
{
if (!isset($this->apis[$api])) {
throw new \InvalidArgumentException('No handler for '.$api.' implemented.');

View File

@@ -47,32 +47,33 @@ interface PetApiInterface
/**
* Sets authentication method petstore_auth
*
* @param string $value Value of the petstore_auth authentication method.
* @param string|null $value Value of the petstore_auth authentication method.
*
* @return void
*/
public function setpetstore_auth($value);
public function setpetstore_auth(?string $value): void;
/**
* Sets authentication method api_key
*
* @param string $value Value of the api_key authentication method.
* @param string|null $value Value of the api_key authentication method.
*
* @return void
*/
public function setapi_key($value);
public function setapi_key(?string $value): void;
/**
* Operation addPet
*
* Add a new pet to the store
*
* @param \OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param Pet $pet Pet object that needs to be added to the store (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Pet
* @return array|object|null
*/
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet;
public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -80,13 +81,14 @@ interface PetApiInterface
*
* Deletes a pet
*
* @param \int $petId Pet id to delete (required)
* @param \string $apiKey (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int $petId Pet id to delete (required)
* @param string|null $apiKey (optional)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders): void;
public function deletePet(int $petId, ?string $apiKey, int &$responseCode, array &$responseHeaders): void;
/**
@@ -94,12 +96,13 @@ interface PetApiInterface
*
* Finds Pets by status
*
* @param \string[] $status Status values that need to be considered for filter (required) (deprecated)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param array $status Status values that need to be considered for filter (required) (deprecated)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Pet[]
* @return array|object|null
*/
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders): iterable;
public function findPetsByStatus(array $status, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -107,13 +110,14 @@ interface PetApiInterface
*
* Finds Pets by tags
*
* @param \string[] $tags Tags to filter by (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param array $tags Tags to filter by (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Pet[]
* @return array|object|null
* @deprecated
*/
public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders): iterable;
public function findPetsByTags(array $tags, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -121,12 +125,13 @@ interface PetApiInterface
*
* Find pet by ID
*
* @param \int $petId ID of pet to return (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int $petId ID of pet to return (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Pet
* @return array|object|null
*/
public function getPetById($petId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet;
public function getPetById(int $petId, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -134,12 +139,13 @@ interface PetApiInterface
*
* Update an existing pet
*
* @param \OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param Pet $pet Pet object that needs to be added to the store (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Pet
* @return array|object|null
*/
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet;
public function updatePet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -147,14 +153,15 @@ interface PetApiInterface
*
* Updates a pet in the store with form data
*
* @param \int $petId ID of pet that needs to be updated (required)
* @param \string $name Updated name of the pet (optional)
* @param \string $status Updated status of the pet (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int $petId ID of pet that needs to be updated (required)
* @param string|null $name Updated name of the pet (optional)
* @param string|null $status Updated status of the pet (optional)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders): void;
public function updatePetWithForm(int $petId, ?string $name, ?string $status, int &$responseCode, array &$responseHeaders): void;
/**
@@ -162,13 +169,14 @@ interface PetApiInterface
*
* uploads an image
*
* @param \int $petId ID of pet to update (required)
* @param \string $additionalMetadata Additional data to pass to server (optional)
* @param \UploadedFile $file file to upload (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int $petId ID of pet to update (required)
* @param string|null $additionalMetadata Additional data to pass to server (optional)
* @param UploadedFile|null $file file to upload (optional)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\ApiResponse
* @return array|object|null
*/
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\ApiResponse;
public function uploadFile(int $petId, ?string $additionalMetadata, ?UploadedFile $file, int &$responseCode, array &$responseHeaders): array|object|null;
}

View File

@@ -46,23 +46,24 @@ interface StoreApiInterface
/**
* Sets authentication method api_key
*
* @param string $value Value of the api_key authentication method.
* @param string|null $value Value of the api_key authentication method.
*
* @return void
*/
public function setapi_key($value);
public function setapi_key(?string $value): void;
/**
* Operation deleteOrder
*
* Delete purchase order by ID
*
* @param \string $orderId ID of the order that needs to be deleted (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param string $orderId ID of the order that needs to be deleted (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders): void;
public function deleteOrder(string $orderId, int &$responseCode, array &$responseHeaders): void;
/**
@@ -70,11 +71,12 @@ interface StoreApiInterface
*
* Returns pet inventories by status
*
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \int
* @return array|object|null
*/
public function getInventory(&$responseCode, array &$responseHeaders): array|\int;
public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -82,12 +84,13 @@ interface StoreApiInterface
*
* Find purchase order by ID
*
* @param \int $orderId ID of pet that needs to be fetched (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int $orderId ID of pet that needs to be fetched (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Order
* @return array|object|null
*/
public function getOrderById($orderId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order;
public function getOrderById(int $orderId, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -95,11 +98,12 @@ interface StoreApiInterface
*
* Place an order for a pet
*
* @param \OpenAPI\Server\Model\Order $order order placed for purchasing the pet (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param Order $order order placed for purchasing the pet (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\Order
* @return array|object|null
*/
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order;
public function placeOrder(Order $order, int &$responseCode, array &$responseHeaders): array|object|null;
}

View File

@@ -46,23 +46,24 @@ interface UserApiInterface
/**
* Sets authentication method api_key
*
* @param string $value Value of the api_key authentication method.
* @param string|null $value Value of the api_key authentication method.
*
* @return void
*/
public function setapi_key($value);
public function setapi_key(?string $value): void;
/**
* Operation createUser
*
* Create user
*
* @param \OpenAPI\Server\Model\User $user Created user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param User $user Created user object (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function createUser(User $user, &$responseCode, array &$responseHeaders): void;
public function createUser(User $user, int &$responseCode, array &$responseHeaders): void;
/**
@@ -70,12 +71,13 @@ interface UserApiInterface
*
* Creates list of users with given input array
*
* @param \OpenAPI\Server\Model\User[] $user List of user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param array $user List of user object (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders): void;
public function createUsersWithArrayInput(array $user, int &$responseCode, array &$responseHeaders): void;
/**
@@ -83,12 +85,13 @@ interface UserApiInterface
*
* Creates list of users with given input array
*
* @param \OpenAPI\Server\Model\User[] $user List of user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param array $user List of user object (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders): void;
public function createUsersWithListInput(array $user, int &$responseCode, array &$responseHeaders): void;
/**
@@ -96,12 +99,13 @@ interface UserApiInterface
*
* Delete user
*
* @param \string $username The name that needs to be deleted (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param string $username The name that needs to be deleted (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function deleteUser($username, &$responseCode, array &$responseHeaders): void;
public function deleteUser(string $username, int &$responseCode, array &$responseHeaders): void;
/**
@@ -109,12 +113,13 @@ interface UserApiInterface
*
* Get user by user name
*
* @param \string $username The name that needs to be fetched. Use user1 for testing. (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \OpenAPI\Server\Model\User
* @return array|object|null
*/
public function getUserByName($username, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\User;
public function getUserByName(string $username, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -122,13 +127,14 @@ interface UserApiInterface
*
* Logs user into the system
*
* @param \string $username The user name for login (required)
* @param \string $password The password for login in clear text (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param string $username The user name for login (required)
* @param string $password The password for login in clear text (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return \string
* @return array|object|null
*/
public function loginUser($username, $password, &$responseCode, array &$responseHeaders): array|\string;
public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null;
/**
@@ -136,11 +142,12 @@ interface UserApiInterface
*
* Logs out current logged in user session
*
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function logoutUser(&$responseCode, array &$responseHeaders): void;
public function logoutUser(int &$responseCode, array &$responseHeaders): void;
/**
@@ -148,12 +155,13 @@ interface UserApiInterface
*
* Updated user
*
* @param \string $username name that need to be deleted (required)
* @param \OpenAPI\Server\Model\User $user Updated user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response ()
* @param string $username name that need to be deleted (required)
* @param User $user Updated user object (required)
* @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return void
*/
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders): void;
public function updateUser(string $username, User $user, int &$responseCode, array &$responseHeaders): void;
}

View File

@@ -29,10 +29,12 @@
namespace OpenAPI\Server\Controller;
use OpenAPI\Server\Api\ApiServer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\ConstraintViolation;
use OpenAPI\Server\Service\SerializerInterface;
use OpenAPI\Server\Service\ValidatorInterface;
@@ -46,23 +48,29 @@ use OpenAPI\Server\Service\ValidatorInterface;
*/
class Controller extends AbstractController
{
protected $validator;
protected $serializer;
protected $apiServer;
protected ValidatorInterface $validator;
protected SerializerInterface $serializer;
protected ApiServer $apiServer;
public function setValidator(ValidatorInterface $validator)
public function setValidator(ValidatorInterface $validator): self
{
$this->validator = $validator;
return $this;
}
public function setSerializer(SerializerInterface $serializer)
public function setSerializer(SerializerInterface $serializer): self
{
$this->serializer = $serializer;
return $this;
}
public function setApiServer($server)
public function setApiServer(ApiServer $server): self
{
$this->apiServer = $server;
return $this;
}
/**
@@ -73,7 +81,7 @@ class Controller extends AbstractController
*
* @return Response
*/
public function createBadRequestResponse($message = 'Bad Request.')
public function createBadRequestResponse(string $message = 'Bad Request.'): Response
{
return new Response($message, 400);
}
@@ -86,7 +94,7 @@ class Controller extends AbstractController
*
* @return Response
*/
public function createErrorResponse(HttpException $exception)
public function createErrorResponse(HttpException $exception): Response
{
$statusCode = $exception->getStatusCode();
$headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']);
@@ -101,12 +109,11 @@ class Controller extends AbstractController
* Serializes data to a given type format.
*
* @param mixed $data The data to serialize.
* @param string $class The source data class.
* @param string $format The target serialization format.
*
* @return string A serialized data string.
*/
protected function serialize($data, $format)
protected function serialize($data, string $format): string
{
return $this->serializer->serialize($data, $format);
}
@@ -114,35 +121,47 @@ class Controller extends AbstractController
/**
* Deserializes data from a given type format.
*
* @param string $data The data to deserialize.
* @param mixed $data The data to deserialize.
* @param string $class The target data class.
* @param string $format The source serialization format.
*
* @return mixed A deserialized data.
*/
protected function deserialize($data, $class, $format)
protected function deserialize($data, string $class, string $format)
{
return $this->serializer->deserialize($data, $class, $format);
}
protected function validate($data, $asserts = null)
/**
* @param mixed $data
* @param mixed $asserts
*
* @return Response|null
*/
protected function validate($data, $asserts = null): ?Response
{
$errors = $this->validator->validate($data, $asserts);
if (count($errors) > 0) {
$errorsString = (string)$errors;
$errorsString = '';
/** @var ConstraintViolation $violation */
foreach ($errors as $violation) {
$errorsString .= $violation->getMessage()."\n";
}
return $this->createBadRequestResponse($errorsString);
}
return null;
}
/**
* Converts an exception to a serializable array.
*
* @param \Exception|null $exception
* @param \Throwable|null $exception
*
* @return array
* @return array|null
*/
private function exceptionToArray(\Exception $exception = null)
private function exceptionToArray(\Throwable $exception = null): ?array
{
if (null === $exception) {
return null;
@@ -161,7 +180,15 @@ class Controller extends AbstractController
];
}
protected function getOutputFormat($accept, array $produced)
/**
* Converts an exception to a serializable array.
*
* @param string $accept
* @param array $produced
*
* @return ?string
*/
protected function getOutputFormat(string $accept, array $produced): ?string
{
// Figure out what the client accepts
$accept = preg_split("/[\s,]+/", $accept);
@@ -196,7 +223,7 @@ class Controller extends AbstractController
*
* @return bool Returns true if Content-Type supported otherwise false.
*/
public static function isContentTypeAllowed(Request $request, array $consumes = [])
public static function isContentTypeAllowed(Request $request, array $consumes = []): bool
{
if (!empty($consumes) && $consumes[0] !== '*/*') {
$currentFormat = $request->getContentType();

View File

@@ -114,6 +114,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->addPet($pet, $responseCode, $responseHeaders);
// Find default response message
@@ -140,7 +141,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -198,7 +199,8 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders);
$handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders);
// Find default response message
$message = '';
@@ -220,7 +222,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -286,6 +288,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->findPetsByStatus($status, $responseCode, $responseHeaders);
// Find default response message
@@ -312,7 +315,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -376,6 +379,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->findPetsByTags($tags, $responseCode, $responseHeaders);
// Find default response message
@@ -402,7 +406,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -461,6 +465,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getPetById($petId, $responseCode, $responseHeaders);
// Find default response message
@@ -490,7 +495,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -559,6 +564,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->updatePet($pet, $responseCode, $responseHeaders);
// Find default response message
@@ -591,7 +597,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -657,7 +663,8 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders);
$handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders);
// Find default response message
$message = '';
@@ -679,7 +686,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -753,6 +760,7 @@ class PetController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->uploadFile($petId, $additionalMetadata, $file, $responseCode, $responseHeaders);
// Find default response message
@@ -776,7 +784,7 @@ class PetController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}

View File

@@ -89,7 +89,8 @@ class StoreController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deleteOrder($orderId, $responseCode, $responseHeaders);
$handler->deleteOrder($orderId, $responseCode, $responseHeaders);
// Find default response message
$message = '';
@@ -114,7 +115,7 @@ class StoreController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -159,6 +160,7 @@ class StoreController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getInventory($responseCode, $responseHeaders);
// Find default response message
@@ -182,7 +184,7 @@ class StoreController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -238,6 +240,7 @@ class StoreController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getOrderById($orderId, $responseCode, $responseHeaders);
// Find default response message
@@ -267,7 +270,7 @@ class StoreController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -331,6 +334,7 @@ class StoreController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->placeOrder($order, $responseCode, $responseHeaders);
// Find default response message
@@ -357,7 +361,7 @@ class StoreController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}

View File

@@ -104,7 +104,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUser($user, $responseCode, $responseHeaders);
$handler->createUser($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
@@ -126,7 +127,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -188,7 +189,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
$handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
@@ -210,7 +212,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -272,7 +274,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
$handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
@@ -294,7 +297,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -344,7 +347,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deleteUser($username, $responseCode, $responseHeaders);
$handler->deleteUser($username, $responseCode, $responseHeaders);
// Find default response message
$message = '';
@@ -369,7 +373,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -423,6 +427,7 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getUserByName($username, $responseCode, $responseHeaders);
// Find default response message
@@ -452,7 +457,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -517,6 +522,7 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->loginUser($username, $password, $responseCode, $responseHeaders);
// Find default response message
@@ -543,7 +549,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -579,7 +585,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->logoutUser($responseCode, $responseHeaders);
$handler->logoutUser($responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
@@ -601,7 +608,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
@@ -669,7 +676,8 @@ class UserController extends Controller
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->updateUser($username, $user, $responseCode, $responseHeaders);
$handler->updateUser($username, $user, $responseCode, $responseHeaders);
// Find default response message
$message = '';
@@ -694,7 +702,7 @@ class UserController extends Controller
]
)
);
} catch (Exception $fallthrough) {
} catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}

View File

@@ -44,7 +44,7 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
*/
class OpenAPIServerExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

View File

@@ -49,7 +49,7 @@ class ApiResponse
* @Assert\Type("int")
* @Type("int")
*/
protected $code;
protected ?int $code = null;
/**
* @var string|null
@@ -57,7 +57,7 @@ class ApiResponse
* @Assert\Type("string")
* @Type("string")
*/
protected $type;
protected ?string $type = null;
/**
* @var string|null
@@ -65,17 +65,17 @@ class ApiResponse
* @Assert\Type("string")
* @Type("string")
*/
protected $message;
protected ?string $message = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->code = isset($data['code']) ? $data['code'] : null;
$this->type = isset($data['type']) ? $data['type'] : null;
$this->message = isset($data['message']) ? $data['message'] : null;
$this->code = $data['code'] ?? null;
$this->type = $data['type'] ?? null;
$this->message = $data['message'] ?? null;
}
/**
@@ -83,7 +83,7 @@ class ApiResponse
*
* @return int|null
*/
public function getCode()
public function getCode(): ?int
{
return $this->code;
}
@@ -95,7 +95,7 @@ class ApiResponse
*
* @return $this
*/
public function setCode($code = null)
public function setCode(?int $code = null): self
{
$this->code = $code;
@@ -107,7 +107,7 @@ class ApiResponse
*
* @return string|null
*/
public function getType()
public function getType(): ?string
{
return $this->type;
}
@@ -119,7 +119,7 @@ class ApiResponse
*
* @return $this
*/
public function setType($type = null)
public function setType(?string $type = null): self
{
$this->type = $type;
@@ -131,7 +131,7 @@ class ApiResponse
*
* @return string|null
*/
public function getMessage()
public function getMessage(): ?string
{
return $this->message;
}
@@ -143,7 +143,7 @@ class ApiResponse
*
* @return $this
*/
public function setMessage($message = null)
public function setMessage(?string $message = null): self
{
$this->message = $message;

View File

@@ -49,7 +49,7 @@ class Category
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
protected ?int $id = null;
/**
* @var string|null
@@ -58,16 +58,16 @@ class Category
* @Type("string")
* @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")
*/
protected $name;
protected ?string $name = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->id = isset($data['id']) ? $data['id'] : null;
$this->name = isset($data['name']) ? $data['name'] : null;
$this->id = $data['id'] ?? null;
$this->name = $data['name'] ?? null;
}
/**
@@ -75,7 +75,7 @@ class Category
*
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@@ -87,7 +87,7 @@ class Category
*
* @return $this
*/
public function setId($id = null)
public function setId(?int $id = null): self
{
$this->id = $id;
@@ -99,7 +99,7 @@ class Category
*
* @return string|null
*/
public function getName()
public function getName(): ?string
{
return $this->name;
}
@@ -111,7 +111,7 @@ class Category
*
* @return $this
*/
public function setName($name = null)
public function setName(?string $name = null): self
{
$this->name = $name;

View File

@@ -49,7 +49,7 @@ class Order
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
protected ?int $id = null;
/**
* @var int|null
@@ -57,7 +57,7 @@ class Order
* @Assert\Type("int")
* @Type("int")
*/
protected $petId;
protected ?int $petId = null;
/**
* @var int|null
@@ -65,7 +65,7 @@ class Order
* @Assert\Type("int")
* @Type("int")
*/
protected $quantity;
protected ?int $quantity = null;
/**
* @var \DateTime|null
@@ -73,7 +73,7 @@ class Order
* @Assert\DateTime()
* @Type("DateTime")
*/
protected $shipDate;
protected ?\DateTime $shipDate = null;
/**
* Order Status
@@ -84,7 +84,7 @@ class Order
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
protected ?string $status = null;
/**
* @var bool|null
@@ -92,20 +92,20 @@ class Order
* @Assert\Type("bool")
* @Type("bool")
*/
protected $complete;
protected ?bool $complete = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->id = isset($data['id']) ? $data['id'] : null;
$this->petId = isset($data['petId']) ? $data['petId'] : null;
$this->quantity = isset($data['quantity']) ? $data['quantity'] : null;
$this->shipDate = isset($data['shipDate']) ? $data['shipDate'] : null;
$this->status = isset($data['status']) ? $data['status'] : null;
$this->complete = isset($data['complete']) ? $data['complete'] : false;
$this->id = $data['id'] ?? null;
$this->petId = $data['petId'] ?? null;
$this->quantity = $data['quantity'] ?? null;
$this->shipDate = $data['shipDate'] ?? null;
$this->status = $data['status'] ?? null;
$this->complete = $data['complete'] ?? null;
}
/**
@@ -113,7 +113,7 @@ class Order
*
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@@ -125,7 +125,7 @@ class Order
*
* @return $this
*/
public function setId($id = null)
public function setId(?int $id = null): self
{
$this->id = $id;
@@ -137,7 +137,7 @@ class Order
*
* @return int|null
*/
public function getPetId()
public function getPetId(): ?int
{
return $this->petId;
}
@@ -149,7 +149,7 @@ class Order
*
* @return $this
*/
public function setPetId($petId = null)
public function setPetId(?int $petId = null): self
{
$this->petId = $petId;
@@ -161,7 +161,7 @@ class Order
*
* @return int|null
*/
public function getQuantity()
public function getQuantity(): ?int
{
return $this->quantity;
}
@@ -173,7 +173,7 @@ class Order
*
* @return $this
*/
public function setQuantity($quantity = null)
public function setQuantity(?int $quantity = null): self
{
$this->quantity = $quantity;
@@ -197,7 +197,7 @@ class Order
*
* @return $this
*/
public function setShipDate(\DateTime $shipDate = null)
public function setShipDate(?\DateTime $shipDate = null): self
{
$this->shipDate = $shipDate;
@@ -209,7 +209,7 @@ class Order
*
* @return string|null
*/
public function getStatus()
public function getStatus(): ?string
{
return $this->status;
}
@@ -221,7 +221,7 @@ class Order
*
* @return $this
*/
public function setStatus($status = null)
public function setStatus(?string $status = null): self
{
$this->status = $status;
@@ -233,7 +233,7 @@ class Order
*
* @return bool|null
*/
public function isComplete()
public function isComplete(): ?bool
{
return $this->complete;
}
@@ -245,7 +245,7 @@ class Order
*
* @return $this
*/
public function setComplete($complete = null)
public function setComplete(?bool $complete = null): self
{
$this->complete = $complete;

View File

@@ -49,27 +49,27 @@ class Pet
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
protected ?int $id = null;
/**
* @var OpenAPI\Server\Model\Category|null
* @var Category|null
* @SerializedName("category")
* @Assert\Type("OpenAPI\Server\Model\Category")
* @Type("OpenAPI\Server\Model\Category")
*/
protected $category;
protected ?Category $category = null;
/**
* @var string
* @var string|null
* @SerializedName("name")
* @Assert\NotNull()
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
protected ?string $name = null;
/**
* @var string[]
* @var array|null
* @SerializedName("photoUrls")
* @Assert\NotNull()
* @Assert\All({
@@ -77,17 +77,17 @@ class Pet
* })
* @Type("array<string>")
*/
protected $photoUrls;
protected ?array $photoUrls = null;
/**
* @var OpenAPI\Server\Model\Tag[]|null
* @var array|null
* @SerializedName("tags")
* @Assert\All({
* @Assert\Type("OpenAPI\Server\Model\Tag")
* })
* @Type("array<OpenAPI\Server\Model\Tag>")
*/
protected $tags;
protected ?array $tags = null;
/**
* pet status in the store
@@ -98,20 +98,20 @@ class Pet
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
protected ?string $status = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->id = isset($data['id']) ? $data['id'] : null;
$this->category = isset($data['category']) ? $data['category'] : null;
$this->name = isset($data['name']) ? $data['name'] : null;
$this->photoUrls = isset($data['photoUrls']) ? $data['photoUrls'] : null;
$this->tags = isset($data['tags']) ? $data['tags'] : null;
$this->status = isset($data['status']) ? $data['status'] : null;
$this->id = $data['id'] ?? null;
$this->category = $data['category'] ?? null;
$this->name = $data['name'] ?? null;
$this->photoUrls = $data['photoUrls'] ?? null;
$this->tags = $data['tags'] ?? null;
$this->status = $data['status'] ?? null;
}
/**
@@ -119,7 +119,7 @@ class Pet
*
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@@ -131,7 +131,7 @@ class Pet
*
* @return $this
*/
public function setId($id = null)
public function setId(?int $id = null): self
{
$this->id = $id;
@@ -141,7 +141,7 @@ class Pet
/**
* Gets category.
*
* @return OpenAPI\Server\Model\Category|null
* @return Category|null
*/
public function getCategory(): ?Category
{
@@ -151,11 +151,11 @@ class Pet
/**
* Sets category.
*
* @param OpenAPI\Server\Model\Category|null $category
* @param Category|null $category
*
* @return $this
*/
public function setCategory(Category $category = null)
public function setCategory(?Category $category = null): self
{
$this->category = $category;
@@ -165,9 +165,9 @@ class Pet
/**
* Gets name.
*
* @return string
* @return string|null
*/
public function getName()
public function getName(): ?string
{
return $this->name;
}
@@ -175,11 +175,11 @@ class Pet
/**
* Sets name.
*
* @param string $name
* @param string|null $name
*
* @return $this
*/
public function setName($name)
public function setName(?string $name): self
{
$this->name = $name;
@@ -189,9 +189,9 @@ class Pet
/**
* Gets photoUrls.
*
* @return string[]
* @return array|null
*/
public function getPhotoUrls(): array
public function getPhotoUrls(): ?array
{
return $this->photoUrls;
}
@@ -199,11 +199,11 @@ class Pet
/**
* Sets photoUrls.
*
* @param string[] $photoUrls
* @param array|null $photoUrls
*
* @return $this
*/
public function setPhotoUrls(array $photoUrls)
public function setPhotoUrls(?array $photoUrls): self
{
$this->photoUrls = $photoUrls;
@@ -213,7 +213,7 @@ class Pet
/**
* Gets tags.
*
* @return OpenAPI\Server\Model\Tag[]|null
* @return array|null
*/
public function getTags(): ?array
{
@@ -223,11 +223,11 @@ class Pet
/**
* Sets tags.
*
* @param OpenAPI\Server\Model\Tag[]|null $tags
* @param array|null $tags
*
* @return $this
*/
public function setTags(array $tags = null)
public function setTags(?array $tags = null): self
{
$this->tags = $tags;
@@ -239,7 +239,7 @@ class Pet
*
* @return string|null
*/
public function getStatus()
public function getStatus(): ?string
{
return $this->status;
}
@@ -251,7 +251,7 @@ class Pet
*
* @return $this
*/
public function setStatus($status = null)
public function setStatus(?string $status = null): self
{
$this->status = $status;

View File

@@ -49,7 +49,7 @@ class Tag
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
protected ?int $id = null;
/**
* @var string|null
@@ -57,16 +57,16 @@ class Tag
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
protected ?string $name = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->id = isset($data['id']) ? $data['id'] : null;
$this->name = isset($data['name']) ? $data['name'] : null;
$this->id = $data['id'] ?? null;
$this->name = $data['name'] ?? null;
}
/**
@@ -74,7 +74,7 @@ class Tag
*
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@@ -86,7 +86,7 @@ class Tag
*
* @return $this
*/
public function setId($id = null)
public function setId(?int $id = null): self
{
$this->id = $id;
@@ -98,7 +98,7 @@ class Tag
*
* @return string|null
*/
public function getName()
public function getName(): ?string
{
return $this->name;
}
@@ -110,7 +110,7 @@ class Tag
*
* @return $this
*/
public function setName($name = null)
public function setName(?string $name = null): self
{
$this->name = $name;

View File

@@ -49,7 +49,7 @@ class User
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
protected ?int $id = null;
/**
* @var string|null
@@ -57,7 +57,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $username;
protected ?string $username = null;
/**
* @var string|null
@@ -65,7 +65,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $firstName;
protected ?string $firstName = null;
/**
* @var string|null
@@ -73,7 +73,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $lastName;
protected ?string $lastName = null;
/**
* @var string|null
@@ -81,7 +81,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $email;
protected ?string $email = null;
/**
* @var string|null
@@ -89,7 +89,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $password;
protected ?string $password = null;
/**
* @var string|null
@@ -97,7 +97,7 @@ class User
* @Assert\Type("string")
* @Type("string")
*/
protected $phone;
protected ?string $phone = null;
/**
* User Status
@@ -107,22 +107,22 @@ class User
* @Assert\Type("int")
* @Type("int")
*/
protected $userStatus;
protected ?int $userStatus = null;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
* @param array|null $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->id = isset($data['id']) ? $data['id'] : null;
$this->username = isset($data['username']) ? $data['username'] : null;
$this->firstName = isset($data['firstName']) ? $data['firstName'] : null;
$this->lastName = isset($data['lastName']) ? $data['lastName'] : null;
$this->email = isset($data['email']) ? $data['email'] : null;
$this->password = isset($data['password']) ? $data['password'] : null;
$this->phone = isset($data['phone']) ? $data['phone'] : null;
$this->userStatus = isset($data['userStatus']) ? $data['userStatus'] : null;
$this->id = $data['id'] ?? null;
$this->username = $data['username'] ?? null;
$this->firstName = $data['firstName'] ?? null;
$this->lastName = $data['lastName'] ?? null;
$this->email = $data['email'] ?? null;
$this->password = $data['password'] ?? null;
$this->phone = $data['phone'] ?? null;
$this->userStatus = $data['userStatus'] ?? null;
}
/**
@@ -130,7 +130,7 @@ class User
*
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
@@ -142,7 +142,7 @@ class User
*
* @return $this
*/
public function setId($id = null)
public function setId(?int $id = null): self
{
$this->id = $id;
@@ -154,7 +154,7 @@ class User
*
* @return string|null
*/
public function getUsername()
public function getUsername(): ?string
{
return $this->username;
}
@@ -166,7 +166,7 @@ class User
*
* @return $this
*/
public function setUsername($username = null)
public function setUsername(?string $username = null): self
{
$this->username = $username;
@@ -178,7 +178,7 @@ class User
*
* @return string|null
*/
public function getFirstName()
public function getFirstName(): ?string
{
return $this->firstName;
}
@@ -190,7 +190,7 @@ class User
*
* @return $this
*/
public function setFirstName($firstName = null)
public function setFirstName(?string $firstName = null): self
{
$this->firstName = $firstName;
@@ -202,7 +202,7 @@ class User
*
* @return string|null
*/
public function getLastName()
public function getLastName(): ?string
{
return $this->lastName;
}
@@ -214,7 +214,7 @@ class User
*
* @return $this
*/
public function setLastName($lastName = null)
public function setLastName(?string $lastName = null): self
{
$this->lastName = $lastName;
@@ -226,7 +226,7 @@ class User
*
* @return string|null
*/
public function getEmail()
public function getEmail(): ?string
{
return $this->email;
}
@@ -238,7 +238,7 @@ class User
*
* @return $this
*/
public function setEmail($email = null)
public function setEmail(?string $email = null): self
{
$this->email = $email;
@@ -250,7 +250,7 @@ class User
*
* @return string|null
*/
public function getPassword()
public function getPassword(): ?string
{
return $this->password;
}
@@ -262,7 +262,7 @@ class User
*
* @return $this
*/
public function setPassword($password = null)
public function setPassword(?string $password = null): self
{
$this->password = $password;
@@ -274,7 +274,7 @@ class User
*
* @return string|null
*/
public function getPhone()
public function getPhone(): ?string
{
return $this->phone;
}
@@ -286,7 +286,7 @@ class User
*
* @return $this
*/
public function setPhone($phone = null)
public function setPhone(?string $phone = null): self
{
$this->phone = $phone;
@@ -298,7 +298,7 @@ class User
*
* @return int|null
*/
public function getUserStatus()
public function getUserStatus(): ?int
{
return $this->userStatus;
}
@@ -310,7 +310,7 @@ class User
*
* @return $this
*/
public function setUserStatus($userStatus = null)
public function setUserStatus(?int $userStatus = null): self
{
$this->userStatus = $userStatus;

View File

@@ -26,7 +26,7 @@ To install the dependencies via [Composer](http://getcomposer.org/), add the fol
Then run:
```
composer require GIT_USER_ID/GIT_REPO_ID:dev-master
composer require openapitools/petstore:dev-master
```
to add the generated openapi bundle as a dependency.
@@ -87,7 +87,7 @@ class PetApi implements PetApiInterface // An interface is autogenerated
/**
* Implementation of PetApiInterface#addPet
*/
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}

View File

@@ -57,7 +57,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#addPet
*/
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -119,7 +119,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#deletePet
*/
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders): void
public function deletePet(int $petId, ?string $apiKey, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -182,7 +182,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#findPetsByStatus
*/
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders): iterable
public function findPetsByStatus(array $status, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -244,7 +244,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#findPetsByTags
*/
public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders): iterable
public function findPetsByTags(array $tags, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -306,7 +306,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#getPetById
*/
public function getPetById($petId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function getPetById(int $petId, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -368,7 +368,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#updatePet
*/
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function updatePet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -430,7 +430,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#updatePetWithForm
*/
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders): void
public function updatePetWithForm(int $petId, ?string $name, ?string $status, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -494,7 +494,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#uploadFile
*/
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\ApiResponse
public function uploadFile(int $petId, ?string $additionalMetadata, ?UploadedFile $file, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}

View File

@@ -45,7 +45,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#deleteOrder
*/
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders): void
public function deleteOrder(string $orderId, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -107,7 +107,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#getInventory
*/
public function getInventory(, &$responseCode, array &$responseHeaders): array|\int
public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -158,7 +158,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#getOrderById
*/
public function getOrderById($orderId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order
public function getOrderById(int $orderId, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -212,7 +212,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#placeOrder
*/
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order
public function placeOrder(Order $order, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}

View File

@@ -57,7 +57,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUser
*/
public function createUser(User $user, &$responseCode, array &$responseHeaders): void
public function createUser(User $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -119,7 +119,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUsersWithArrayInput
*/
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders): void
public function createUsersWithArrayInput(array $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -181,7 +181,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUsersWithListInput
*/
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders): void
public function createUsersWithListInput(array $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -243,7 +243,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#deleteUser
*/
public function deleteUser($username, &$responseCode, array &$responseHeaders): void
public function deleteUser(string $username, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -297,7 +297,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#getUserByName
*/
public function getUserByName($username, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\User
public function getUserByName(string $username, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -351,7 +351,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#loginUser
*/
public function loginUser($username, $password, &$responseCode, array &$responseHeaders): array|\string
public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -414,7 +414,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#logoutUser
*/
public function logoutUser(, &$responseCode, array &$responseHeaders): void
public function logoutUser(int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -473,7 +473,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#updateUser
*/
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders): void
public function updateUser(string $username, User $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}

View File

@@ -5,13 +5,14 @@ namespace OpenAPI\Server\Service;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\Serializer;
use JMS\Serializer\Visitor\Factory\XmlDeserializationVisitorFactory;
use DateTime;
use RuntimeException;
class JmsSerializer implements SerializerInterface
{
protected $serializer;
protected Serializer $serializer;
public function __construct()
{
@@ -23,12 +24,18 @@ class JmsSerializer implements SerializerInterface
->build();
}
public function serialize($data, $format)
/**
* @inheritdoc
*/
public function serialize($data, string $format): string
{
return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format));
}
public function deserialize($data, $type, $format)
/**
* @inheritdoc
*/
public function deserialize($data, string $type, string $format)
{
if ($format == 'string') {
return $this->deserializeString($data, $type);
@@ -38,7 +45,7 @@ class JmsSerializer implements SerializerInterface
return $this->serializer->deserialize($data, $type, $this->convertFormat($format));
}
private function convertFormat($format)
private function convertFormat(string $format): ?string
{
switch ($format) {
case 'application/json':
@@ -50,7 +57,7 @@ class JmsSerializer implements SerializerInterface
return null;
}
private function deserializeString($data, $type)
private function deserializeString($data, string $type)
{
// Figure out if we have an array format
if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) {
@@ -73,6 +80,10 @@ class JmsSerializer implements SerializerInterface
break;
case 'boolean':
case 'bool':
if (is_bool($data)) {
return $data;
}
if (strtolower($data) === 'true') {
return true;
}
@@ -93,8 +104,12 @@ class JmsSerializer implements SerializerInterface
return $data;
}
private function deserializeArrayString($format, $type, $data)
private function deserializeArrayString(string $format, string $type, $data): array
{
if (empty($data)) {
return [];
}
// Parse the string using the correct separator
switch ($format) {
case 'csv':

View File

@@ -12,16 +12,16 @@ interface SerializerInterface
*
* @return string
*/
public function serialize($data, $format);
public function serialize($data, string $format): string;
/**
* Deserializes the given data to the specified type.
*
* @param string $data
* @param mixed $data
* @param string $type
* @param string $format
*
* @return object|array|scalar
*/
public function deserialize($data, $type, $format);
public function deserialize($data, string $type, string $format);
}

View File

@@ -27,7 +27,7 @@ use JMS\Serializer\Visitor\DeserializationVisitorInterface;
class StrictJsonDeserializationVisitor implements DeserializationVisitorInterface
{
protected $jsonDeserializationVisitor: JsonDeserializationVisitor;
protected JsonDeserializationVisitor $jsonDeserializationVisitor;
public function __construct(
int $options = 0,

View File

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidator
class SymfonyValidator implements ValidatorInterface
{
protected $validator;
protected SymfonyValidatorInterface $validator;
public function __construct(SymfonyValidatorInterface $validator)
{

View File

@@ -2,6 +2,9 @@
namespace OpenAPI\Server\Service;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolationListInterface;
interface ValidatorInterface
{
/**

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\PetApiInterface
*/
class PetApiInterfaceTest extends WebTestCase
{
@@ -85,13 +82,14 @@ class PetApiInterfaceTest extends WebTestCase
* Add a new pet to the store.
*
*/
public function testAddPet()
public function testAddPet(): void
{
$client = self::$client;
$path = '/pet';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for addPet not implemented');
}
/**
@@ -100,7 +98,7 @@ class PetApiInterfaceTest extends WebTestCase
* Deletes a pet.
*
*/
public function testDeletePet()
public function testDeletePet(): void
{
$client = self::$client;
@@ -110,6 +108,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deletePet not implemented');
}
/**
@@ -118,13 +117,14 @@ class PetApiInterfaceTest extends WebTestCase
* Finds Pets by status.
*
*/
public function testFindPetsByStatus()
public function testFindPetsByStatus(): void
{
$client = self::$client;
$path = '/pet/findByStatus';
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for findPetsByStatus not implemented');
}
/**
@@ -133,13 +133,14 @@ class PetApiInterfaceTest extends WebTestCase
* Finds Pets by tags.
*
*/
public function testFindPetsByTags()
public function testFindPetsByTags(): void
{
$client = self::$client;
$path = '/pet/findByTags';
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for findPetsByTags not implemented');
}
/**
@@ -148,7 +149,7 @@ class PetApiInterfaceTest extends WebTestCase
* Find pet by ID.
*
*/
public function testGetPetById()
public function testGetPetById(): void
{
$client = self::$client;
@@ -158,6 +159,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getPetById not implemented');
}
/**
@@ -166,13 +168,14 @@ class PetApiInterfaceTest extends WebTestCase
* Update an existing pet.
*
*/
public function testUpdatePet()
public function testUpdatePet(): void
{
$client = self::$client;
$path = '/pet';
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for updatePet not implemented');
}
/**
@@ -181,7 +184,7 @@ class PetApiInterfaceTest extends WebTestCase
* Updates a pet in the store with form data.
*
*/
public function testUpdatePetWithForm()
public function testUpdatePetWithForm(): void
{
$client = self::$client;
@@ -191,6 +194,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path);
$this->markTestSkipped('Test for updatePetWithForm not implemented');
}
/**
@@ -199,7 +203,7 @@ class PetApiInterfaceTest extends WebTestCase
* uploads an image.
*
*/
public function testUploadFile()
public function testUploadFile(): void
{
$client = self::$client;
@@ -209,13 +213,18 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path);
$this->markTestSkipped('Test for uploadFile not implemented');
}
protected function genTestData($regexp)
/**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\StoreApiInterface
*/
class StoreApiInterfaceTest extends WebTestCase
{
@@ -85,7 +82,7 @@ class StoreApiInterfaceTest extends WebTestCase
* Delete purchase order by ID.
*
*/
public function testDeleteOrder()
public function testDeleteOrder(): void
{
$client = self::$client;
@@ -95,6 +92,7 @@ class StoreApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deleteOrder not implemented');
}
/**
@@ -103,13 +101,14 @@ class StoreApiInterfaceTest extends WebTestCase
* Returns pet inventories by status.
*
*/
public function testGetInventory()
public function testGetInventory(): void
{
$client = self::$client;
$path = '/store/inventory';
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getInventory not implemented');
}
/**
@@ -118,7 +117,7 @@ class StoreApiInterfaceTest extends WebTestCase
* Find purchase order by ID.
*
*/
public function testGetOrderById()
public function testGetOrderById(): void
{
$client = self::$client;
@@ -128,6 +127,7 @@ class StoreApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getOrderById not implemented');
}
/**
@@ -136,20 +136,25 @@ class StoreApiInterfaceTest extends WebTestCase
* Place an order for a pet.
*
*/
public function testPlaceOrder()
public function testPlaceOrder(): void
{
$client = self::$client;
$path = '/store/order';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for placeOrder not implemented');
}
protected function genTestData($regexp)
/**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\UserApiInterface
*/
class UserApiInterfaceTest extends WebTestCase
{
@@ -85,13 +82,14 @@ class UserApiInterfaceTest extends WebTestCase
* Create user.
*
*/
public function testCreateUser()
public function testCreateUser(): void
{
$client = self::$client;
$path = '/user';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUser not implemented');
}
/**
@@ -100,13 +98,14 @@ class UserApiInterfaceTest extends WebTestCase
* Creates list of users with given input array.
*
*/
public function testCreateUsersWithArrayInput()
public function testCreateUsersWithArrayInput(): void
{
$client = self::$client;
$path = '/user/createWithArray';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUsersWithArrayInput not implemented');
}
/**
@@ -115,13 +114,14 @@ class UserApiInterfaceTest extends WebTestCase
* Creates list of users with given input array.
*
*/
public function testCreateUsersWithListInput()
public function testCreateUsersWithListInput(): void
{
$client = self::$client;
$path = '/user/createWithList';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUsersWithListInput not implemented');
}
/**
@@ -130,7 +130,7 @@ class UserApiInterfaceTest extends WebTestCase
* Delete user.
*
*/
public function testDeleteUser()
public function testDeleteUser(): void
{
$client = self::$client;
@@ -140,6 +140,7 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deleteUser not implemented');
}
/**
@@ -148,7 +149,7 @@ class UserApiInterfaceTest extends WebTestCase
* Get user by user name.
*
*/
public function testGetUserByName()
public function testGetUserByName(): void
{
$client = self::$client;
@@ -158,6 +159,7 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getUserByName not implemented');
}
/**
@@ -166,13 +168,14 @@ class UserApiInterfaceTest extends WebTestCase
* Logs user into the system.
*
*/
public function testLoginUser()
public function testLoginUser(): void
{
$client = self::$client;
$path = '/user/login';
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for loginUser not implemented');
}
/**
@@ -181,13 +184,14 @@ class UserApiInterfaceTest extends WebTestCase
* Logs out current logged in user session.
*
*/
public function testLogoutUser()
public function testLogoutUser(): void
{
$client = self::$client;
$path = '/user/logout';
$crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for logoutUser not implemented');
}
/**
@@ -196,7 +200,7 @@ class UserApiInterfaceTest extends WebTestCase
* Updated user.
*
*/
public function testUpdateUser()
public function testUpdateUser(): void
{
$client = self::$client;
@@ -206,13 +210,18 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for updateUser not implemented');
}
protected function genTestData($regexp)
/**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);

View File

@@ -8,15 +8,20 @@ use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
/**
* @inheritDoc
*/
public function registerBundles(): iterable
{
$bundles = array(
new FrameworkBundle()
);
return $bundles;
return [
new FrameworkBundle(),
];
}
/**
* @inheritDoc
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/test_config.yml');

View File

@@ -43,21 +43,16 @@ use Symfony\Component\HttpFoundation\Request;
*/
class ControllerTest extends TestCase
{
/**
* Tests isContentTypeAllowed static method.
*
* @param string $contentType
* @param array $consumes
* @param bool $expectedReturn
*
* @covers ::isContentTypeAllowed
* @dataProvider provideArgumentsForIsContentTypeAllowed
* @dataProvider dataProviderIsContentTypeAllowed
*/
public function testIsContentTypeAllowed($contentType, array $consumes, $expectedReturn)
public function testIsContentTypeAllowed(?string $contentType, array $consumes, bool $expectedReturn): void
{
$request = new Request();
$request->headers->set('CONTENT_TYPE', $contentType, true);// last one argument overrides header
$request->headers->set('CONTENT_TYPE', $contentType);// last one argument overrides header
$this->assertSame(
$expectedReturn,
Controller::isContentTypeAllowed($request, $consumes),
@@ -70,7 +65,7 @@ class ControllerTest extends TestCase
);
}
public function provideArgumentsForIsContentTypeAllowed()
public function dataProviderIsContentTypeAllowed(): array
{
return [
'usual JSON content type' => [

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* ApiResponseTest Class Doc Comment
*
* @category Class */
// * @description Describes the result of uploading an image resource
/**
* @category Class
* @description Describes the result of uploading an image resource
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\ApiResponse
*/
class ApiResponseTest extends TestCase
{
protected ApiResponse|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class ApiResponseTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(ApiResponse::class)->getMockForAbstractClass();
}
/**
@@ -73,31 +76,45 @@ class ApiResponseTest extends TestCase
}
/**
* Test "ApiResponse"
* @group integration
* @small
*/
public function testApiResponse()
public function testTestClassExists(): void
{
$testApiResponse = new ApiResponse();
$this->assertTrue(class_exists(ApiResponse::class));
$this->assertInstanceOf(ApiResponse::class, $this->object);
}
/**
* Test attribute "code"
*
* @group unit
* @small
*/
public function testPropertyCode()
public function testPropertyCode(): void
{
$this->markTestSkipped('Test for property code not implemented');
}
/**
* Test attribute "type"
*
* @group unit
* @small
*/
public function testPropertyType()
public function testPropertyType(): void
{
$this->markTestSkipped('Test for property type not implemented');
}
/**
* Test attribute "message"
*
* @group unit
* @small
*/
public function testPropertyMessage()
public function testPropertyMessage(): void
{
$this->markTestSkipped('Test for property message not implemented');
}
}

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* CategoryTest Class Doc Comment
*
* @category Class */
// * @description A category for a pet
/**
* @category Class
* @description A category for a pet
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Category
*/
class CategoryTest extends TestCase
{
protected Category|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class CategoryTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(Category::class)->getMockForAbstractClass();
}
/**
@@ -73,24 +76,34 @@ class CategoryTest extends TestCase
}
/**
* Test "Category"
* @group integration
* @small
*/
public function testCategory()
public function testTestClassExists(): void
{
$testCategory = new Category();
$this->assertTrue(class_exists(Category::class));
$this->assertInstanceOf(Category::class, $this->object);
}
/**
* Test attribute "id"
*
* @group unit
* @small
*/
public function testPropertyId()
public function testPropertyId(): void
{
$this->markTestSkipped('Test for property id not implemented');
}
/**
* Test attribute "name"
*
* @group unit
* @small
*/
public function testPropertyName()
public function testPropertyName(): void
{
$this->markTestSkipped('Test for property name not implemented');
}
}

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* OrderTest Class Doc Comment
*
* @category Class */
// * @description An order for a pets from the pet store
/**
* @category Class
* @description An order for a pets from the pet store
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Order
*/
class OrderTest extends TestCase
{
protected Order|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class OrderTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(Order::class)->getMockForAbstractClass();
}
/**
@@ -73,52 +76,78 @@ class OrderTest extends TestCase
}
/**
* Test "Order"
* @group integration
* @small
*/
public function testOrder()
public function testTestClassExists(): void
{
$testOrder = new Order();
$this->assertTrue(class_exists(Order::class));
$this->assertInstanceOf(Order::class, $this->object);
}
/**
* Test attribute "id"
*
* @group unit
* @small
*/
public function testPropertyId()
public function testPropertyId(): void
{
$this->markTestSkipped('Test for property id not implemented');
}
/**
* Test attribute "petId"
*
* @group unit
* @small
*/
public function testPropertyPetId()
public function testPropertyPetId(): void
{
$this->markTestSkipped('Test for property petId not implemented');
}
/**
* Test attribute "quantity"
*
* @group unit
* @small
*/
public function testPropertyQuantity()
public function testPropertyQuantity(): void
{
$this->markTestSkipped('Test for property quantity not implemented');
}
/**
* Test attribute "shipDate"
*
* @group unit
* @small
*/
public function testPropertyShipDate()
public function testPropertyShipDate(): void
{
$this->markTestSkipped('Test for property shipDate not implemented');
}
/**
* Test attribute "status"
*
* @group unit
* @small
*/
public function testPropertyStatus()
public function testPropertyStatus(): void
{
$this->markTestSkipped('Test for property status not implemented');
}
/**
* Test attribute "complete"
*
* @group unit
* @small
*/
public function testPropertyComplete()
public function testPropertyComplete(): void
{
$this->markTestSkipped('Test for property complete not implemented');
}
}

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* PetTest Class Doc Comment
*
* @category Class */
// * @description A pet for sale in the pet store
/**
* @category Class
* @description A pet for sale in the pet store
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Pet
*/
class PetTest extends TestCase
{
protected Pet|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class PetTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(Pet::class)->getMockForAbstractClass();
}
/**
@@ -73,52 +76,78 @@ class PetTest extends TestCase
}
/**
* Test "Pet"
* @group integration
* @small
*/
public function testPet()
public function testTestClassExists(): void
{
$testPet = new Pet();
$this->assertTrue(class_exists(Pet::class));
$this->assertInstanceOf(Pet::class, $this->object);
}
/**
* Test attribute "id"
*
* @group unit
* @small
*/
public function testPropertyId()
public function testPropertyId(): void
{
$this->markTestSkipped('Test for property id not implemented');
}
/**
* Test attribute "category"
*
* @group unit
* @small
*/
public function testPropertyCategory()
public function testPropertyCategory(): void
{
$this->markTestSkipped('Test for property category not implemented');
}
/**
* Test attribute "name"
*
* @group unit
* @small
*/
public function testPropertyName()
public function testPropertyName(): void
{
$this->markTestSkipped('Test for property name not implemented');
}
/**
* Test attribute "photoUrls"
*
* @group unit
* @small
*/
public function testPropertyPhotoUrls()
public function testPropertyPhotoUrls(): void
{
$this->markTestSkipped('Test for property photoUrls not implemented');
}
/**
* Test attribute "tags"
*
* @group unit
* @small
*/
public function testPropertyTags()
public function testPropertyTags(): void
{
$this->markTestSkipped('Test for property tags not implemented');
}
/**
* Test attribute "status"
*
* @group unit
* @small
*/
public function testPropertyStatus()
public function testPropertyStatus(): void
{
$this->markTestSkipped('Test for property status not implemented');
}
}

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* TagTest Class Doc Comment
*
* @category Class */
// * @description A tag for a pet
/**
* @category Class
* @description A tag for a pet
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Tag
*/
class TagTest extends TestCase
{
protected Tag|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class TagTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(Tag::class)->getMockForAbstractClass();
}
/**
@@ -73,24 +76,34 @@ class TagTest extends TestCase
}
/**
* Test "Tag"
* @group integration
* @small
*/
public function testTag()
public function testTestClassExists(): void
{
$testTag = new Tag();
$this->assertTrue(class_exists(Tag::class));
$this->assertInstanceOf(Tag::class, $this->object);
}
/**
* Test attribute "id"
*
* @group unit
* @small
*/
public function testPropertyId()
public function testPropertyId(): void
{
$this->markTestSkipped('Test for property id not implemented');
}
/**
* Test attribute "name"
*
* @group unit
* @small
*/
public function testPropertyName()
public function testPropertyName(): void
{
$this->markTestSkipped('Test for property name not implemented');
}
}

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* UserTest Class Doc Comment
*
* @category Class */
// * @description A User who is purchasing from the pet store
/**
* @category Class
* @description A User who is purchasing from the pet store
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\User
*/
class UserTest extends TestCase
{
protected User|MockObject $object;
/**
* Setup before running any test case
@@ -56,6 +58,7 @@ class UserTest extends TestCase
*/
public function setUp(): void
{
$this->object = $this->getMockBuilder(User::class)->getMockForAbstractClass();
}
/**
@@ -73,66 +76,100 @@ class UserTest extends TestCase
}
/**
* Test "User"
* @group integration
* @small
*/
public function testUser()
public function testTestClassExists(): void
{
$testUser = new User();
$this->assertTrue(class_exists(User::class));
$this->assertInstanceOf(User::class, $this->object);
}
/**
* Test attribute "id"
*
* @group unit
* @small
*/
public function testPropertyId()
public function testPropertyId(): void
{
$this->markTestSkipped('Test for property id not implemented');
}
/**
* Test attribute "username"
*
* @group unit
* @small
*/
public function testPropertyUsername()
public function testPropertyUsername(): void
{
$this->markTestSkipped('Test for property username not implemented');
}
/**
* Test attribute "firstName"
*
* @group unit
* @small
*/
public function testPropertyFirstName()
public function testPropertyFirstName(): void
{
$this->markTestSkipped('Test for property firstName not implemented');
}
/**
* Test attribute "lastName"
*
* @group unit
* @small
*/
public function testPropertyLastName()
public function testPropertyLastName(): void
{
$this->markTestSkipped('Test for property lastName not implemented');
}
/**
* Test attribute "email"
*
* @group unit
* @small
*/
public function testPropertyEmail()
public function testPropertyEmail(): void
{
$this->markTestSkipped('Test for property email not implemented');
}
/**
* Test attribute "password"
*
* @group unit
* @small
*/
public function testPropertyPassword()
public function testPropertyPassword(): void
{
$this->markTestSkipped('Test for property password not implemented');
}
/**
* Test attribute "phone"
*
* @group unit
* @small
*/
public function testPropertyPhone()
public function testPropertyPhone(): void
{
$this->markTestSkipped('Test for property phone not implemented');
}
/**
* Test attribute "userStatus"
*
* @group unit
* @small
*/
public function testPropertyUserStatus()
public function testPropertyUserStatus(): void
{
$this->markTestSkipped('Test for property userStatus not implemented');
}
}

View File

@@ -5,4 +5,4 @@ framework:
secret: "testsecret"
test: ~
router:
resource: "%kernel.project_dir%/../Resources/config/routing.yml"
resource: "%kernel.project_dir%/Resources/config/routing.yml"

View File

@@ -1,5 +1,5 @@
{
"name": "GIT_USER_ID/GIT_REPO_ID",
"name": "openapitools/petstore",
"description": "",
"keywords": [
"openapi",

View File

@@ -14,12 +14,12 @@ if [ "$git_host" = "" ]; then
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
git_user_id="openapitools"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
git_repo_id="petstore"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

View File

@@ -1,24 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">././Api</directory>
<directory suffix=".php">././Model</directory>
<directory suffix=".php">././Controller</directory>
</include>
</coverage>
<testsuites>
<testsuite>
<testsuite name="Default test suite">
<directory>./Tests/Api</directory>
<directory>./Tests/Model</directory>
<directory>./Tests/Controller</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">././Api</directory>
<directory suffix=".php">././Model</directory>
<directory suffix=".php">././Controller</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_CLASS" value="OpenAPI\Server\Tests\AppKernel" />