diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index a1c9e05042..78bac41d9d 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -45,12 +45,12 @@ public class {{classname}} { */ public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; - {{#requiredParamCount}} - // verify required params are set - if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) { - throw new ApiException(400, "missing required params"); + {{#allParams}}{{#required}} + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { + throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"); } - {{/requiredParamCount}} + {{/required}}{{/allParams}} // create path and map variables String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}} diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java index 842c080024..b5d6bb70d7 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java @@ -249,6 +249,11 @@ public class PetApi { public Pet getPetById (Long petId) throws ApiException { Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json") @@ -302,6 +307,11 @@ public class PetApi { public void updatePetWithForm (String petId, String name, String status) throws ApiException { Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json") @@ -362,6 +372,11 @@ public class PetApi { public void deletePet (String apiKey, Long petId) throws ApiException { Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json") @@ -416,6 +431,11 @@ public class PetApi { public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + // create path and map variables String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json") diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java index cff340e69d..6da7b5abb2 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java @@ -144,6 +144,11 @@ public class StoreApi { public Order getOrderById (String orderId) throws ApiException { Object postBody = null; + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") @@ -195,6 +200,11 @@ public class StoreApi { public void deleteOrder (String orderId) throws ApiException { Object postBody = null; + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java index 2296c0223c..d0974d95a5 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java @@ -299,6 +299,11 @@ public class UserApi { public User getUserByName (String username) throws ApiException { Object postBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json") @@ -351,6 +356,11 @@ public class UserApi { public void updateUser (String username, User body) throws ApiException { Object postBody = body; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json") @@ -402,6 +412,11 @@ public class UserApi { public void deleteUser (String username) throws ApiException { Object postBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json")