diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index a434699f90a..e0b94e6b232 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -39,6 +39,12 @@ class {{classname}} { {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { + {{#allParams}}{{#required}} + // verify the required parameter '{{paramName}}' is set + if (${{paramName}} === null) { + throw new \Exception("Missing the required parameter ${{paramName}} when calling {{nickname}}"); + } + {{/required}}{{/allParams}} // parse inputs $resourcePath = "{{path}}"; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php index 80d9c040d1e..fc8331da4bd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php @@ -38,6 +38,7 @@ class PetApi { * @return void */ public function updatePet($body) { + // parse inputs $resourcePath = "/pet"; @@ -91,6 +92,7 @@ class PetApi { * @return void */ public function addPet($body) { + // parse inputs $resourcePath = "/pet"; @@ -144,6 +146,7 @@ class PetApi { * @return array[Pet] */ public function findPetsByStatus($status) { + // parse inputs $resourcePath = "/pet/findByStatus"; @@ -202,6 +205,7 @@ class PetApi { * @return array[Pet] */ public function findPetsByTags($tags) { + // parse inputs $resourcePath = "/pet/findByTags"; @@ -260,6 +264,12 @@ class PetApi { * @return Pet */ public function getPetById($pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \Exception("Missing the required parameter $pet_id when calling getPetById"); + } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -321,6 +331,12 @@ class PetApi { * @return void */ public function updatePetWithForm($pet_id, $name, $status) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \Exception("Missing the required parameter $pet_id when calling updatePetWithForm"); + } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -381,6 +397,12 @@ class PetApi { * @return void */ public function deletePet($api_key, $pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \Exception("Missing the required parameter $pet_id when calling deletePet"); + } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -439,6 +461,12 @@ class PetApi { * @return void */ public function uploadFile($pet_id, $additional_metadata, $file) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \Exception("Missing the required parameter $pet_id when calling uploadFile"); + } + // parse inputs $resourcePath = "/pet/{petId}/uploadImage"; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php index 4e40ed983b9..6e3ce56e7ce 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php @@ -37,6 +37,7 @@ class StoreApi { * @return map[string,int] */ public function getInventory() { + // parse inputs $resourcePath = "/store/inventory"; @@ -92,6 +93,7 @@ class StoreApi { * @return Order */ public function placeOrder($body) { + // parse inputs $resourcePath = "/store/order"; @@ -151,6 +153,12 @@ class StoreApi { * @return Order */ public function getOrderById($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { + throw new \Exception("Missing the required parameter $order_id when calling getOrderById"); + } + // parse inputs $resourcePath = "/store/order/{orderId}"; @@ -210,6 +218,12 @@ class StoreApi { * @return void */ public function deleteOrder($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { + throw new \Exception("Missing the required parameter $order_id when calling deleteOrder"); + } + // parse inputs $resourcePath = "/store/order/{orderId}"; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php index f3e9e7f4cc6..8296d5e92fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php @@ -38,6 +38,7 @@ class UserApi { * @return void */ public function createUser($body) { + // parse inputs $resourcePath = "/user"; @@ -91,6 +92,7 @@ class UserApi { * @return void */ public function createUsersWithArrayInput($body) { + // parse inputs $resourcePath = "/user/createWithArray"; @@ -144,6 +146,7 @@ class UserApi { * @return void */ public function createUsersWithListInput($body) { + // parse inputs $resourcePath = "/user/createWithList"; @@ -198,6 +201,7 @@ class UserApi { * @return string */ public function loginUser($username, $password) { + // parse inputs $resourcePath = "/user/login"; @@ -258,6 +262,7 @@ class UserApi { * @return void */ public function logoutUser() { + // parse inputs $resourcePath = "/user/logout"; @@ -307,6 +312,12 @@ class UserApi { * @return User */ public function getUserByName($username) { + + // verify the required parameter 'username' is set + if ($username === null) { + throw new \Exception("Missing the required parameter $username when calling getUserByName"); + } + // parse inputs $resourcePath = "/user/{username}"; @@ -367,6 +378,12 @@ class UserApi { * @return void */ public function updateUser($username, $body) { + + // verify the required parameter 'username' is set + if ($username === null) { + throw new \Exception("Missing the required parameter $username when calling updateUser"); + } + // parse inputs $resourcePath = "/user/{username}"; @@ -424,6 +441,12 @@ class UserApi { * @return void */ public function deleteUser($username) { + + // verify the required parameter 'username' is set + if ($username === null) { + throw new \Exception("Missing the required parameter $username when calling deleteUser"); + } + // parse inputs $resourcePath = "/user/{username}";