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 83a43b42853..03d692e5922 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/api.mustache @@ -105,12 +105,7 @@ public class {{classname}} { return {{#returnType}}null{{/returnType}}; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return {{#returnType}} null{{/returnType}}; - } - else { - throw ex; - } + throw ex; } } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache index 07044d59efe..bf6006a7f30 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache @@ -24,6 +24,7 @@ import java.net.Socket; import java.net.UnknownHostException; import java.net.URLEncoder; +import java.util.Collection; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -120,6 +121,15 @@ public class ApiInvoker { return ""; } else if (param instanceof Date) { return formatDateTime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); } else { return String.valueOf(param); } @@ -147,7 +157,7 @@ public class ApiInvoker { public static Object deserialize(String json, String containerType, Class cls) throws ApiException { try{ - if("List".equals(containerType)) { + if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) { JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); List response = (List>) JsonUtil.getJsonMapper().readValue(json, typeInfo); return response; @@ -307,6 +317,7 @@ public class ApiInvoker { HttpEntity resEntity = response.getEntity(); responseString = EntityUtils.toString(resEntity); } + return responseString; } else { if(response.getEntity() != null) { @@ -315,9 +326,8 @@ public class ApiInvoker { } else responseString = "no data"; - throw new ApiException(code, responseString); } - return responseString; + throw new ApiException(code, responseString); } catch(IOException e) { throw new ApiException(500, e.getMessage()); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java index 1d1ce3841ec..8c3f271a13e 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java @@ -24,6 +24,7 @@ import java.net.Socket; import java.net.UnknownHostException; import java.net.URLEncoder; +import java.util.Collection; import java.util.Map; import java.util.HashMap; import java.util.List; @@ -120,6 +121,15 @@ public class ApiInvoker { return ""; } else if (param instanceof Date) { return formatDateTime((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); } else { return String.valueOf(param); } @@ -147,7 +157,7 @@ public class ApiInvoker { public static Object deserialize(String json, String containerType, Class cls) throws ApiException { try{ - if("List".equals(containerType)) { + if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) { JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); List response = (List>) JsonUtil.getJsonMapper().readValue(json, typeInfo); return response; @@ -307,6 +317,7 @@ public class ApiInvoker { HttpEntity resEntity = response.getEntity(); responseString = EntityUtils.toString(resEntity); } + return responseString; } else { if(response.getEntity() != null) { @@ -315,9 +326,8 @@ public class ApiInvoker { } else responseString = "no data"; - throw new ApiException(code, responseString); } - return responseString; + throw new ApiException(code, responseString); } catch(IOException e) { throw new ApiException(500, e.getMessage()); 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 2ecaae40c07..93d9963d5e5 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 @@ -84,12 +84,7 @@ public class PetApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -139,12 +134,7 @@ public class PetApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -196,12 +186,7 @@ public class PetApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -253,12 +238,7 @@ public class PetApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -308,12 +288,7 @@ public class PetApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -373,12 +348,7 @@ public class PetApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -429,12 +399,7 @@ public class PetApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -494,12 +459,7 @@ public class PetApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } 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 b68af58ce9d..3a8ebbaedaa 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 @@ -84,12 +84,7 @@ public class StoreApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -139,12 +134,7 @@ public class StoreApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -194,12 +184,7 @@ public class StoreApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -249,12 +234,7 @@ public class StoreApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } 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 aea620104a9..2e3aba0acd6 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 @@ -84,12 +84,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -139,12 +134,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -194,12 +184,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -253,12 +238,7 @@ public class UserApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -308,12 +288,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -363,12 +338,7 @@ public class UserApi { return null; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return null; - } - else { - throw ex; - } + throw ex; } } @@ -418,12 +388,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } @@ -473,12 +438,7 @@ public class UserApi { return ; } } catch (ApiException ex) { - if(ex.getCode() == 404) { - return ; - } - else { - throw ex; - } + throw ex; } } diff --git a/samples/html/index.html b/samples/html/index.html index 4869e0a255d..66d26311705 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -444,11 +444,11 @@
{\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-04-04T23:36:32.265+0000"\n}
+ {\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-04-05T00:02:39.658+0000"\n}
\n 123456 \n 123456 \n 0 \n 2015-04-04T16:36:32.268Z \n string \n true \n
+ \n 123456 \n 123456 \n 0 \n 2015-04-04T17:02:39.662Z \n string \n true \n
{\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-04-04T23:36:32.269+0000"\n}
+ {\n "id" : 123456789,\n "petId" : 123456789,\n "complete" : true,\n "status" : "aeiou",\n "quantity" : 123,\n "shipDate" : "2015-04-05T00:02:39.664+0000"\n}
\n 123456 \n 123456 \n 0 \n 2015-04-04T16:36:32.270Z \n string \n true \n
+ \n 123456 \n 123456 \n 0 \n 2015-04-04T17:02:39.664Z \n string \n true \n