fix required parameters check for php

This commit is contained in:
wing328 2015-04-30 16:52:33 +08:00
parent 303378c5eb
commit 93e4ef0eec
4 changed files with 71 additions and 0 deletions

View File

@ -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}}";

View File

@ -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";

View File

@ -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}";

View File

@ -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}";