Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/configs/php-symfony-SymfonyBundle-php.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -66,14 +75,14 @@ public function setapi_key($value);
*
* 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
Expand Down Expand Up @@ -137,14 +146,14 @@ public function getPetById($petId, &$responseCode, array &$responseHeaders);
*
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ public function getOrderById($orderId, &$responseCode, array &$responseHeaders);
*
* 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,56 @@
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
Expand Down Expand Up @@ -146,12 +155,12 @@ public function logoutUser(&$responseCode, array &$responseHeaders);
* 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,29 @@ public function addPetAction(Request $request)
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());
}
Expand All @@ -90,7 +99,7 @@ public function addPetAction(Request $request)
$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;
}
Expand All @@ -103,26 +112,30 @@ public function addPetAction(Request $request)
$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
]
)
Expand Down Expand Up @@ -498,20 +511,29 @@ public function updatePetAction(Request $request)
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());
}
Expand All @@ -521,7 +543,7 @@ public function updatePetAction(Request $request)
$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;
}
Expand All @@ -534,15 +556,18 @@ public function updatePetAction(Request $request)
$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;
Expand All @@ -555,11 +580,12 @@ public function updatePetAction(Request $request)
}

return new Response(
'',
$result !== null ?$this->serialize($result, $responseFormat):'',
$responseCode,
array_merge(
$responseHeaders,
[
'Content-Type' => $responseFormat,
'X-OpenAPI-Message' => $message
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function getOrderByIdAction(Request $request, $orderId)
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);
Expand All @@ -301,14 +301,14 @@ public function placeOrderAction(Request $request)
// 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());
}
Expand All @@ -318,7 +318,7 @@ public function placeOrderAction(Request $request)
$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;
}
Expand All @@ -331,7 +331,7 @@ public function placeOrderAction(Request $request)
// 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 = '';
Expand Down
Loading