diff --git a/modules/swagger-codegen/src/main/resources/android-java/api.mustache b/modules/swagger-codegen/src/main/resources/android-java/api.mustache index 0f21897e67..ed9538c159 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/api.mustache @@ -47,13 +47,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}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java index c8da678b2f..88fdfdb698 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java @@ -46,7 +46,6 @@ public class PetApi { */ public void updatePet (Pet body) throws ApiException { Object postBody = body; - // create path and map variables @@ -101,7 +100,6 @@ public class PetApi { */ public void addPet (Pet body) throws ApiException { Object postBody = body; - // create path and map variables @@ -156,7 +154,6 @@ public class PetApi { */ public List findPetsByStatus (List status) throws ApiException { Object postBody = null; - // create path and map variables @@ -213,7 +210,6 @@ public class PetApi { */ public List findPetsByTags (List tags) throws ApiException { Object postBody = null; - // create path and map variables @@ -270,7 +266,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 @@ -327,7 +327,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 @@ -393,7 +397,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 @@ -451,7 +459,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 diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java index 1e2ff3bba8..ecd8e83304 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java @@ -45,7 +45,6 @@ public class StoreApi { */ public Map getInventory () throws ApiException { Object postBody = null; - // create path and map variables @@ -100,7 +99,6 @@ public class StoreApi { */ public Order placeOrder (Order body) throws ApiException { Object postBody = body; - // create path and map variables @@ -155,7 +153,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 @@ -210,7 +212,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 diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java index da105638c5..e1df3fd4f1 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java @@ -46,7 +46,6 @@ public class UserApi { */ public void createUser (User body) throws ApiException { Object postBody = body; - // create path and map variables @@ -101,7 +100,6 @@ public class UserApi { */ public void createUsersWithArrayInput (List body) throws ApiException { Object postBody = body; - // create path and map variables @@ -156,7 +154,6 @@ public class UserApi { */ public void createUsersWithListInput (List body) throws ApiException { Object postBody = body; - // create path and map variables @@ -212,7 +209,6 @@ public class UserApi { */ public String loginUser (String username, String password) throws ApiException { Object postBody = null; - // create path and map variables @@ -270,7 +266,6 @@ public class UserApi { */ public void logoutUser () throws ApiException { Object postBody = null; - // create path and map variables @@ -325,7 +320,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 @@ -381,7 +380,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 @@ -436,7 +439,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 diff --git a/samples/client/petstore/java/hello.txt b/samples/client/petstore/java/hello.txt new file mode 100644 index 0000000000..6769dd60bd --- /dev/null +++ b/samples/client/petstore/java/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file