Fix PHP Symfony OpenAPI 3 sample location. Fixes #3531 (#3532)

* Fix PHP Symfony OpenAPI 3.0 sample location

* Update PHP Symfony OpenAPI 3.0 sample
This commit is contained in:
Ivan Aksamentov 2019-08-02 00:55:58 +02:00 committed by William Cheng
parent 581131e0fe
commit ed82aaae97
63 changed files with 8105 additions and 1 deletions

View File

@ -23,7 +23,7 @@ if [ ! -d "${APP_DIR}" ]; then
fi fi
# Make sure that we are regenerating the sample by removing any existing target directory # Make sure that we are regenerating the sample by removing any existing target directory
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/php-symfony/SymfonyBundle-php" TARGET_DIR="$SCRIPT_DIR/../../samples/openapi3/server/petstore/php-symfony/SymfonyBundle-php"
if [ -d "$TARGET_DIR" ]; then if [ -d "$TARGET_DIR" ]; then
rm -rf $TARGET_DIR rm -rf $TARGET_DIR
fi fi

View File

@ -0,0 +1,54 @@
# ref: https://github.com/github/gitignore/blob/master/Symfony.gitignore
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
# Email spool folder
/app/spool/*
# Cache, session files and logs (Symfony3)
/var/cache/*
/var/logs/*
/var/sessions/*
!var/cache/.gitkeep
!var/logs/.gitkeep
!var/sessions/.gitkeep
# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/
# Assets and user uploads
/web/bundles/
/web/uploads/
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/build/
# Composer PHAR
/composer.phar
# Backup entities generated with doctrine:generate:entities command
**/Entity/*~
# Embedded web-server pid file
/.web-server-pid
# From root gitignore
/Tests/cache/
/Tests/logs/

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,18 @@
<?php
return Symfony\CS\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->setUsingCache(true)
->fixers(
[
'ordered_use',
'phpdoc_order',
'short_array_syntax',
'strict',
'strict_param'
]
)
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
);

View File

@ -0,0 +1,10 @@
language: php
sudo: false
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
before_install: "composer install"
script: "vendor/bin/phpunit"

View File

@ -0,0 +1,80 @@
<?php
/**
* ApiServer
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Api
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Api;
/**
* ApiServer Class Doc Comment
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Api
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class ApiServer
{
/**
* @var array
*/
private $apis = array();
/**
* Adds an API handler to the server.
*
* @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)
{
if (isset($this->apis[$api])) {
throw new \InvalidArgumentException('API has already a handler: '.$api);
}
$this->apis[$api] = $handler;
}
/**
* Returns an API handler.
*
* @param string $api An API name of the handle
* @return mixed Returns a handler
* @throws \InvalidArgumentException When no such handler exists
*/
public function getApiHandler($api)
{
if (!isset($this->apis[$api])) {
throw new \InvalidArgumentException('No handler for '.$api.' implemented.');
}
return $this->apis[$api];
}
}

View File

@ -0,0 +1,190 @@
<?php
/**
* PetApiInterface
* PHP version 5
*
* @category Class
* @package OpenAPI\Server
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Api;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use OpenAPI\Server\Model\ApiResponse;
use OpenAPI\Server\Model\Pet;
/**
* PetApiInterface Interface Doc Comment
*
* @category Interface
* @package OpenAPI\Server\Api
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
interface PetApiInterface
{
/**
* Sets authentication method petstore_auth
*
* @param string $value Value of the petstore_auth authentication method.
*
* @return void
*/
public function setpetstore_auth($value);
/**
* Sets authentication method api_key
*
* @param string $value Value of the api_key authentication method.
*
* @return void
*/
public function setapi_key($value);
/**
* Sets authentication method petstore_auth
*
* @param string $value Value of the petstore_auth authentication method.
*
* @return void
*/
public function setpetstore_auth($value);
/**
* 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 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 $pet, &$responseCode, array &$responseHeaders);
/**
* Operation deletePet
*
* Deletes a pet
*
* @param int $petId Pet id to delete (required)
* @param string $apiKey (optional)
* @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);
/**
* Operation findPetsByStatus
*
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (required)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\Pet[]
*
*/
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders);
/**
* Operation findPetsByTags
*
* Finds Pets by tags
*
* @param string[] $tags Tags to filter by (required)
* @param int $maxCount Maximum number of items to return (optional)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\Pet[]
*
*/
public function findPetsByTags(array $tags, $maxCount = null, &$responseCode, array &$responseHeaders);
/**
* Operation getPetById
*
* Find pet by ID
*
* @param int $petId ID of pet to return (required)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\Pet
*
*/
public function getPetById($petId, &$responseCode, array &$responseHeaders);
/**
* Operation updatePet
*
* Update an existing pet
*
* @param OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required)
* @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 $pet, &$responseCode, array &$responseHeaders);
/**
* Operation updatePetWithForm
*
* 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 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);
/**
* Operation uploadFile
*
* 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 integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\ApiResponse
*
*/
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders);
}

View File

@ -0,0 +1,108 @@
<?php
/**
* StoreApiInterface
* PHP version 5
*
* @category Class
* @package OpenAPI\Server
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Api;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use OpenAPI\Server\Model\Order;
/**
* StoreApiInterface Interface Doc Comment
*
* @category Interface
* @package OpenAPI\Server\Api
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
interface StoreApiInterface
{
/**
* Sets authentication method api_key
*
* @param string $value Value of the api_key authentication method.
*
* @return void
*/
public function setapi_key($value);
/**
* Operation deleteOrder
*
* Delete purchase order by ID
*
* @param string $orderId ID of the order that needs to be deleted (required)
* @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);
/**
* Operation getInventory
*
* Returns pet inventories by status
*
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return int
*
*/
public function getInventory(&$responseCode, array &$responseHeaders);
/**
* Operation getOrderById
*
* Find purchase order by ID
*
* @param int $orderId ID of pet that needs to be fetched (required)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\Order
*
*/
public function getOrderById($orderId, &$responseCode, array &$responseHeaders);
/**
* Operation placeOrder
*
* Place an order for a pet
*
* @param OpenAPI\Server\Model\Order $order order placed for purchasing the pet (required)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\Order
*
*/
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders);
}

View File

@ -0,0 +1,166 @@
<?php
/**
* UserApiInterface
* PHP version 5
*
* @category Class
* @package OpenAPI\Server
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Api;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use OpenAPI\Server\Model\User;
/**
* UserApiInterface Interface Doc Comment
*
* @category Interface
* @package OpenAPI\Server\Api
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
interface UserApiInterface
{
/**
* Sets authentication method auth_cookie
*
* @param string $value Value of the auth_cookie authentication method.
*
* @return void
*/
public function setauth_cookie($value);
/**
* Operation createUser
*
* Create user
*
* @param OpenAPI\Server\Model\User $user Created user object (required)
* @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 $user, &$responseCode, array &$responseHeaders);
/**
* Operation createUsersWithArrayInput
*
* Creates list of users with given input array
*
* @param OpenAPI\Server\Model\User[] $user List of user object (required)
* @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 $user, &$responseCode, array &$responseHeaders);
/**
* Operation createUsersWithListInput
*
* Creates list of users with given input array
*
* @param OpenAPI\Server\Model\User[] $user List of user object (required)
* @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 $user, &$responseCode, array &$responseHeaders);
/**
* Operation deleteUser
*
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @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);
/**
* Operation getUserByName
*
* Get user by user name
*
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @param integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return OpenAPI\Server\Model\User
*
*/
public function getUserByName($username, &$responseCode, array &$responseHeaders);
/**
* Operation loginUser
*
* 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 integer $responseCode The HTTP response code to return
* @param array $responseHeaders Additional HTTP headers to return with the response ()
*
* @return string
*
*/
public function loginUser($username, $password, &$responseCode, array &$responseHeaders);
/**
* Operation logoutUser
*
* Logs out current logged in user session
*
* @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);
/**
* Operation updateUser
*
* Updated user
*
* @param string $username name that need to be deleted (required)
* @param OpenAPI\Server\Model\User $user Updated user object (required)
* @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 $user, &$responseCode, array &$responseHeaders);
}

View File

@ -0,0 +1,189 @@
<?php
/**
* Controller
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use OpenAPI\Server\Service\SerializerInterface;
use OpenAPI\Server\Service\ValidatorInterface;
/**
* Controller Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class Controller extends AbstractController
{
protected $validator;
protected $serializer;
protected $apiServer;
public function setValidator(ValidatorInterface $validator)
{
$this->validator = $validator;
}
public function setSerializer(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}
public function setApiServer($server)
{
$this->apiServer = $server;
}
/**
* This will return a response with code 400. Usage example:
* return $this->createBadRequestResponse('Unable to access this page!');
*
* @param string $message A message
*
* @return Response
*/
public function createBadRequestResponse($message = 'Bad Request.')
{
return new Response($message, 400);
}
/**
* This will return an error response. Usage example:
* return $this->createErrorResponse(new UnauthorizedHttpException());
*
* @param HttpException $exception An HTTP exception
*
* @return Response
*/
public function createErrorResponse(HttpException $exception)
{
$statusCode = $exception->getStatusCode();
$headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']);
$json = $this->exceptionToArray($exception);
$json['statusCode'] = $statusCode;
return new Response(json_encode($json, 15, 512), $statusCode, $headers);
}
/**
* 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)
{
return $this->serializer->serialize($data, $format);
}
/**
* Deserializes data from a given type format.
*
* @param string $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)
{
return $this->serializer->deserialize($data, $class, $format);
}
protected function validate($data, $asserts = null)
{
$errors = $this->validator->validate($data, $asserts);
if (count($errors) > 0) {
$errorsString = (string)$errors;
return $this->createBadRequestResponse($errorsString);
}
}
/**
* Converts an exception to a serializable array.
*
* @param \Exception|null $exception
*
* @return array
*/
private function exceptionToArray(\Exception $exception = null)
{
if (null === $exception) {
return null;
}
if (!$this->container->get('kernel')->isDebug()) {
return [
'message' => $exception->getMessage(),
];
}
return [
'message' => $exception->getMessage(),
'type' => get_class($exception),
'previous' => $this->exceptionToArray($exception->getPrevious()),
];
}
protected function getOutputFormat($accept, array $produced)
{
// Figure out what the client accepts
$accept = preg_split("/[\s,]+/", $accept);
if (in_array('*/*', $accept) || in_array('application/*', $accept)) {
// Prefer JSON if the client has no preference
if (in_array('application/json', $produced)) {
return 'application/json';
}
if (in_array('application/xml', $produced)) {
return 'application/xml';
}
}
if (in_array('application/json', $accept) && in_array('application/json', $produced)) {
return 'application/json';
}
if (in_array('application/xml', $accept) && in_array('application/xml', $produced)) {
return 'application/xml';
}
// If we reach this point, we don't have a common ground between server and client
return null;
}
}

View File

@ -0,0 +1,771 @@
<?php
/**
* PetController
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Controller;
use \Exception;
use JMS\Serializer\Exception\RuntimeException as SerializerRuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\Constraints as Assert;
use OpenAPI\Server\Api\PetApiInterface;
use OpenAPI\Server\Model\ApiResponse;
use OpenAPI\Server\Model\Pet;
/**
* PetController Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class PetController extends Controller
{
/**
* Operation addPet
*
* Add a new pet to the store
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function addPetAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json', 'application/xml'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$pet = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$pet = $this->deserialize($pet, 'OpenAPI\Server\Model\Pet', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet");
$asserts[] = new Assert\Valid();
$response = $this->validate($pet, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->addPet($pet, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 405:
$message = 'Invalid input';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation deletePet
*
* Deletes a pet
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function deletePetAction(Request $request, $petId)
{
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$apiKey = $request->headers->get('api_key');
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$petId = $this->deserialize($petId, 'int', 'string');
$apiKey = $this->deserialize($apiKey, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("int");
$response = $this->validate($petId, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\Type("string");
$response = $this->validate($apiKey, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 400:
$message = 'Invalid pet value';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation findPetsByStatus
*
* Finds Pets by status
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function findPetsByStatusAction(Request $request)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$status = $request->query->get('status');
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$status = $this->deserialize($status, 'array<csv,string>', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([
new Assert\Choice([ "available", "pending", "sold" ])
]);
$asserts[] = new Assert\All([
new Assert\Type("string"),
]);
$response = $this->validate($status, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->findPetsByStatus($status, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid status value';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation findPetsByTags
*
* Finds Pets by tags
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function findPetsByTagsAction(Request $request)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$tags = $request->query->get('tags');
$maxCount = $request->query->get('maxCount');
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$tags = $this->deserialize($tags, 'array<csv,string>', 'string');
$maxCount = $this->deserialize($maxCount, 'int', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([
new Assert\Type("string"),
]);
$response = $this->validate($tags, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\Type("int");
$response = $this->validate($maxCount, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->findPetsByTags($tags, $maxCount, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid tag value';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation getPetById
*
* Find pet by ID
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function getPetByIdAction(Request $request, $petId)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Authentication 'api_key' required
// Set key with prefix in header
$securityapi_key = $request->headers->get('api_key');
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$petId = $this->deserialize($petId, 'int', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("int");
$response = $this->validate($petId, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'api_key'
$handler->setapi_key($securityapi_key);
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getPetById($petId, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid ID supplied';
break;
case 404:
$message = 'Pet not found';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation updatePet
*
* Update an existing pet
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function updatePetAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json', 'application/xml'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$pet = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$pet = $this->deserialize($pet, 'OpenAPI\Server\Model\Pet', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet");
$asserts[] = new Assert\Valid();
$response = $this->validate($pet, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->updatePet($pet, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 400:
$message = 'Invalid ID supplied';
break;
case 404:
$message = 'Pet not found';
break;
case 405:
$message = 'Validation exception';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation updatePetWithForm
*
* Updates a pet in the store with form data
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function updatePetWithFormAction(Request $request, $petId)
{
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$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
try {
$petId = $this->deserialize($petId, 'int', 'string');
$name = $this->deserialize($name, 'string', 'string');
$status = $this->deserialize($status, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("int");
$response = $this->validate($petId, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\Type("string");
$response = $this->validate($name, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\Type("string");
$response = $this->validate($status, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 405:
$message = 'Invalid input';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation uploadFile
*
* uploads an image
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function uploadFileAction(Request $request, $petId)
{
// Figure out what data format to return to the client
$produces = ['application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Authentication 'petstore_auth' required
// Oauth required
$securitypetstore_auth = $request->headers->get('authorization');
// Read out all input parameter values into variables
$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
try {
$petId = $this->deserialize($petId, 'int', 'string');
$additionalMetadata = $this->deserialize($additionalMetadata, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("int");
$response = $this->validate($petId, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\Type("string");
$response = $this->validate($additionalMetadata, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\File();
$response = $this->validate($file, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'petstore_auth'
$handler->setpetstore_auth($securitypetstore_auth);
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->uploadFile($petId, $additionalMetadata, $file, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Returns the handler for this API controller.
* @return PetApiInterface
*/
public function getApiHandler()
{
return $this->apiServer->getApiHandler('pet');
}
}

View File

@ -0,0 +1,373 @@
<?php
/**
* StoreController
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Controller;
use \Exception;
use JMS\Serializer\Exception\RuntimeException as SerializerRuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\Constraints as Assert;
use OpenAPI\Server\Api\StoreApiInterface;
use OpenAPI\Server\Model\Order;
/**
* StoreController Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class StoreController extends Controller
{
/**
* Operation deleteOrder
*
* Delete purchase order by ID
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function deleteOrderAction(Request $request, $orderId)
{
// Handle authentication
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$orderId = $this->deserialize($orderId, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$response = $this->validate($orderId, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deleteOrder($orderId, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 400:
$message = 'Invalid ID supplied';
break;
case 404:
$message = 'Order not found';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation getInventory
*
* Returns pet inventories by status
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function getInventoryAction(Request $request)
{
// Figure out what data format to return to the client
$produces = ['application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Authentication 'api_key' required
// Set key with prefix in header
$securityapi_key = $request->headers->get('api_key');
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Validate the input values
try {
$handler = $this->getApiHandler();
// Set authentication method 'api_key'
$handler->setapi_key($securityapi_key);
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getInventory($responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation getOrderById
*
* Find purchase order by ID
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function getOrderByIdAction(Request $request, $orderId)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$orderId = $this->deserialize($orderId, 'int', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("int");
$asserts[] = new Assert\GreaterThanOrEqual(1);
$asserts[] = new Assert\LessThanOrEqual(1);
$response = $this->validate($orderId, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getOrderById($orderId, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid ID supplied';
break;
case 404:
$message = 'Order not found';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation placeOrder
*
* Place an order for a pet
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function placeOrderAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
$order = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$order = $this->deserialize($order, 'OpenAPI\Server\Model\Order', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Order");
$asserts[] = new Assert\Valid();
$response = $this->validate($order, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->placeOrder($order, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid Order';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Returns the handler for this API controller.
* @return StoreApiInterface
*/
public function getApiHandler()
{
return $this->apiServer->getApiHandler('store');
}
}

View File

@ -0,0 +1,710 @@
<?php
/**
* UserController
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Controller;
use \Exception;
use JMS\Serializer\Exception\RuntimeException as SerializerRuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\Constraints as Assert;
use OpenAPI\Server\Api\UserApiInterface;
use OpenAPI\Server\Model\User;
/**
* UserController Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Controller
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class UserController extends Controller
{
/**
* Operation createUser
*
* Create user
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function createUserAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
$user = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$user = $this->deserialize($user, 'OpenAPI\Server\Model\User', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("OpenAPI\Server\Model\User");
$asserts[] = new Assert\Valid();
$response = $this->validate($user, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUser($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 0:
$message = 'successful operation';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation createUsersWithArrayInput
*
* Creates list of users with given input array
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function createUsersWithArrayInputAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
$user = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$user = $this->deserialize($user, 'array<OpenAPI\Server\Model\User>', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([
new Assert\Type("OpenAPI\Server\Model\User"),
new Assert\Valid(),
]);
$response = $this->validate($user, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 0:
$message = 'successful operation';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation createUsersWithListInput
*
* Creates list of users with given input array
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function createUsersWithListInputAction(Request $request)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
$user = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$user = $this->deserialize($user, 'array<OpenAPI\Server\Model\User>', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\All([
new Assert\Type("OpenAPI\Server\Model\User"),
new Assert\Valid(),
]);
$response = $this->validate($user, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 0:
$message = 'successful operation';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation deleteUser
*
* Delete user
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function deleteUserAction(Request $request, $username)
{
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$username = $this->deserialize($username, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$response = $this->validate($username, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->deleteUser($username, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 400:
$message = 'Invalid username supplied';
break;
case 404:
$message = 'User not found';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation getUserByName
*
* Get user by user name
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function getUserByNameAction(Request $request, $username)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$username = $this->deserialize($username, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$response = $this->validate($username, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->getUserByName($username, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid username supplied';
break;
case 404:
$message = 'User not found';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation loginUser
*
* Logs user into the system
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function loginUserAction(Request $request)
{
// Figure out what data format to return to the client
$produces = ['application/xml', 'application/json'];
// Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces);
if ($responseFormat === null) {
return new Response('', 406);
}
// Handle authentication
// Read out all input parameter values into variables
$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
try {
$username = $this->deserialize($username, 'string', 'string');
$password = $this->deserialize($password, 'string', 'string');
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$asserts[] = new Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/");
$response = $this->validate($username, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$response = $this->validate($password, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Make the call to the business logic
$responseCode = 200;
$responseHeaders = [];
$result = $handler->loginUser($username, $password, $responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 200:
$message = 'successful operation';
break;
case 400:
$message = 'Invalid username/password supplied';
break;
}
return new Response(
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation logoutUser
*
* Logs out current logged in user session
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function logoutUserAction(Request $request)
{
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
// Use the default value if no value was provided
// Validate the input values
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->logoutUser($responseCode, $responseHeaders);
// Find default response message
$message = 'successful operation';
// Find a more specific message, if available
switch ($responseCode) {
case 0:
$message = 'successful operation';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Operation updateUser
*
* Updated user
*
* @param Request $request The Symfony request to handle.
* @return Response The Symfony response.
*/
public function updateUserAction(Request $request, $username)
{
// Make sure that the client is providing something that we can consume
$consumes = ['application/json'];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us
return new Response('', 415);
}
// Handle authentication
// Authentication 'auth_cookie' required
// Set key with prefix in cookies
$securityauth_cookie = $request->cookies->get('AUTH_KEY');
// Read out all input parameter values into variables
$user = $request->getContent();
// Use the default value if no value was provided
// Deserialize the input values that needs it
try {
$username = $this->deserialize($username, 'string', 'string');
$user = $this->deserialize($user, 'OpenAPI\Server\Model\User', $inputFormat);
} catch (SerializerRuntimeException $exception) {
return $this->createBadRequestResponse($exception->getMessage());
}
// Validate the input values
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("string");
$response = $this->validate($username, $asserts);
if ($response instanceof Response) {
return $response;
}
$asserts = [];
$asserts[] = new Assert\NotNull();
$asserts[] = new Assert\Type("OpenAPI\Server\Model\User");
$asserts[] = new Assert\Valid();
$response = $this->validate($user, $asserts);
if ($response instanceof Response) {
return $response;
}
try {
$handler = $this->getApiHandler();
// Set authentication method 'auth_cookie'
$handler->setauth_cookie($securityauth_cookie);
// Make the call to the business logic
$responseCode = 204;
$responseHeaders = [];
$result = $handler->updateUser($username, $user, $responseCode, $responseHeaders);
// Find default response message
$message = '';
// Find a more specific message, if available
switch ($responseCode) {
case 400:
$message = 'Invalid user supplied';
break;
case 404:
$message = 'User not found';
break;
}
return new Response(
'',
$responseCode,
array_merge(
$responseHeaders,
[
'X-OpenAPI-Message' => $message
]
)
);
} catch (Exception $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
}
}
/**
* Returns the handler for this API controller.
* @return UserApiInterface
*/
public function getApiHandler()
{
return $this->apiServer->getApiHandler('user');
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* OpenAPIServerApiPass
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\DependencyInjection\Compiler
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* OpenAPIServerApiPass Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\DependencyInjection\Compiler
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class OpenAPIServerApiPass implements CompilerPassInterface
{
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container) {
// always first check if the primary service is defined
if (!$container->has('open_api_server.api.api_server')) {
return;
}
$definition = $container->findDefinition('open_api_server.api.api_server');
// find all service IDs with the open_api_server.api tag
$taggedServices = $container->findTaggedServiceIds('open_api_server.api');
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $tag) {
// add the transport service to the ChainTransport service
$definition->addMethodCall('addApiHandler', [$tag['api'], new Reference($id)]);
}
}
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* OpenAPIServerExtension
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\DependencyInjection
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
/**
* OpenAPIServerExtension Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\DependencyInjection
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class OpenAPIServerExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
public function getAlias()
{
return 'open_api_server';
}
}

View File

@ -0,0 +1,154 @@
<?php
/**
* ApiResponse
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the ApiResponse model.
*
* Describes the result of uploading an image resource
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class ApiResponse
{
/**
* @var int|null
* @SerializedName("code")
* @Assert\Type("int")
* @Type("int")
*/
protected $code;
/**
* @var string|null
* @SerializedName("type")
* @Assert\Type("string")
* @Type("string")
*/
protected $type;
/**
* @var string|null
* @SerializedName("message")
* @Assert\Type("string")
* @Type("string")
*/
protected $message;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets code.
*
* @return int|null
*/
public function getCode()
{
return $this->code;
}
/**
* Sets code.
*
* @param int|null $code
*
* @return $this
*/
public function setCode($code = null)
{
$this->code = $code;
return $this;
}
/**
* Gets type.
*
* @return string|null
*/
public function getType()
{
return $this->type;
}
/**
* Sets type.
*
* @param string|null $type
*
* @return $this
*/
public function setType($type = null)
{
$this->type = $type;
return $this;
}
/**
* Gets message.
*
* @return string|null
*/
public function getMessage()
{
return $this->message;
}
/**
* Sets message.
*
* @param string|null $message
*
* @return $this
*/
public function setMessage($message = null)
{
$this->message = $message;
return $this;
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* Category
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the Category model.
*
* A category for a pet
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class Category
{
/**
* @var int|null
* @SerializedName("id")
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
/**
* @var string|null
* @SerializedName("name")
* @Assert\Type("string")
* @Type("string")
* @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")
*/
protected $name;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Sets id.
*
* @param int|null $id
*
* @return $this
*/
public function setId($id = null)
{
$this->id = $id;
return $this;
}
/**
* Gets name.
*
* @return string|null
*/
public function getName()
{
return $this->name;
}
/**
* Sets name.
*
* @param string|null $name
*
* @return $this
*/
public function setName($name = null)
{
$this->name = $name;
return $this;
}
}

View File

@ -0,0 +1,123 @@
<?php
/**
* InlineObject
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the InlineObject model.
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class InlineObject
{
/**
* Updated name of the pet
*
* @var string|null
* @SerializedName("name")
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
/**
* Updated status of the pet
*
* @var string|null
* @SerializedName("status")
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->name = isset($data['name']) ? $data['name'] : null;
$this->status = isset($data['status']) ? $data['status'] : null;
}
/**
* Gets name.
*
* @return string|null
*/
public function getName()
{
return $this->name;
}
/**
* Sets name.
*
* @param string|null $name Updated name of the pet
*
* @return $this
*/
public function setName($name = null)
{
$this->name = $name;
return $this;
}
/**
* Gets status.
*
* @return string|null
*/
public function getStatus()
{
return $this->status;
}
/**
* Sets status.
*
* @param string|null $status Updated status of the pet
*
* @return $this
*/
public function setStatus($status = null)
{
$this->status = $status;
return $this;
}
}

View File

@ -0,0 +1,123 @@
<?php
/**
* InlineObject1
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the InlineObject1 model.
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class InlineObject1
{
/**
* Additional data to pass to server
*
* @var string|null
* @SerializedName("additionalMetadata")
* @Assert\Type("string")
* @Type("string")
*/
protected $additionalMetadata;
/**
* file to upload
*
* @var UploadedFile|null
* @SerializedName("file")
* @Assert\Type("UploadedFile")
* @Type("UploadedFile")
*/
protected $file;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->additionalMetadata = isset($data['additionalMetadata']) ? $data['additionalMetadata'] : null;
$this->file = isset($data['file']) ? $data['file'] : null;
}
/**
* Gets additionalMetadata.
*
* @return string|null
*/
public function getAdditionalMetadata()
{
return $this->additionalMetadata;
}
/**
* Sets additionalMetadata.
*
* @param string|null $additionalMetadata Additional data to pass to server
*
* @return $this
*/
public function setAdditionalMetadata($additionalMetadata = null)
{
$this->additionalMetadata = $additionalMetadata;
return $this;
}
/**
* Gets file.
*
* @return UploadedFile|null
*/
public function getFile()
{
return $this->file;
}
/**
* Sets file.
*
* @param UploadedFile|null $file file to upload
*
* @return $this
*/
public function setFile(UploadedFile $file = null)
{
$this->file = $file;
return $this;
}
}

View File

@ -0,0 +1,256 @@
<?php
/**
* Order
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the Order model.
*
* An order for a pets from the pet store
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class Order
{
/**
* @var int|null
* @SerializedName("id")
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
/**
* @var int|null
* @SerializedName("petId")
* @Assert\Type("int")
* @Type("int")
*/
protected $petId;
/**
* @var int|null
* @SerializedName("quantity")
* @Assert\Type("int")
* @Type("int")
*/
protected $quantity;
/**
* @var \DateTime|null
* @SerializedName("shipDate")
* @Assert\DateTime()
* @Type("DateTime")
*/
protected $shipDate;
/**
* Order Status
*
* @var string|null
* @SerializedName("status")
* @Assert\Choice({ "placed", "approved", "delivered" })
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
/**
* @var bool|null
* @SerializedName("complete")
* @Assert\Type("bool")
* @Type("bool")
*/
protected $complete;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Sets id.
*
* @param int|null $id
*
* @return $this
*/
public function setId($id = null)
{
$this->id = $id;
return $this;
}
/**
* Gets petId.
*
* @return int|null
*/
public function getPetId()
{
return $this->petId;
}
/**
* Sets petId.
*
* @param int|null $petId
*
* @return $this
*/
public function setPetId($petId = null)
{
$this->petId = $petId;
return $this;
}
/**
* Gets quantity.
*
* @return int|null
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Sets quantity.
*
* @param int|null $quantity
*
* @return $this
*/
public function setQuantity($quantity = null)
{
$this->quantity = $quantity;
return $this;
}
/**
* Gets shipDate.
*
* @return \DateTime|null
*/
public function getShipDate()
{
return $this->shipDate;
}
/**
* Sets shipDate.
*
* @param \DateTime|null $shipDate
*
* @return $this
*/
public function setShipDate(\DateTime $shipDate = null)
{
$this->shipDate = $shipDate;
return $this;
}
/**
* Gets status.
*
* @return string|null
*/
public function getStatus()
{
return $this->status;
}
/**
* Sets status.
*
* @param string|null $status Order Status
*
* @return $this
*/
public function setStatus($status = null)
{
$this->status = $status;
return $this;
}
/**
* Gets complete.
*
* @return bool|null
*/
public function isComplete()
{
return $this->complete;
}
/**
* Sets complete.
*
* @param bool|null $complete
*
* @return $this
*/
public function setComplete($complete = null)
{
$this->complete = $complete;
return $this;
}
}

View File

@ -0,0 +1,262 @@
<?php
/**
* Pet
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the Pet model.
*
* A pet for sale in the pet store
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class Pet
{
/**
* @var int|null
* @SerializedName("id")
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
/**
* @var OpenAPI\Server\Model\Category|null
* @SerializedName("category")
* @Assert\Type("OpenAPI\Server\Model\Category")
* @Type("OpenAPI\Server\Model\Category")
*/
protected $category;
/**
* @var string
* @SerializedName("name")
* @Assert\NotNull()
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
/**
* @var string[]
* @SerializedName("photoUrls")
* @Assert\NotNull()
* @Assert\All({
* @Assert\Type("string")
* })
* @Type("array<string>")
*/
protected $photoUrls;
/**
* @var OpenAPI\Server\Model\Tag[]|null
* @SerializedName("tags")
* @Assert\All({
* @Assert\Type("OpenAPI\Server\Model\Tag")
* })
* @Type("array<OpenAPI\Server\Model\Tag>")
*/
protected $tags;
/**
* pet status in the store
*
* @var string|null
* @SerializedName("status")
* @Assert\Choice({ "available", "pending", "sold" })
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Sets id.
*
* @param int|null $id
*
* @return $this
*/
public function setId($id = null)
{
$this->id = $id;
return $this;
}
/**
* Gets category.
*
* @return OpenAPI\Server\Model\Category|null
*/
public function getCategory()
{
return $this->category;
}
/**
* Sets category.
*
* @param OpenAPI\Server\Model\Category|null $category
*
* @return $this
*/
public function setCategory(Category $category = null)
{
$this->category = $category;
return $this;
}
/**
* Gets name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Sets name.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Gets photoUrls.
*
* @return string[]
*/
public function getPhotoUrls()
{
return $this->photoUrls;
}
/**
* Sets photoUrls.
*
* @param string[] $photoUrls
*
* @return $this
*/
public function setPhotoUrls(array $photoUrls)
{
$this->photoUrls = $photoUrls;
return $this;
}
/**
* Gets tags.
*
* @return OpenAPI\Server\Model\Tag[]|null
*/
public function getTags()
{
return $this->tags;
}
/**
* Sets tags.
*
* @param OpenAPI\Server\Model\Tag[]|null $tags
*
* @return $this
*/
public function setTags(array $tags = null)
{
$this->tags = $tags;
return $this;
}
/**
* Gets status.
*
* @return string|null
*/
public function getStatus()
{
return $this->status;
}
/**
* Sets status.
*
* @param string|null $status pet status in the store
*
* @return $this
*/
public function setStatus($status = null)
{
$this->status = $status;
return $this;
}
}

View File

@ -0,0 +1,121 @@
<?php
/**
* Tag
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the Tag model.
*
* A tag for a pet
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class Tag
{
/**
* @var int|null
* @SerializedName("id")
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
/**
* @var string|null
* @SerializedName("name")
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Sets id.
*
* @param int|null $id
*
* @return $this
*/
public function setId($id = null)
{
$this->id = $id;
return $this;
}
/**
* Gets name.
*
* @return string|null
*/
public function getName()
{
return $this->name;
}
/**
* Sets name.
*
* @param string|null $name
*
* @return $this
*/
public function setName($name = null)
{
$this->name = $name;
return $this;
}
}

View File

@ -0,0 +1,321 @@
<?php
/**
* User
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the User model.
*
* A User who is purchasing from the pet store
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class User
{
/**
* @var int|null
* @SerializedName("id")
* @Assert\Type("int")
* @Type("int")
*/
protected $id;
/**
* @var string|null
* @SerializedName("username")
* @Assert\Type("string")
* @Type("string")
*/
protected $username;
/**
* @var string|null
* @SerializedName("firstName")
* @Assert\Type("string")
* @Type("string")
*/
protected $firstName;
/**
* @var string|null
* @SerializedName("lastName")
* @Assert\Type("string")
* @Type("string")
*/
protected $lastName;
/**
* @var string|null
* @SerializedName("email")
* @Assert\Type("string")
* @Type("string")
*/
protected $email;
/**
* @var string|null
* @SerializedName("password")
* @Assert\Type("string")
* @Type("string")
*/
protected $password;
/**
* @var string|null
* @SerializedName("phone")
* @Assert\Type("string")
* @Type("string")
*/
protected $phone;
/**
* User Status
*
* @var int|null
* @SerializedName("userStatus")
* @Assert\Type("int")
* @Type("int")
*/
protected $userStatus;
/**
* Constructor
* @param mixed[] $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;
}
/**
* Gets id.
*
* @return int|null
*/
public function getId()
{
return $this->id;
}
/**
* Sets id.
*
* @param int|null $id
*
* @return $this
*/
public function setId($id = null)
{
$this->id = $id;
return $this;
}
/**
* Gets username.
*
* @return string|null
*/
public function getUsername()
{
return $this->username;
}
/**
* Sets username.
*
* @param string|null $username
*
* @return $this
*/
public function setUsername($username = null)
{
$this->username = $username;
return $this;
}
/**
* Gets firstName.
*
* @return string|null
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Sets firstName.
*
* @param string|null $firstName
*
* @return $this
*/
public function setFirstName($firstName = null)
{
$this->firstName = $firstName;
return $this;
}
/**
* Gets lastName.
*
* @return string|null
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Sets lastName.
*
* @param string|null $lastName
*
* @return $this
*/
public function setLastName($lastName = null)
{
$this->lastName = $lastName;
return $this;
}
/**
* Gets email.
*
* @return string|null
*/
public function getEmail()
{
return $this->email;
}
/**
* Sets email.
*
* @param string|null $email
*
* @return $this
*/
public function setEmail($email = null)
{
$this->email = $email;
return $this;
}
/**
* Gets password.
*
* @return string|null
*/
public function getPassword()
{
return $this->password;
}
/**
* Sets password.
*
* @param string|null $password
*
* @return $this
*/
public function setPassword($password = null)
{
$this->password = $password;
return $this;
}
/**
* Gets phone.
*
* @return string|null
*/
public function getPhone()
{
return $this->phone;
}
/**
* Sets phone.
*
* @param string|null $phone
*
* @return $this
*/
public function setPhone($phone = null)
{
$this->phone = $phone;
return $this;
}
/**
* Gets userStatus.
*
* @return int|null
*/
public function getUserStatus()
{
return $this->userStatus;
}
/**
* Sets userStatus.
*
* @param int|null $userStatus User Status
*
* @return $this
*/
public function setUserStatus($userStatus = null)
{
$this->userStatus = $userStatus;
return $this;
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* OpenAPIServerBundle
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use OpenAPI\Server\DependencyInjection\Compiler\OpenAPIServerApiPass;
/**
* OpenAPIServerBundle Class Doc Comment
*
* @category Class
* @package OpenAPI\Server
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
class OpenAPIServerBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new OpenAPIServerApiPass());
}
}

View File

@ -0,0 +1,190 @@
# OpenAPIServer
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
This [Symfony](https://symfony.com/) bundle is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0
- Build package: org.openapitools.codegen.languages.PhpSymfonyServerCodegen
## Requirements
PHP 5.4.0 and later
## Installation & Usage
To install the dependencies via [Composer](http://getcomposer.org/), add the following repository to `composer.json` of your Symfony project:
```json
{
"repositories": [{
"type": "path",
"url": "//Path to your generated openapi bundle"
}],
}
```
Then run:
```
composer require GIT_USER_ID/GIT_REPO_ID:dev-master
```
to add the generated openapi bundle as a dependency.
## Tests
To run the unit tests for the generated bundle, first navigate to the directory containing the code, then run the following commands:
```
composer install
./vendor/bin/phpunit
```
## Getting Started
Step 1: Please follow the [installation procedure](#installation--usage) first.
Step 2: Enable the bundle in the kernel:
```php
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new OpenAPI\Server\OpenAPIServerBundle(),
// ...
);
}
```
Step 3: Register the routes:
```yaml
# app/config/routing.yml
open_api_server:
resource: "@OpenAPIServerBundle/Resources/config/routing.yml"
```
Step 4: Implement the API calls:
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface // An interface is autogenerated
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
/**
* Implementation of PetApiInterface#addPet
*/
public function addPet(Pet $pet)
{
// Implement the operation ...
}
// Other operation methods ...
}
```
Step 5: Tag your API implementation:
```yaml
# src/Acme/MyBundle/Resources/services.yml
services:
# ...
acme.my_bundle.api.pet:
class: Acme\MyBundle\Api\PetApi
tags:
- { name: "open_api_server.api", api: "pet" }
# ...
```
Now you can start using the bundle!
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*PetApiInterface* | [**addPet**](Resources/docs/Api/PetApiInterface.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApiInterface* | [**deletePet**](Resources/docs/Api/PetApiInterface.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApiInterface* | [**findPetsByStatus**](Resources/docs/Api/PetApiInterface.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApiInterface* | [**findPetsByTags**](Resources/docs/Api/PetApiInterface.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApiInterface* | [**getPetById**](Resources/docs/Api/PetApiInterface.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApiInterface* | [**updatePet**](Resources/docs/Api/PetApiInterface.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApiInterface* | [**updatePetWithForm**](Resources/docs/Api/PetApiInterface.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApiInterface* | [**uploadFile**](Resources/docs/Api/PetApiInterface.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApiInterface* | [**deleteOrder**](Resources/docs/Api/StoreApiInterface.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApiInterface* | [**getInventory**](Resources/docs/Api/StoreApiInterface.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApiInterface* | [**getOrderById**](Resources/docs/Api/StoreApiInterface.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApiInterface* | [**placeOrder**](Resources/docs/Api/StoreApiInterface.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApiInterface* | [**createUser**](Resources/docs/Api/UserApiInterface.md#createuser) | **POST** /user | Create user
*UserApiInterface* | [**createUsersWithArrayInput**](Resources/docs/Api/UserApiInterface.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApiInterface* | [**createUsersWithListInput**](Resources/docs/Api/UserApiInterface.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApiInterface* | [**deleteUser**](Resources/docs/Api/UserApiInterface.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApiInterface* | [**getUserByName**](Resources/docs/Api/UserApiInterface.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApiInterface* | [**loginUser**](Resources/docs/Api/UserApiInterface.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApiInterface* | [**logoutUser**](Resources/docs/Api/UserApiInterface.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApiInterface* | [**updateUser**](Resources/docs/Api/UserApiInterface.md#updateuser) | **PUT** /user/{username} | Updated user
## Documentation For Models
- [ApiResponse](Resources/docs/Model/ApiResponse.md)
- [Category](Resources/docs/Model/Category.md)
- [InlineObject](Resources/docs/Model/InlineObject.md)
- [InlineObject1](Resources/docs/Model/InlineObject1.md)
- [Order](Resources/docs/Model/Order.md)
- [Pet](Resources/docs/Model/Pet.md)
- [Tag](Resources/docs/Model/Tag.md)
- [User](Resources/docs/Model/User.md)
## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## auth_cookie
- **Type**: API key
- **API key parameter name**: AUTH_KEY
- **Location**:
## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## Author

View File

@ -0,0 +1,145 @@
# NOTE: This file is auto generated by the openapi generator program.
# https://github.com/openapitools/openapi-generator
# Do not edit the class manually.
# pet
open_api_server_pet_addpet:
path: /pet
methods: [POST]
defaults:
_controller: open_api_server.controller.pet:addPetAction
open_api_server_pet_deletepet:
path: /pet/{petId}
methods: [DELETE]
defaults:
_controller: open_api_server.controller.pet:deletePetAction
requirements:
petId: '\d+'
open_api_server_pet_findpetsbystatus:
path: /pet/findByStatus
methods: [GET]
defaults:
_controller: open_api_server.controller.pet:findPetsByStatusAction
open_api_server_pet_findpetsbytags:
path: /pet/findByTags
methods: [GET]
defaults:
_controller: open_api_server.controller.pet:findPetsByTagsAction
open_api_server_pet_getpetbyid:
path: /pet/{petId}
methods: [GET]
defaults:
_controller: open_api_server.controller.pet:getPetByIdAction
requirements:
petId: '\d+'
open_api_server_pet_updatepet:
path: /pet
methods: [PUT]
defaults:
_controller: open_api_server.controller.pet:updatePetAction
open_api_server_pet_updatepetwithform:
path: /pet/{petId}
methods: [POST]
defaults:
_controller: open_api_server.controller.pet:updatePetWithFormAction
requirements:
petId: '\d+'
open_api_server_pet_uploadfile:
path: /pet/{petId}/uploadImage
methods: [POST]
defaults:
_controller: open_api_server.controller.pet:uploadFileAction
requirements:
petId: '\d+'
# store
open_api_server_store_deleteorder:
path: /store/order/{orderId}
methods: [DELETE]
defaults:
_controller: open_api_server.controller.store:deleteOrderAction
requirements:
orderId: '[a-z0-9]+'
open_api_server_store_getinventory:
path: /store/inventory
methods: [GET]
defaults:
_controller: open_api_server.controller.store:getInventoryAction
open_api_server_store_getorderbyid:
path: /store/order/{orderId}
methods: [GET]
defaults:
_controller: open_api_server.controller.store:getOrderByIdAction
requirements:
orderId: '\d+'
open_api_server_store_placeorder:
path: /store/order
methods: [POST]
defaults:
_controller: open_api_server.controller.store:placeOrderAction
# user
open_api_server_user_createuser:
path: /user
methods: [POST]
defaults:
_controller: open_api_server.controller.user:createUserAction
open_api_server_user_createuserswitharrayinput:
path: /user/createWithArray
methods: [POST]
defaults:
_controller: open_api_server.controller.user:createUsersWithArrayInputAction
open_api_server_user_createuserswithlistinput:
path: /user/createWithList
methods: [POST]
defaults:
_controller: open_api_server.controller.user:createUsersWithListInputAction
open_api_server_user_deleteuser:
path: /user/{username}
methods: [DELETE]
defaults:
_controller: open_api_server.controller.user:deleteUserAction
requirements:
username: '[a-z0-9]+'
open_api_server_user_getuserbyname:
path: /user/{username}
methods: [GET]
defaults:
_controller: open_api_server.controller.user:getUserByNameAction
requirements:
username: '[a-z0-9]+'
open_api_server_user_loginuser:
path: /user/login
methods: [GET]
defaults:
_controller: open_api_server.controller.user:loginUserAction
open_api_server_user_logoutuser:
path: /user/logout
methods: [GET]
defaults:
_controller: open_api_server.controller.user:logoutUserAction
open_api_server_user_updateuser:
path: /user/{username}
methods: [PUT]
defaults:
_controller: open_api_server.controller.user:updateUserAction
requirements:
username: '[a-z0-9]+'

View File

@ -0,0 +1,50 @@
# NOTE: This file is auto generated by the openapi generator program.
# https://github.com/openapitools/openapi-generator
# Do not edit the class manually.
parameters:
open_api_server.serializer: 'OpenAPI\Server\Service\JmsSerializer'
open_api_server.validator: 'OpenAPI\Server\Service\SymfonyValidator'
services:
open_api_server.api.api_server:
class: OpenAPI\Server\Api\ApiServer
open_api_server.model.model_serializer:
class: OpenAPI\Server\Model\ModelSerializer
open_api_server.service.serializer:
class: '%open_api_server.serializer%'
open_api_server.service.validator:
class: '%open_api_server.validator%'
arguments:
- '@validator'
open_api_server.controller.pet:
class: OpenAPI\Server\Controller\PetController
calls:
- [setSerializer, ['@open_api_server.service.serializer']]
- [setValidator, ['@open_api_server.service.validator']]
- [setApiServer, ['@open_api_server.api.api_server']]
tags: ['controller.service_arguments']
autowire: true
open_api_server.controller.store:
class: OpenAPI\Server\Controller\StoreController
calls:
- [setSerializer, ['@open_api_server.service.serializer']]
- [setValidator, ['@open_api_server.service.validator']]
- [setApiServer, ['@open_api_server.api.api_server']]
tags: ['controller.service_arguments']
autowire: true
open_api_server.controller.user:
class: OpenAPI\Server\Controller\UserController
calls:
- [setSerializer, ['@open_api_server.service.serializer']]
- [setValidator, ['@open_api_server.service.validator']]
- [setApiServer, ['@open_api_server.api.api_server']]
tags: ['controller.service_arguments']
autowire: true

View File

@ -0,0 +1,520 @@
# OpenAPI\Server\Api\PetApiInterface
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addPet**](PetApiInterface.md#addPet) | **POST** /pet | Add a new pet to the store
[**deletePet**](PetApiInterface.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
[**findPetsByStatus**](PetApiInterface.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
[**findPetsByTags**](PetApiInterface.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
[**getPetById**](PetApiInterface.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
[**updatePet**](PetApiInterface.md#updatePet) | **PUT** /pet | Update an existing pet
[**updatePetWithForm**](PetApiInterface.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**uploadFile**](PetApiInterface.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
## Service Declaration
```yaml
# src/Acme/MyBundle/Resources/services.yml
services:
# ...
acme.my_bundle.api.pet:
class: Acme\MyBundle\Api\PetApi
tags:
- { name: "open_api_server.api", api: "pet" }
# ...
```
## **addPet**
> addPet($pet)
Add a new pet to the store
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#addPet
*/
public function addPet(Pet $pet)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
void (empty response body)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
[[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)
## **deletePet**
> deletePet($petId, $apiKey)
Deletes a pet
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#deletePet
*/
public function deletePet($petId, $apiKey = null)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete |
**apiKey** | **string**| | [optional]
### Return type
void (empty response body)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[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**
> OpenAPI\Server\Model\Pet findPetsByStatus($status)
Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#findPetsByStatus
*/
public function findPetsByStatus(array $status)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**string**](../Model/string.md)| Status values that need to be considered for filter |
### Return type
[**OpenAPI\Server\Model\Pet**](../Model/Pet.md)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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**
> OpenAPI\Server\Model\Pet findPetsByTags($tags, $maxCount)
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#findPetsByTags
*/
public function findPetsByTags(array $tags, $maxCount = null)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**string**](../Model/string.md)| Tags to filter by |
**maxCount** | **int**| Maximum number of items to return | [optional]
### Return type
[**OpenAPI\Server\Model\Pet**](../Model/Pet.md)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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)
## **getPetById**
> OpenAPI\Server\Model\Pet getPetById($petId)
Find pet by ID
Returns a single pet
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure API key authorization: api_key
*/
public function setapi_key($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of PetApiInterface#getPetById
*/
public function getPetById($petId)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return |
### Return type
[**OpenAPI\Server\Model\Pet**](../Model/Pet.md)
### Authorization
[api_key](../../README.md#api_key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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)
## **updatePet**
> updatePet($pet)
Update an existing pet
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#updatePet
*/
public function updatePet(Pet $pet)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
void (empty response body)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
[[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)
## **updatePetWithForm**
> updatePetWithForm($petId, $name, $status)
Updates a pet in the store with form data
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#updatePetWithForm
*/
public function updatePetWithForm($petId, $name = null, $status = null)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated |
**name** | **string**| Updated name of the pet | [optional]
**status** | **string**| Updated status of the pet | [optional]
### Return type
void (empty response body)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
[[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)
## **uploadFile**
> OpenAPI\Server\Model\ApiResponse uploadFile($petId, $additionalMetadata, $file)
uploads an image
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/PetApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\PetApiInterface;
class PetApi implements PetApiInterface
{
/**
* Configure OAuth2 access token for authorization: petstore_auth
*/
public function setpetstore_auth($oauthToken)
{
// Retrieve logged in user from $oauthToken ...
}
// ...
/**
* Implementation of PetApiInterface#uploadFile
*/
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update |
**additionalMetadata** | **string**| Additional data to pass to server | [optional]
**file** | **UploadedFile****UploadedFile**| file to upload | [optional]
### Return type
[**OpenAPI\Server\Model\ApiResponse**](../Model/ApiResponse.md)
### Authorization
[petstore_auth](../../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
[[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)

View File

@ -0,0 +1,243 @@
# OpenAPI\Server\Api\StoreApiInterface
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**deleteOrder**](StoreApiInterface.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
[**getInventory**](StoreApiInterface.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApiInterface.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
[**placeOrder**](StoreApiInterface.md#placeOrder) | **POST** /store/order | Place an order for a pet
## Service Declaration
```yaml
# src/Acme/MyBundle/Resources/services.yml
services:
# ...
acme.my_bundle.api.store:
class: Acme\MyBundle\Api\StoreApi
tags:
- { name: "open_api_server.api", api: "store" }
# ...
```
## **deleteOrder**
> deleteOrder($orderId)
Delete purchase order by ID
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/StoreApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\StoreApiInterface;
class StoreApi implements StoreApiInterface
{
// ...
/**
* Implementation of StoreApiInterface#deleteOrder
*/
public function deleteOrder($orderId)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **string**| ID of the order that needs to be deleted |
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[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()
Returns pet inventories by status
Returns a map of status codes to quantities
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/StoreApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\StoreApiInterface;
class StoreApi implements StoreApiInterface
{
/**
* Configure API key authorization: api_key
*/
public function setapi_key($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of StoreApiInterface#getInventory
*/
public function getInventory()
{
// Implement the operation ...
}
// ...
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
**int**
### Authorization
[api_key](../../README.md#api_key)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[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)
## **getOrderById**
> OpenAPI\Server\Model\Order getOrderById($orderId)
Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/StoreApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\StoreApiInterface;
class StoreApi implements StoreApiInterface
{
// ...
/**
* Implementation of StoreApiInterface#getOrderById
*/
public function getOrderById($orderId)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**orderId** | **int**| ID of pet that needs to be fetched |
### Return type
[**OpenAPI\Server\Model\Order**](../Model/Order.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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)
## **placeOrder**
> OpenAPI\Server\Model\Order placeOrder($order)
Place an order for a pet
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/StoreApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\StoreApiInterface;
class StoreApi implements StoreApiInterface
{
// ...
/**
* Implementation of StoreApiInterface#placeOrder
*/
public function placeOrder(Order $order)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order** | [**OpenAPI\Server\Model\Order**](../Model/Order.md)| order placed for purchasing the pet |
### Return type
[**OpenAPI\Server\Model\Order**](../Model/Order.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/xml, application/json
[[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)

View File

@ -0,0 +1,497 @@
# OpenAPI\Server\Api\UserApiInterface
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**createUser**](UserApiInterface.md#createUser) | **POST** /user | Create user
[**createUsersWithArrayInput**](UserApiInterface.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
[**createUsersWithListInput**](UserApiInterface.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
[**deleteUser**](UserApiInterface.md#deleteUser) | **DELETE** /user/{username} | Delete user
[**getUserByName**](UserApiInterface.md#getUserByName) | **GET** /user/{username} | Get user by user name
[**loginUser**](UserApiInterface.md#loginUser) | **GET** /user/login | Logs user into the system
[**logoutUser**](UserApiInterface.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
[**updateUser**](UserApiInterface.md#updateUser) | **PUT** /user/{username} | Updated user
## Service Declaration
```yaml
# src/Acme/MyBundle/Resources/services.yml
services:
# ...
acme.my_bundle.api.user:
class: Acme\MyBundle\Api\UserApi
tags:
- { name: "open_api_server.api", api: "user" }
# ...
```
## **createUser**
> createUser($user)
Create user
This can only be done by the logged in user.
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#createUser
*/
public function createUser(User $user)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Created user object |
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
[[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)
## **createUsersWithArrayInput**
> createUsersWithArrayInput($user)
Creates list of users with given input array
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#createUsersWithArrayInput
*/
public function createUsersWithArrayInput(array $user)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
[[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)
## **createUsersWithListInput**
> createUsersWithListInput($user)
Creates list of users with given input array
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#createUsersWithListInput
*/
public function createUsersWithListInput(array $user)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
[[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)
## **deleteUser**
> deleteUser($username)
Delete user
This can only be done by the logged in user.
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#deleteUser
*/
public function deleteUser($username)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **string**| The name that needs to be deleted |
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[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)
## **getUserByName**
> OpenAPI\Server\Model\User getUserByName($username)
Get user by user name
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
// ...
/**
* Implementation of UserApiInterface#getUserByName
*/
public function getUserByName($username)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **string**| The name that needs to be fetched. Use user1 for testing. |
### Return type
[**OpenAPI\Server\Model\User**](../Model/User.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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)
## **loginUser**
> string loginUser($username, $password)
Logs user into the system
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
// ...
/**
* Implementation of UserApiInterface#loginUser
*/
public function loginUser($username, $password)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **string**| The user name for login |
**password** | **string**| The password for login in clear text |
### Return type
**string**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
[[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)
## **logoutUser**
> logoutUser()
Logs out current logged in user session
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#logoutUser
*/
public function logoutUser()
{
// Implement the operation ...
}
// ...
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
[[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)
## **updateUser**
> updateUser($username, $user)
Updated user
This can only be done by the logged in user.
### Example Implementation
```php
<?php
// src/Acme/MyBundle/Api/UserApiInterface.php
namespace Acme\MyBundle\Api;
use OpenAPI\Server\Api\UserApiInterface;
class UserApi implements UserApiInterface
{
/**
* Configure API key authorization: auth_cookie
*/
public function setauth_cookie($apiKey)
{
// Retrieve logged in user from $apiKey ...
}
// ...
/**
* Implementation of UserApiInterface#updateUser
*/
public function updateUser($username, User $user)
{
// Implement the operation ...
}
// ...
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **string**| name that need to be deleted |
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Updated user object |
### Return type
void (empty response body)
### Authorization
[auth_cookie](../../README.md#auth_cookie)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
[[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)

View File

@ -0,0 +1,12 @@
# ApiResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | | [optional]
**type** | **string** | | [optional]
**message** | **string** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional]
**name** | **string** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# InlineObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **string** | Updated name of the pet | [optional]
**status** | **string** | Updated status of the pet | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# InlineObject1
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additionalMetadata** | **string** | Additional data to pass to server | [optional]
**file** | [**UploadedFile**](UploadedFile.md) | file to upload | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,15 @@
# Order
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional]
**petId** | **int** | | [optional]
**quantity** | **int** | | [optional]
**shipDate** | [**\DateTime**](\DateTime.md) | | [optional]
**status** | **string** | Order Status | [optional]
**complete** | **bool** | | [optional] [default to false]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,15 @@
# Pet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional]
**category** | [**OpenAPI\Server\Model\Category**](Category.md) | | [optional]
**name** | **string** | |
**photoUrls** | **string** | |
**tags** | [**OpenAPI\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)

View File

@ -0,0 +1,11 @@
# Tag
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional]
**name** | **string** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,17 @@
# User
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | | [optional]
**username** | **string** | | [optional]
**firstName** | **string** | | [optional]
**lastName** | **string** | | [optional]
**email** | **string** | | [optional]
**password** | **string** | | [optional]
**phone** | **string** | | [optional]
**userStatus** | **int** | User Status | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,115 @@
<?php
namespace OpenAPI\Server\Service;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\XmlDeserializationVisitor;
class JmsSerializer implements SerializerInterface
{
protected $serializer;
public function __construct()
{
$naming_strategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
$this->serializer = SerializerBuilder::create()
->setDeserializationVisitor('json', new StrictJsonDeserializationVisitor($naming_strategy))
->setDeserializationVisitor('xml', new XmlDeserializationVisitor($naming_strategy))
->build();
}
public function serialize($data, $format)
{
return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format));
}
public function deserialize($data, $type, $format)
{
if ($format == 'string') {
return $this->deserializeString($data, $type);
}
// If we end up here, let JMS serializer handle the deserialization
return $this->serializer->deserialize($data, $type, $this->convertFormat($format));
}
private function convertFormat($format)
{
switch ($format) {
case 'application/json':
return 'json';
case 'application/xml':
return 'xml';
}
return null;
}
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':
if (is_int($data)) {
return $data;
}
if (is_numeric($data)) {
return $data + 0;
}
break;
case 'string':
break;
case 'boolean':
case 'bool':
if (strtolower($data) === 'true') {
return true;
}
if (strtolower($data) === 'false') {
return false;
}
break;
}
// 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;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace OpenAPI\Server\Service;
interface SerializerInterface
{
/**
* Serializes the given data to the specified output format.
*
* @param object|array|scalar $data
* @param string $format
*
* @return string
*/
public function serialize($data, $format);
/**
* Deserializes the given data to the specified type.
*
* @param string $data
* @param string $type
* @param string $format
*
* @return object|array|scalar
*/
public function deserialize($data, $type, $format);
}

View File

@ -0,0 +1,72 @@
<?php
/*
* Copyright 2017 Dmitriy Simushev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace OpenAPI\Server\Service;
use JMS\Serializer\Context;
use JMS\Serializer\JsonDeserializationVisitor;
class StrictJsonDeserializationVisitor extends JsonDeserializationVisitor
{
/**
* {@inheritdoc}
*/
public function visitString($data, array $type, Context $context)
{
if (!is_string($data)) {
throw TypeMismatchException::fromValue('string', $data, $context);
}
return parent::visitString($data, $type, $context);
}
/**
* {@inheritdoc}
*/
public function visitBoolean($data, array $type, Context $context)
{
if (!is_bool($data)) {
throw TypeMismatchException::fromValue('boolean', $data, $context);
}
return parent::visitBoolean($data, $type, $context);
}
/**
* {@inheritdoc}
*/
public function visitInteger($data, array $type, Context $context)
{
if (!is_int($data)) {
throw TypeMismatchException::fromValue('integer', $data, $context);
}
return parent::visitInteger($data, $type, $context);
}
/**
* {@inheritdoc}
*/
public function visitDouble($data, array $type, Context $context)
{
if (!is_float($data) && !is_integer($data)) {
throw TypeMismatchException::fromValue('double', $data, $context);
}
return parent::visitDouble($data, $type, $context);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace OpenAPI\Server\Service;
use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidatorInterface;
class SymfonyValidator implements ValidatorInterface
{
protected $validator;
public function __construct(SymfonyValidatorInterface $validator)
{
$this->validator = $validator;
}
public function validate($value, $constraints = null, $groups = null)
{
return $this->validator->validate($value, $constraints, $groups);
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
* Copyright 2017 Dmitriy Simushev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace OpenAPI\Server\Service;
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\Exception\RuntimeException;
class TypeMismatchException extends RuntimeException
{
/**
* A handy method for building exception instance.
*
* @param string $expected_type
* @param mixed $actual_value
* @param DeserializationContext|null $context
* @return TypeMismatchException
*/
public static function fromValue(
$expected_type,
$actual_value,
DeserializationContext $context = null
) {
if (null !== $context && count($context->getCurrentPath()) > 0) {
$property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath()));
} else {
$property = '';
}
return new static(sprintf(
'Expected %s%s, but got %s: %s',
$property,
$expected_type,
gettype($actual_value),
json_encode($actual_value)
));
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace OpenAPI\Server\Service;
interface ValidatorInterface
{
/**
* Validates a value against a constraint or a list of constraints.
*
* If no constraint is passed, the constraint
* {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
*
* @param mixed $value The value to validate
* @param Constraint|Constraint[] $constraints The constraint(s) to validate
* against
* @param array|null $groups The validation groups to
* validate. If none is given,
* "Default" is assumed
*
* @return ConstraintViolationListInterface A list of constraint violations
* If the list is empty, validation
* succeeded
*/
public function validate($value, $constraints = null, $groups = null);
}

View File

@ -0,0 +1,217 @@
<?php
/**
* PetApiInterfaceTest
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the endpoint.
*/
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\Test\WebTestCase;
/**
* PetApiInterfaceTest Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class PetApiInterfaceTest extends WebTestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test case for addPet
*
* Add a new pet to the store.
*
*/
public function testAddPet()
{
$client = static::createClient();
$path = '/pet';
$crawler = $client->request('POST', $path);
}
/**
* Test case for deletePet
*
* Deletes a pet.
*
*/
public function testDeletePet()
{
$client = static::createClient();
$path = '/pet/{petId}';
$pattern = '{petId}';
$data = $this->genTestData('\d+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
}
/**
* Test case for findPetsByStatus
*
* Finds Pets by status.
*
*/
public function testFindPetsByStatus()
{
$client = static::createClient();
$path = '/pet/findByStatus';
$crawler = $client->request('GET', $path);
}
/**
* Test case for findPetsByTags
*
* Finds Pets by tags.
*
*/
public function testFindPetsByTags()
{
$client = static::createClient();
$path = '/pet/findByTags';
$crawler = $client->request('GET', $path);
}
/**
* Test case for getPetById
*
* Find pet by ID.
*
*/
public function testGetPetById()
{
$client = static::createClient();
$path = '/pet/{petId}';
$pattern = '{petId}';
$data = $this->genTestData('\d+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
}
/**
* Test case for updatePet
*
* Update an existing pet.
*
*/
public function testUpdatePet()
{
$client = static::createClient();
$path = '/pet';
$crawler = $client->request('PUT', $path);
}
/**
* Test case for updatePetWithForm
*
* Updates a pet in the store with form data.
*
*/
public function testUpdatePetWithForm()
{
$client = static::createClient();
$path = '/pet/{petId}';
$pattern = '{petId}';
$data = $this->genTestData('\d+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path);
}
/**
* Test case for uploadFile
*
* uploads an image.
*
*/
public function testUploadFile()
{
$client = static::createClient();
$path = '/pet/{petId}/uploadImage';
$pattern = '{petId}';
$data = $this->genTestData('\d+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path);
}
protected function genTestData($regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);
}
}

View File

@ -0,0 +1,151 @@
<?php
/**
* StoreApiInterfaceTest
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the endpoint.
*/
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\Test\WebTestCase;
/**
* StoreApiInterfaceTest Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class StoreApiInterfaceTest extends WebTestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test case for deleteOrder
*
* Delete purchase order by ID.
*
*/
public function testDeleteOrder()
{
$client = static::createClient();
$path = '/store/order/{orderId}';
$pattern = '{orderId}';
$data = $this->genTestData('[a-z0-9]+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
}
/**
* Test case for getInventory
*
* Returns pet inventories by status.
*
*/
public function testGetInventory()
{
$client = static::createClient();
$path = '/store/inventory';
$crawler = $client->request('GET', $path);
}
/**
* Test case for getOrderById
*
* Find purchase order by ID.
*
*/
public function testGetOrderById()
{
$client = static::createClient();
$path = '/store/order/{orderId}';
$pattern = '{orderId}';
$data = $this->genTestData('\d+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
}
/**
* Test case for placeOrder
*
* Place an order for a pet.
*
*/
public function testPlaceOrder()
{
$client = static::createClient();
$path = '/store/order';
$crawler = $client->request('POST', $path);
}
protected function genTestData($regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);
}
}

View File

@ -0,0 +1,214 @@
<?php
/**
* UserApiInterfaceTest
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the endpoint.
*/
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\Test\WebTestCase;
/**
* UserApiInterfaceTest Class Doc Comment
*
* @category Class
* @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class UserApiInterfaceTest extends WebTestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test case for createUser
*
* Create user.
*
*/
public function testCreateUser()
{
$client = static::createClient();
$path = '/user';
$crawler = $client->request('POST', $path);
}
/**
* Test case for createUsersWithArrayInput
*
* Creates list of users with given input array.
*
*/
public function testCreateUsersWithArrayInput()
{
$client = static::createClient();
$path = '/user/createWithArray';
$crawler = $client->request('POST', $path);
}
/**
* Test case for createUsersWithListInput
*
* Creates list of users with given input array.
*
*/
public function testCreateUsersWithListInput()
{
$client = static::createClient();
$path = '/user/createWithList';
$crawler = $client->request('POST', $path);
}
/**
* Test case for deleteUser
*
* Delete user.
*
*/
public function testDeleteUser()
{
$client = static::createClient();
$path = '/user/{username}';
$pattern = '{username}';
$data = $this->genTestData('[a-z0-9]+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path);
}
/**
* Test case for getUserByName
*
* Get user by user name.
*
*/
public function testGetUserByName()
{
$client = static::createClient();
$path = '/user/{username}';
$pattern = '{username}';
$data = $this->genTestData('[a-z0-9]+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path);
}
/**
* Test case for loginUser
*
* Logs user into the system.
*
*/
public function testLoginUser()
{
$client = static::createClient();
$path = '/user/login';
$crawler = $client->request('GET', $path);
}
/**
* Test case for logoutUser
*
* Logs out current logged in user session.
*
*/
public function testLogoutUser()
{
$client = static::createClient();
$path = '/user/logout';
$crawler = $client->request('GET', $path);
}
/**
* Test case for updateUser
*
* Updated user.
*
*/
public function testUpdateUser()
{
$client = static::createClient();
$path = '/user/{username}';
$pattern = '{username}';
$data = $this->genTestData('[a-z0-9]+');
$path = str_replace($pattern, $data, $path);
$crawler = $client->request('PUT', $path);
}
protected function genTestData($regexp)
{
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast);
}
}

View File

@ -0,0 +1,21 @@
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle()
);
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/test_config.yml');
}
}

View File

@ -0,0 +1,101 @@
<?php
/**
* ApiResponseTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* ApiResponseTest Class Doc Comment
*
* @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
*/
class ApiResponseTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "ApiResponse"
*/
public function testApiResponse()
{
$testApiResponse = new ApiResponse();
}
/**
* Test attribute "code"
*/
public function testPropertyCode()
{
}
/**
* Test attribute "type"
*/
public function testPropertyType()
{
}
/**
* Test attribute "message"
*/
public function testPropertyMessage()
{
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* CategoryTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* CategoryTest Class Doc Comment
*
* @category Class */
// * @description A category for a pet
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class CategoryTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "Category"
*/
public function testCategory()
{
$testCategory = new Category();
}
/**
* Test attribute "id"
*/
public function testPropertyId()
{
}
/**
* Test attribute "name"
*/
public function testPropertyName()
{
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* InlineObject1Test
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* InlineObject1Test Class Doc Comment
*
* @category Class */
// * @description InlineObject1
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class InlineObject1Test extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "InlineObject1"
*/
public function testInlineObject1()
{
$testInlineObject1 = new InlineObject1();
}
/**
* Test attribute "additionalMetadata"
*/
public function testPropertyAdditionalMetadata()
{
}
/**
* Test attribute "file"
*/
public function testPropertyFile()
{
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* InlineObjectTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* InlineObjectTest Class Doc Comment
*
* @category Class */
// * @description InlineObject
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class InlineObjectTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "InlineObject"
*/
public function testInlineObject()
{
$testInlineObject = new InlineObject();
}
/**
* Test attribute "name"
*/
public function testPropertyName()
{
}
/**
* Test attribute "status"
*/
public function testPropertyStatus()
{
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* OrderTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* OrderTest Class Doc Comment
*
* @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
*/
class OrderTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "Order"
*/
public function testOrder()
{
$testOrder = new Order();
}
/**
* Test attribute "id"
*/
public function testPropertyId()
{
}
/**
* Test attribute "petId"
*/
public function testPropertyPetId()
{
}
/**
* Test attribute "quantity"
*/
public function testPropertyQuantity()
{
}
/**
* Test attribute "shipDate"
*/
public function testPropertyShipDate()
{
}
/**
* Test attribute "status"
*/
public function testPropertyStatus()
{
}
/**
* Test attribute "complete"
*/
public function testPropertyComplete()
{
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* PetTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* PetTest Class Doc Comment
*
* @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
*/
class PetTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "Pet"
*/
public function testPet()
{
$testPet = new Pet();
}
/**
* Test attribute "id"
*/
public function testPropertyId()
{
}
/**
* Test attribute "category"
*/
public function testPropertyCategory()
{
}
/**
* Test attribute "name"
*/
public function testPropertyName()
{
}
/**
* Test attribute "photoUrls"
*/
public function testPropertyPhotoUrls()
{
}
/**
* Test attribute "tags"
*/
public function testPropertyTags()
{
}
/**
* Test attribute "status"
*/
public function testPropertyStatus()
{
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* TagTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* TagTest Class Doc Comment
*
* @category Class */
// * @description A tag for a pet
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class TagTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "Tag"
*/
public function testTag()
{
$testTag = new Tag();
}
/**
* Test attribute "id"
*/
public function testPropertyId()
{
}
/**
* Test attribute "name"
*/
public function testPropertyName()
{
}
}

View File

@ -0,0 +1,136 @@
<?php
/**
* UserTest
*
* PHP version 5
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
/**
* UserTest Class Doc Comment
*
* @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
*/
class UserTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "User"
*/
public function testUser()
{
$testUser = new User();
}
/**
* Test attribute "id"
*/
public function testPropertyId()
{
}
/**
* Test attribute "username"
*/
public function testPropertyUsername()
{
}
/**
* Test attribute "firstName"
*/
public function testPropertyFirstName()
{
}
/**
* Test attribute "lastName"
*/
public function testPropertyLastName()
{
}
/**
* Test attribute "email"
*/
public function testPropertyEmail()
{
}
/**
* Test attribute "password"
*/
public function testPropertyPassword()
{
}
/**
* Test attribute "phone"
*/
public function testPropertyPhone()
{
}
/**
* Test attribute "userStatus"
*/
public function testPropertyUserStatus()
{
}
}

View File

@ -0,0 +1,8 @@
imports:
- { resource: "../Resources/config/services.yml" }
framework:
secret: "testsecret"
test: ~
router:
resource: "%kernel.root_dir%/../Resources/config/routing.yml"

View File

@ -0,0 +1,54 @@
<?php
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* An example of a project-specific implementation.
*
* After registering this autoload function with SPL, the following line
* would cause the function to attempt to load the \OpenAPI\Server\Baz\Qux class
* from /path/to/project/./Baz/Qux.php:
*
* new \OpenAPI\Server\Baz\Qux;
*
* @param string $class The fully-qualified class name.
*
* @return void
*/
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'OpenAPI\\Server\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/./';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

View File

@ -0,0 +1,38 @@
{
"name": "GIT_USER_ID/GIT_REPO_ID",
"description": "",
"keywords": [
"openapi",
"php",
"sdk",
"api"
],
"homepage": "https://github.com/openapitools/openapi-generator",
"license": "unlicense",
"authors": [
{
"name": "openapi-generator contributors",
"homepage": "https://github.com/openapitools/openapi-generator"
}
],
"require": {
"php": ">=5.4",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"symfony/validator": "*",
"jms/serializer-bundle": "^2.0",
"symfony/framework-bundle": "^3.3|^4.1"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~1.0",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~1.12",
"symfony/browser-kit": "*",
"hoa/regex": "~1.0"
},
"autoload": {
"psr-4": { "OpenAPI\\Server\\" : "./" }
}
}

View File

@ -0,0 +1,52 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
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"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite>
<directory>./Tests/Api</directory>
<directory>./Tests/Model</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">././Api</directory>
<directory suffix=".php">././Model</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_DIR" value="Tests/" />
</php>
</phpunit>

View File

@ -0,0 +1,57 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.penneo</groupId>
<artifactId>PhpSymfonyPetstoreServerTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>PHP Symfony Petstore Server</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>bundle-install</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>composer</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>bundle-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>vendor/bin/phpunit</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>