From 0ee6531fcd60f6c0202f6a092f7aaeafa050f032 Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 01:02:04 -0800 Subject: [PATCH 1/7] Version mapping for scala 2.10.* should be consistent. --- bin/Version.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/Version.scala b/bin/Version.scala index 8607187f845..d25fe6f9bb7 100644 --- a/bin/Version.scala +++ b/bin/Version.scala @@ -1,5 +1,7 @@ val version = scala.util.Properties.scalaPropOrElse("version.number", "unknown").toString match { case "2.10.0" => "2.10" + case "2.10.2" => "2.10" + case "2.10.3" => "2.10" case e: String => e } -println(version) \ No newline at end of file +println(version) From 17c38115e60e86436faa29f645919133dc4299d9 Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 01:05:13 -0800 Subject: [PATCH 2/7] rebuild java files before changes to template --- .../java/src/main/java/com/wordnik/client/ApiInvoker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java b/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java index 955ffe39f6e..781e7da6981 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java @@ -12,6 +12,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.LoggingFilter; import com.sun.jersey.api.client.WebResource.Builder; +import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.MediaType; import java.util.Map; @@ -123,7 +124,7 @@ public class ApiInvoker { else { throw new ApiException(500, "unknown method type " + method); } - if(response.getClientResponseStatus() == ClientResponse.Status.OK) { + if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) { return (String) response.getEntity(String.class); } else { From 1e2f7cb1f8697a396a641ae3aa0282ff0fcb525f Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 01:13:51 -0800 Subject: [PATCH 3/7] To throw expected ApiException instead of NullPointerException, check required parameters before use --- src/main/resources/Java/api.mustache | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/Java/api.mustache b/src/main/resources/Java/api.mustache index de2248f8930..5ae03eca407 100644 --- a/src/main/resources/Java/api.mustache +++ b/src/main/resources/Java/api.mustache @@ -26,13 +26,6 @@ public class {{classname}} { {{#operation}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { - // create path and map variables - String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - {{#requiredParamCount}} // verify required params are set if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) { @@ -40,6 +33,13 @@ public class {{classname}} { } {{/requiredParamCount}} + // create path and map variables + String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) queryParams.put("{{baseName}}", String.valueOf({{paramName}})); {{/queryParams}} From 08a3e9e881c0558b642cb48d62b5d8713dcd0761 Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 01:16:21 -0800 Subject: [PATCH 4/7] Rebuild generated java samples with ApiException checking properly located --- .../java/com/wordnik/petstore/api/PetApi.java | 64 ++++++------- .../com/wordnik/petstore/api/StoreApi.java | 24 ++--- .../com/wordnik/petstore/api/UserApi.java | 56 +++++------ .../com/wordnik/client/api/AccountApi.java | 32 +++---- .../java/com/wordnik/client/api/WordApi.java | 96 +++++++++---------- .../com/wordnik/client/api/WordListApi.java | 48 +++++----- .../com/wordnik/client/api/WordListsApi.java | 8 +- .../java/com/wordnik/client/api/WordsApi.java | 16 ++-- 8 files changed, 172 insertions(+), 172 deletions(-) diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java index 8b460e98cfa..4abd43de856 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/PetApi.java @@ -23,6 +23,10 @@ public class PetApi { } public Pet getPetById (Long petId) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -30,10 +34,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -54,6 +54,10 @@ public class PetApi { } } public void deletePet (String petId) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -61,10 +65,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -85,6 +85,10 @@ public class PetApi { } } public List partialUpdate (String petId, Pet body) throws ApiException { + // verify required params are set + if(petId == null || body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -92,10 +96,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null || body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -116,6 +116,10 @@ public class PetApi { } } public void updatePetWithForm (String petId, String name, String status) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -123,10 +127,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -174,6 +174,10 @@ public class PetApi { } } public void addPet (Pet body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -181,10 +185,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -205,6 +205,10 @@ public class PetApi { } } public void updatePet (Pet body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -212,10 +216,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -236,6 +236,10 @@ public class PetApi { } } public List findPetsByStatus (String status) throws ApiException { + // verify required params are set + if(status == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -243,10 +247,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(status == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(status))) queryParams.put("status", String.valueOf(status)); String contentType = "application/json"; @@ -269,6 +269,10 @@ public class PetApi { } } public List findPetsByTags (String tags) throws ApiException { + // verify required params are set + if(tags == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -276,10 +280,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(tags == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(tags))) queryParams.put("tags", String.valueOf(tags)); String contentType = "application/json"; diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java index dc57a7956dc..9be137cd79f 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/StoreApi.java @@ -22,6 +22,10 @@ public class StoreApi { } public Order getOrderById (String orderId) throws ApiException { + // verify required params are set + if(orderId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); @@ -29,10 +33,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(orderId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -53,6 +53,10 @@ public class StoreApi { } } public void deleteOrder (String orderId) throws ApiException { + // verify required params are set + if(orderId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); @@ -60,10 +64,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(orderId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -84,6 +84,10 @@ public class StoreApi { } } public void placeOrder (Order body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); @@ -91,10 +95,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { diff --git a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java index c5c7d3affae..0527a5a49ca 100644 --- a/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java +++ b/samples/client/petstore/java/src/main/java/com/wordnik/petstore/api/UserApi.java @@ -22,6 +22,10 @@ public class UserApi { } public void createUser (User body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); @@ -29,10 +33,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -53,6 +53,10 @@ public class UserApi { } } public void createUsersWithArrayInput (List body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -60,10 +64,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -84,6 +84,10 @@ public class UserApi { } } public void createUsersWithListInput (List body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -91,10 +95,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -115,6 +115,10 @@ public class UserApi { } } public void updateUser (String username, User body) throws ApiException { + // verify required params are set + if(username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -122,10 +126,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -146,6 +146,10 @@ public class UserApi { } } public void deleteUser (String username) throws ApiException { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -153,10 +157,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -177,6 +177,10 @@ public class UserApi { } } public User getUserByName (String username) throws ApiException { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -184,10 +188,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -208,6 +208,10 @@ public class UserApi { } } public String loginUser (String username, String password) throws ApiException { + // verify required params are set + if(username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); @@ -215,10 +219,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || password == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(username))) queryParams.put("username", String.valueOf(username)); if(!"null".equals(String.valueOf(password))) diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java index 51448d9cfd1..33a1d5da0c6 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java @@ -25,6 +25,10 @@ public class AccountApi { } public AuthenticationToken authenticate (String username, String password) throws ApiException { + // verify required params are set + if(username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -32,10 +36,6 @@ public class AccountApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || password == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(password))) queryParams.put("password", String.valueOf(password)); String contentType = "application/json"; @@ -58,6 +58,10 @@ public class AccountApi { } } public AuthenticationToken authenticatePost (String username, String body) throws ApiException { + // verify required params are set + if(username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -65,10 +69,6 @@ public class AccountApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -89,6 +89,10 @@ public class AccountApi { } } public List getWordListsForLoggedInUser (String auth_token, Integer skip, Integer limit) throws ApiException { + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/account.{format}/wordLists".replaceAll("\\{format\\}","json"); @@ -96,10 +100,6 @@ public class AccountApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(auth_token == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(skip))) queryParams.put("skip", String.valueOf(skip)); if(!"null".equals(String.valueOf(limit))) @@ -153,6 +153,10 @@ public class AccountApi { } } public User getLoggedInUser (String auth_token) throws ApiException { + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/account.{format}/user".replaceAll("\\{format\\}","json"); @@ -160,10 +164,6 @@ public class AccountApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java index 6d11ad99c7b..8ab25e31c50 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java @@ -32,6 +32,10 @@ public class WordApi { } public ExampleSearchResults getExamples (String word, String includeDuplicates, String useCanonical, Integer skip, Integer limit) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/examples".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -39,10 +43,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(includeDuplicates))) queryParams.put("includeDuplicates", String.valueOf(includeDuplicates)); if(!"null".equals(String.valueOf(useCanonical))) @@ -71,6 +71,10 @@ public class WordApi { } } public WordObject getWord (String word, String useCanonical, String includeSuggestions) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -78,10 +82,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(includeSuggestions))) @@ -106,6 +106,10 @@ public class WordApi { } } public List getDefinitions (String word, String partOfSpeech, String sourceDictionaries, Integer limit, String includeRelated, String useCanonical, String includeTags) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/definitions".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -113,10 +117,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(limit))) queryParams.put("limit", String.valueOf(limit)); if(!"null".equals(String.valueOf(partOfSpeech))) @@ -149,6 +149,10 @@ public class WordApi { } } public Example getTopExample (String word, String useCanonical) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/topExample".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -156,10 +160,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); String contentType = "application/json"; @@ -182,6 +182,10 @@ public class WordApi { } } public List getRelatedWords (String word, String relationshipTypes, String useCanonical, Integer limitPerRelationshipType) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/relatedWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -189,10 +193,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(relationshipTypes))) @@ -219,6 +219,10 @@ public class WordApi { } } public List getTextPronunciations (String word, String sourceDictionary, String typeFormat, String useCanonical, Integer limit) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/pronunciations".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -226,10 +230,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(sourceDictionary))) @@ -258,6 +258,10 @@ public class WordApi { } } public List getHyphenation (String word, String sourceDictionary, String useCanonical, Integer limit) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/hyphenation".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -265,10 +269,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(sourceDictionary))) @@ -295,6 +295,10 @@ public class WordApi { } } public FrequencySummary getWordFrequency (String word, String useCanonical, Integer startYear, Integer endYear) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/frequency".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -302,10 +306,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(startYear))) @@ -332,6 +332,10 @@ public class WordApi { } } public List getPhrases (String word, Integer limit, Integer wlmi, String useCanonical) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/phrases".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -339,10 +343,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(limit))) queryParams.put("limit", String.valueOf(limit)); if(!"null".equals(String.valueOf(wlmi))) @@ -369,6 +369,10 @@ public class WordApi { } } public List getEtymologies (String word, String useCanonical) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/etymologies".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -376,10 +380,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); String contentType = "application/json"; @@ -402,6 +402,10 @@ public class WordApi { } } public List getAudio (String word, String useCanonical, Integer limit) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/audio".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -409,10 +413,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(useCanonical))) queryParams.put("useCanonical", String.valueOf(useCanonical)); if(!"null".equals(String.valueOf(limit))) @@ -437,6 +437,10 @@ public class WordApi { } } public ScrabbleScoreResult getScrabbleScore (String word) throws ApiException { + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/word.{format}/{word}/scrabbleScore".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString())); @@ -444,10 +448,6 @@ public class WordApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(word == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java index b75aa46004c..bb434b11a88 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java @@ -24,6 +24,10 @@ public class WordListApi { } public void updateWordList (String permalink, WordList body, String auth_token) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -31,10 +35,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; @@ -56,6 +56,10 @@ public class WordListApi { } } public void deleteWordList (String permalink, String auth_token) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -63,10 +67,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; @@ -88,6 +88,10 @@ public class WordListApi { } } public WordList getWordListByPermalink (String permalink, String auth_token) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -95,10 +99,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; @@ -120,6 +120,10 @@ public class WordListApi { } } public void addWordsToWordList (String permalink, List body, String auth_token) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -127,10 +131,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; @@ -152,6 +152,10 @@ public class WordListApi { } } public List getWordListWords (String permalink, String auth_token, String sortBy, String sortOrder, Integer skip, Integer limit) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -159,10 +163,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(sortBy))) queryParams.put("sortBy", String.valueOf(sortBy)); if(!"null".equals(String.valueOf(sortOrder))) @@ -192,6 +192,10 @@ public class WordListApi { } } public void deleteWordsFromWordList (String permalink, List body, String auth_token) throws ApiException { + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordList.{format}/{permalink}/deleteWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink.toString())); @@ -199,10 +203,6 @@ public class WordListApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(permalink == null || auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java index c8d669e48d3..5a8836a067a 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java @@ -22,6 +22,10 @@ public class WordListsApi { } public WordList createWordList (WordList body, String auth_token) throws ApiException { + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/wordLists.{format}".replaceAll("\\{format\\}","json"); @@ -29,10 +33,6 @@ public class WordListsApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(auth_token == null ) { - throw new ApiException(400, "missing required params"); - } headerParams.put("auth_token", auth_token); String contentType = "application/json"; diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java index a543bf2c70a..a7e2d8b70da 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java @@ -25,6 +25,10 @@ public class WordsApi { } public WordSearchResults searchWords (String query, String includePartOfSpeech, String excludePartOfSpeech, String caseSensitive, Integer minCorpusCount, Integer maxCorpusCount, Integer minDictionaryCount, Integer maxDictionaryCount, Integer minLength, Integer maxLength, Integer skip, Integer limit) throws ApiException { + // verify required params are set + if(query == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/words.{format}/search/{query}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "query" + "\\}", apiInvoker.escapeString(query.toString())); @@ -32,10 +36,6 @@ public class WordsApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(query == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(caseSensitive))) queryParams.put("caseSensitive", String.valueOf(caseSensitive)); if(!"null".equals(String.valueOf(includePartOfSpeech))) @@ -107,6 +107,10 @@ public class WordsApi { } } public DefinitionSearchResults reverseDictionary (String query, String findSenseForWord, String includeSourceDictionaries, String excludeSourceDictionaries, String includePartOfSpeech, String excludePartOfSpeech, String expandTerms, String sortBy, String sortOrder, Integer minCorpusCount, Integer maxCorpusCount, Integer minLength, Integer maxLength, String includeTags, String skip, Integer limit) throws ApiException { + // verify required params are set + if(query == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/words.{format}/reverseDictionary".replaceAll("\\{format\\}","json"); @@ -114,10 +118,6 @@ public class WordsApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(query == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(query))) queryParams.put("query", String.valueOf(query)); if(!"null".equals(String.valueOf(findSenseForWord))) From 59897c19a9965e944b2f4c26eac8db9d052f8ee1 Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 01:16:58 -0800 Subject: [PATCH 5/7] Rebuild wording sample ApiInvoker from latest. --- .../src/main/java/com/wordnik/client/common/ApiInvoker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java index 8344a2ab37f..04f65f0ea94 100644 --- a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java @@ -12,6 +12,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.LoggingFilter; import com.sun.jersey.api.client.WebResource.Builder; +import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.MediaType; import java.util.Map; @@ -123,7 +124,7 @@ public class ApiInvoker { else { throw new ApiException(500, "unknown method type " + method); } - if(response.getClientResponseStatus() == ClientResponse.Status.OK) { + if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) { return (String) response.getEntity(String.class); } else { From 800312361fa417accd417d7b2ff3ee5140cf0acd Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 08:02:03 -0800 Subject: [PATCH 6/7] Also android-java templates: Rebuild wording sample ApiInvoker from latest.To throw expected ApiException instead of NullPointerException, check required parameters before use --- src/main/resources/android-java/api.mustache | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/android-java/api.mustache b/src/main/resources/android-java/api.mustache index 925e9b9d711..afd6297c451 100644 --- a/src/main/resources/android-java/api.mustache +++ b/src/main/resources/android-java/api.mustache @@ -30,13 +30,6 @@ public class {{classname}} { {{#operation}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { - // create path and map variables - String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; - - // query params - Map queryParams = new HashMap(); - Map headerParams = new HashMap(); - {{#requiredParamCount}} // verify required params are set if({{/requiredParamCount}}{{#requiredParams}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}) { @@ -44,6 +37,13 @@ public class {{classname}} { } {{/requiredParamCount}} + // create path and map variables + String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{paramName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) queryParams.put("{{paramName}}", String.valueOf({{paramName}})); {{/queryParams}} From 2c73efa53668e745dbdaf7590c51bd9e90af164d Mon Sep 17 00:00:00 2001 From: Robert Blair Date: Wed, 27 Nov 2013 08:02:42 -0800 Subject: [PATCH 7/7] And rebuild the samples for android-java --- .../java/com/wordnik/petstore/api/PetApi.java | 64 +++++++++---------- .../com/wordnik/petstore/api/StoreApi.java | 24 +++---- .../com/wordnik/petstore/api/UserApi.java | 56 ++++++++-------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/PetApi.java b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/PetApi.java index c620cd42599..c9e33d53512 100644 --- a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/PetApi.java +++ b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/PetApi.java @@ -27,6 +27,10 @@ public class PetApi { } public Pet getPetById (Long petId) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -34,10 +38,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -58,6 +58,10 @@ public class PetApi { } } public void deletePet (String petId) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -65,10 +69,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -89,6 +89,10 @@ public class PetApi { } } public List partialUpdate (String petId, Pet body) throws ApiException { + // verify required params are set + if(petId == null || body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -96,10 +100,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null || body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -120,6 +120,10 @@ public class PetApi { } } public void updatePetWithForm (String petId, String name, String status) throws ApiException { + // verify required params are set + if(petId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); @@ -127,10 +131,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(petId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -178,6 +178,10 @@ public class PetApi { } } public void addPet (Pet body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -185,10 +189,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -209,6 +209,10 @@ public class PetApi { } } public void updatePet (Pet body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -216,10 +220,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -240,6 +240,10 @@ public class PetApi { } } public List findPetsByStatus (String status) throws ApiException { + // verify required params are set + if(status == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -247,10 +251,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(status == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(status))) queryParams.put("status", String.valueOf(status)); String contentType = "application/json"; @@ -273,6 +273,10 @@ public class PetApi { } } public List findPetsByTags (String tags) throws ApiException { + // verify required params are set + if(tags == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -280,10 +284,6 @@ public class PetApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(tags == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(tags))) queryParams.put("tags", String.valueOf(tags)); String contentType = "application/json"; diff --git a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/StoreApi.java b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/StoreApi.java index ea2fd613818..12076bf43dd 100644 --- a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/StoreApi.java +++ b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/StoreApi.java @@ -26,6 +26,10 @@ public class StoreApi { } public Order getOrderById (String orderId) throws ApiException { + // verify required params are set + if(orderId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); @@ -33,10 +37,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(orderId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -57,6 +57,10 @@ public class StoreApi { } } public void deleteOrder (String orderId) throws ApiException { + // verify required params are set + if(orderId == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); @@ -64,10 +68,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(orderId == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -88,6 +88,10 @@ public class StoreApi { } } public void placeOrder (Order body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); @@ -95,10 +99,6 @@ public class StoreApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { diff --git a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/UserApi.java index 505f1245ce1..56ed2a8e038 100644 --- a/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/UserApi.java +++ b/samples/client/petstore/android-java/src/main/java/com/wordnik/petstore/api/UserApi.java @@ -26,6 +26,10 @@ public class UserApi { } public void createUser (User body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); @@ -33,10 +37,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -57,6 +57,10 @@ public class UserApi { } } public void createUsersWithArrayInput (List body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -64,10 +68,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -88,6 +88,10 @@ public class UserApi { } } public void createUsersWithListInput (List body) throws ApiException { + // verify required params are set + if(body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -95,10 +99,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -119,6 +119,10 @@ public class UserApi { } } public void updateUser (String username, User body) throws ApiException { + // verify required params are set + if(username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -126,10 +130,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || body == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -150,6 +150,10 @@ public class UserApi { } } public void deleteUser (String username) throws ApiException { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -157,10 +161,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -181,6 +181,10 @@ public class UserApi { } } public User getUserByName (String username) throws ApiException { + // verify required params are set + if(username == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -188,10 +192,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null ) { - throw new ApiException(400, "missing required params"); - } String contentType = "application/json"; try { @@ -212,6 +212,10 @@ public class UserApi { } } public String loginUser (String username, String password) throws ApiException { + // verify required params are set + if(username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); @@ -219,10 +223,6 @@ public class UserApi { Map queryParams = new HashMap(); Map headerParams = new HashMap(); - // verify required params are set - if(username == null || password == null ) { - throw new ApiException(400, "missing required params"); - } if(!"null".equals(String.valueOf(username))) queryParams.put("username", String.valueOf(username)); if(!"null".equals(String.valueOf(password)))