mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-02 21:50:55 +00:00
switch to oas3 spec for php-symfony samples (#9248)
This commit is contained in:
parent
1b63822501
commit
c285f393b0
@ -1,4 +1,4 @@
|
||||
generatorName: php-symfony
|
||||
outputDir: samples/server/petstore/php-symfony/SymfonyBundle-php
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/php-symfony
|
||||
|
@ -52,6 +52,15 @@ interface PetApiInterface
|
||||
*/
|
||||
public function setpetstore_auth($value);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@ -66,14 +75,14 @@ interface PetApiInterface
|
||||
*
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* @param OpenAPI\Server\Model\Pet $body Pet object that needs to be added to the store (required)
|
||||
* @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
|
||||
* @return OpenAPI\Server\Model\Pet
|
||||
*
|
||||
*/
|
||||
public function addPet(Pet $body, &$responseCode, array &$responseHeaders);
|
||||
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders);
|
||||
|
||||
/**
|
||||
* Operation deletePet
|
||||
@ -137,14 +146,14 @@ interface PetApiInterface
|
||||
*
|
||||
* Update an existing pet
|
||||
*
|
||||
* @param OpenAPI\Server\Model\Pet $body Pet object that needs to be added to the store (required)
|
||||
* @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
|
||||
* @return OpenAPI\Server\Model\Pet
|
||||
*
|
||||
*/
|
||||
public function updatePet(Pet $body, &$responseCode, array &$responseHeaders);
|
||||
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders);
|
||||
|
||||
/**
|
||||
* Operation updatePetWithForm
|
||||
|
@ -97,12 +97,12 @@ interface StoreApiInterface
|
||||
*
|
||||
* Place an order for a pet
|
||||
*
|
||||
* @param OpenAPI\Server\Model\Order $body order placed for purchasing the pet (required)
|
||||
* @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 $body, &$responseCode, array &$responseHeaders);
|
||||
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders);
|
||||
}
|
||||
|
@ -42,47 +42,56 @@ use OpenAPI\Server\Model\User;
|
||||
interface UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Sets authentication method api_key
|
||||
*
|
||||
* @param string $value Value of the api_key authentication method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setapi_key($value);
|
||||
|
||||
/**
|
||||
* Operation createUser
|
||||
*
|
||||
* Create user
|
||||
*
|
||||
* @param OpenAPI\Server\Model\User $body Created user object (required)
|
||||
* @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 $body, &$responseCode, array &$responseHeaders);
|
||||
public function createUser(User $user, &$responseCode, array &$responseHeaders);
|
||||
|
||||
/**
|
||||
* Operation createUsersWithArrayInput
|
||||
*
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param OpenAPI\Server\Model\User[] $body List of user object (required)
|
||||
* @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 $body, &$responseCode, array &$responseHeaders);
|
||||
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders);
|
||||
|
||||
/**
|
||||
* Operation createUsersWithListInput
|
||||
*
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param OpenAPI\Server\Model\User[] $body List of user object (required)
|
||||
* @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 $body, &$responseCode, array &$responseHeaders);
|
||||
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders);
|
||||
|
||||
/**
|
||||
* Operation deleteUser
|
||||
@ -146,12 +155,12 @@ interface UserApiInterface
|
||||
* Updated user
|
||||
*
|
||||
* @param string $username name that need to be deleted (required)
|
||||
* @param OpenAPI\Server\Model\User $body Updated user object (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 $body, &$responseCode, array &$responseHeaders);
|
||||
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders);
|
||||
}
|
||||
|
@ -67,20 +67,29 @@ class PetController extends Controller
|
||||
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
|
||||
// Authentication 'petstore_auth' required
|
||||
// Oauth required
|
||||
$securitypetstore_auth = $request->headers->get('authorization');
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
$body = $request->getContent();
|
||||
$pet = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'OpenAPI\Server\Model\Pet', $inputFormat);
|
||||
$pet = $this->deserialize($pet, 'OpenAPI\Server\Model\Pet', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -90,7 +99,7 @@ class PetController extends Controller
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet");
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($pet, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -103,26 +112,30 @@ class PetController extends Controller
|
||||
$handler->setpetstore_auth($securitypetstore_auth);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseCode = 200;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->addPet($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->addPet($pet, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = '';
|
||||
|
||||
// Find a more specific message, if available
|
||||
switch ($responseCode) {
|
||||
case 200:
|
||||
$message = 'successful operation';
|
||||
break;
|
||||
case 405:
|
||||
$message = 'Invalid input';
|
||||
break;
|
||||
}
|
||||
|
||||
return new Response(
|
||||
'',
|
||||
$result !== null ?$this->serialize($result, $responseFormat):'',
|
||||
$responseCode,
|
||||
array_merge(
|
||||
$responseHeaders,
|
||||
[
|
||||
'Content-Type' => $responseFormat,
|
||||
'X-OpenAPI-Message' => $message
|
||||
]
|
||||
)
|
||||
@ -498,20 +511,29 @@ class PetController extends Controller
|
||||
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
|
||||
// Authentication 'petstore_auth' required
|
||||
// Oauth required
|
||||
$securitypetstore_auth = $request->headers->get('authorization');
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
$body = $request->getContent();
|
||||
$pet = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'OpenAPI\Server\Model\Pet', $inputFormat);
|
||||
$pet = $this->deserialize($pet, 'OpenAPI\Server\Model\Pet', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -521,7 +543,7 @@ class PetController extends Controller
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet");
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($pet, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -534,15 +556,18 @@ class PetController extends Controller
|
||||
$handler->setpetstore_auth($securitypetstore_auth);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseCode = 200;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->updatePet($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->updatePet($pet, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = '';
|
||||
|
||||
// Find a more specific message, if available
|
||||
switch ($responseCode) {
|
||||
case 200:
|
||||
$message = 'successful operation';
|
||||
break;
|
||||
case 400:
|
||||
$message = 'Invalid ID supplied';
|
||||
break;
|
||||
@ -555,11 +580,12 @@ class PetController extends Controller
|
||||
}
|
||||
|
||||
return new Response(
|
||||
'',
|
||||
$result !== null ?$this->serialize($result, $responseFormat):'',
|
||||
$responseCode,
|
||||
array_merge(
|
||||
$responseHeaders,
|
||||
[
|
||||
'Content-Type' => $responseFormat,
|
||||
'X-OpenAPI-Message' => $message
|
||||
]
|
||||
)
|
||||
|
@ -283,7 +283,7 @@ class StoreController extends Controller
|
||||
public function placeOrderAction(Request $request)
|
||||
{
|
||||
// Make sure that the client is providing something that we can consume
|
||||
$consumes = [];
|
||||
$consumes = ['application/json'];
|
||||
if (!static::isContentTypeAllowed($request, $consumes)) {
|
||||
// We can't consume the content that the client is sending us
|
||||
return new Response('', 415);
|
||||
@ -301,14 +301,14 @@ class StoreController extends Controller
|
||||
// Handle authentication
|
||||
|
||||
// Read out all input parameter values into variables
|
||||
$body = $request->getContent();
|
||||
$order = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'OpenAPI\Server\Model\Order', $inputFormat);
|
||||
$order = $this->deserialize($order, 'OpenAPI\Server\Model\Order', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -318,7 +318,7 @@ class StoreController extends Controller
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\Type("OpenAPI\Server\Model\Order");
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($order, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -331,7 +331,7 @@ class StoreController extends Controller
|
||||
// Make the call to the business logic
|
||||
$responseCode = 200;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->placeOrder($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->placeOrder($order, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = '';
|
||||
|
@ -60,23 +60,26 @@ class UserController extends Controller
|
||||
public function createUserAction(Request $request)
|
||||
{
|
||||
// Make sure that the client is providing something that we can consume
|
||||
$consumes = [];
|
||||
$consumes = ['application/json'];
|
||||
if (!static::isContentTypeAllowed($request, $consumes)) {
|
||||
// We can't consume the content that the client is sending us
|
||||
return new Response('', 415);
|
||||
}
|
||||
|
||||
// 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
|
||||
$body = $request->getContent();
|
||||
$user = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'OpenAPI\Server\Model\User', $inputFormat);
|
||||
$user = $this->deserialize($user, 'OpenAPI\Server\Model\User', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -86,7 +89,7 @@ class UserController extends Controller
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\Type("OpenAPI\Server\Model\User");
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($user, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -95,11 +98,13 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->createUser($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->createUser($user, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = 'successful operation';
|
||||
@ -137,23 +142,26 @@ class UserController extends Controller
|
||||
public function createUsersWithArrayInputAction(Request $request)
|
||||
{
|
||||
// Make sure that the client is providing something that we can consume
|
||||
$consumes = [];
|
||||
$consumes = ['application/json'];
|
||||
if (!static::isContentTypeAllowed($request, $consumes)) {
|
||||
// We can't consume the content that the client is sending us
|
||||
return new Response('', 415);
|
||||
}
|
||||
|
||||
// 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
|
||||
$body = $request->getContent();
|
||||
$user = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'array<OpenAPI\Server\Model\User>', $inputFormat);
|
||||
$user = $this->deserialize($user, 'array<OpenAPI\Server\Model\User>', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -165,7 +173,7 @@ class UserController extends Controller
|
||||
new Assert\Type("OpenAPI\Server\Model\User"),
|
||||
]);
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($user, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -174,11 +182,13 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->createUsersWithArrayInput($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = 'successful operation';
|
||||
@ -216,23 +226,26 @@ class UserController extends Controller
|
||||
public function createUsersWithListInputAction(Request $request)
|
||||
{
|
||||
// Make sure that the client is providing something that we can consume
|
||||
$consumes = [];
|
||||
$consumes = ['application/json'];
|
||||
if (!static::isContentTypeAllowed($request, $consumes)) {
|
||||
// We can't consume the content that the client is sending us
|
||||
return new Response('', 415);
|
||||
}
|
||||
|
||||
// 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
|
||||
$body = $request->getContent();
|
||||
$user = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
// Deserialize the input values that needs it
|
||||
try {
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'array<OpenAPI\Server\Model\User>', $inputFormat);
|
||||
$user = $this->deserialize($user, 'array<OpenAPI\Server\Model\User>', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -244,7 +257,7 @@ class UserController extends Controller
|
||||
new Assert\Type("OpenAPI\Server\Model\User"),
|
||||
]);
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($user, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -253,11 +266,13 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->createUsersWithListInput($body, $responseCode, $responseHeaders);
|
||||
$result = $handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = 'successful operation';
|
||||
@ -295,6 +310,9 @@ class UserController extends Controller
|
||||
public function deleteUserAction(Request $request, $username)
|
||||
{
|
||||
// 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
|
||||
|
||||
@ -320,6 +338,8 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
@ -476,6 +496,7 @@ class UserController extends Controller
|
||||
$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;
|
||||
@ -538,6 +559,9 @@ class UserController extends Controller
|
||||
public function logoutUserAction(Request $request)
|
||||
{
|
||||
// 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
|
||||
|
||||
@ -549,6 +573,8 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
@ -591,16 +617,19 @@ class UserController extends Controller
|
||||
public function updateUserAction(Request $request, $username)
|
||||
{
|
||||
// Make sure that the client is providing something that we can consume
|
||||
$consumes = [];
|
||||
$consumes = ['application/json'];
|
||||
if (!static::isContentTypeAllowed($request, $consumes)) {
|
||||
// We can't consume the content that the client is sending us
|
||||
return new Response('', 415);
|
||||
}
|
||||
|
||||
// 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
|
||||
$body = $request->getContent();
|
||||
$user = $request->getContent();
|
||||
|
||||
// Use the default value if no value was provided
|
||||
|
||||
@ -608,7 +637,7 @@ class UserController extends Controller
|
||||
try {
|
||||
$username = $this->deserialize($username, 'string', 'string');
|
||||
$inputFormat = $request->getMimeType($request->getContentType());
|
||||
$body = $this->deserialize($body, 'OpenAPI\Server\Model\User', $inputFormat);
|
||||
$user = $this->deserialize($user, 'OpenAPI\Server\Model\User', $inputFormat);
|
||||
} catch (SerializerRuntimeException $exception) {
|
||||
return $this->createBadRequestResponse($exception->getMessage());
|
||||
}
|
||||
@ -625,7 +654,7 @@ class UserController extends Controller
|
||||
$asserts[] = new Assert\NotNull();
|
||||
$asserts[] = new Assert\Type("OpenAPI\Server\Model\User");
|
||||
$asserts[] = new Assert\Valid();
|
||||
$response = $this->validate($body, $asserts);
|
||||
$response = $this->validate($user, $asserts);
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
@ -634,11 +663,13 @@ class UserController extends Controller
|
||||
try {
|
||||
$handler = $this->getApiHandler();
|
||||
|
||||
// Set authentication method 'api_key'
|
||||
$handler->setapi_key($securityapi_key);
|
||||
|
||||
// Make the call to the business logic
|
||||
$responseCode = 204;
|
||||
$responseHeaders = [];
|
||||
$result = $handler->updateUser($username, $body, $responseCode, $responseHeaders);
|
||||
$result = $handler->updateUser($username, $user, $responseCode, $responseHeaders);
|
||||
|
||||
// Find default response message
|
||||
$message = '';
|
||||
|
@ -56,6 +56,7 @@ class Category
|
||||
* @SerializedName("name")
|
||||
* @Assert\Type("string")
|
||||
* @Type("string")
|
||||
* @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
|
@ -93,7 +93,7 @@ class PetApi implements PetApiInterface // An interface is autogenerated
|
||||
/**
|
||||
* Implementation of PetApiInterface#addPet
|
||||
*/
|
||||
public function addPet(Pet $body)
|
||||
public function addPet(Pet $pet)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ services:
|
||||
```
|
||||
|
||||
## **addPet**
|
||||
> addPet($body)
|
||||
> OpenAPI\Server\Model\Pet addPet($pet)
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
@ -56,7 +56,7 @@ class PetApi implements PetApiInterface
|
||||
/**
|
||||
* Implementation of PetApiInterface#addPet
|
||||
*/
|
||||
public function addPet(Pet $body)
|
||||
public function addPet(Pet $pet)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -69,11 +69,11 @@ class PetApi implements PetApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
**pet** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
[**OpenAPI\Server\Model\Pet**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@ -82,7 +82,7 @@ void (empty response body)
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: 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)
|
||||
|
||||
@ -334,7 +334,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **updatePet**
|
||||
> updatePet($body)
|
||||
> OpenAPI\Server\Model\Pet updatePet($pet)
|
||||
|
||||
Update an existing pet
|
||||
|
||||
@ -363,7 +363,7 @@ class PetApi implements PetApiInterface
|
||||
/**
|
||||
* Implementation of PetApiInterface#updatePet
|
||||
*/
|
||||
public function updatePet(Pet $body)
|
||||
public function updatePet(Pet $pet)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -376,11 +376,11 @@ class PetApi implements PetApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
**pet** | [**OpenAPI\Server\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
[**OpenAPI\Server\Model\Pet**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@ -389,7 +389,7 @@ void (empty response body)
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: 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)
|
||||
|
||||
|
@ -190,7 +190,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **placeOrder**
|
||||
> OpenAPI\Server\Model\Order placeOrder($body)
|
||||
> OpenAPI\Server\Model\Order placeOrder($order)
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
@ -211,7 +211,7 @@ class StoreApi implements StoreApiInterface
|
||||
/**
|
||||
* Implementation of StoreApiInterface#placeOrder
|
||||
*/
|
||||
public function placeOrder(Order $body)
|
||||
public function placeOrder(Order $order)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -224,7 +224,7 @@ class StoreApi implements StoreApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\Order**](../Model/Order.md)| order placed for purchasing the pet |
|
||||
**order** | [**OpenAPI\Server\Model\Order**](../Model/Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -236,7 +236,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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)
|
||||
|
@ -27,7 +27,7 @@ services:
|
||||
```
|
||||
|
||||
## **createUser**
|
||||
> createUser($body)
|
||||
> createUser($user)
|
||||
|
||||
Create user
|
||||
|
||||
@ -45,12 +45,20 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
* Implementation of UserApiInterface#createUser
|
||||
*/
|
||||
public function createUser(User $body)
|
||||
public function createUser(User $user)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -63,7 +71,7 @@ class UserApi implements UserApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Created user object |
|
||||
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -71,17 +79,17 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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($body)
|
||||
> createUsersWithArrayInput($user)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
@ -97,12 +105,20 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
* Implementation of UserApiInterface#createUsersWithArrayInput
|
||||
*/
|
||||
public function createUsersWithArrayInput(array $body)
|
||||
public function createUsersWithArrayInput(array $user)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -115,7 +131,7 @@ class UserApi implements UserApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -123,17 +139,17 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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($body)
|
||||
> createUsersWithListInput($user)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
@ -149,12 +165,20 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
* Implementation of UserApiInterface#createUsersWithListInput
|
||||
*/
|
||||
public function createUsersWithListInput(array $body)
|
||||
public function createUsersWithListInput(array $user)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -167,7 +191,7 @@ class UserApi implements UserApiInterface
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -175,11 +199,11 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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)
|
||||
@ -203,6 +227,14 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
@ -229,7 +261,7 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
@ -360,6 +392,14 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
@ -383,7 +423,7 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
@ -393,7 +433,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md)
|
||||
|
||||
## **updateUser**
|
||||
> updateUser($username, $body)
|
||||
> updateUser($username, $user)
|
||||
|
||||
Updated user
|
||||
|
||||
@ -411,12 +451,20 @@ use OpenAPI\Server\Api\UserApiInterface;
|
||||
class UserApi implements UserApiInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Configure API key authorization: api_key
|
||||
*/
|
||||
public function setapi_key($apiKey)
|
||||
{
|
||||
// Retrieve logged in user from $apiKey ...
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
/**
|
||||
* Implementation of UserApiInterface#updateUser
|
||||
*/
|
||||
public function updateUser($username, User $body)
|
||||
public function updateUser($username, User $user)
|
||||
{
|
||||
// Implement the operation ...
|
||||
}
|
||||
@ -430,7 +478,7 @@ class UserApi implements UserApiInterface
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **string**| name that need to be deleted |
|
||||
**body** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Updated user object |
|
||||
**user** | [**OpenAPI\Server\Model\User**](../Model/User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@ -438,11 +486,11 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user