From e7c92856cd84a6b90d54f2ce357f54b5f5385507 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 28 Apr 2016 16:13:44 +0800 Subject: [PATCH] fix retrofit 1, 2 java sample --- .../libraries/okhttp-gson/modelEnum.mustache | 2 +- .../okhttp-gson/modelInnerEnum.mustache | 2 +- .../Java/libraries/okhttp-gson/pojo.mustache | 4 +-- .../Java/libraries/retrofit/model.mustache | 4 +-- .../Java/libraries/retrofit2/model.mustache | 4 +-- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/model/Order.java | 33 ++++++++++--------- .../java/io/swagger/client/model/Pet.java | 33 ++++++++++--------- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/model/Order.java | 33 ++++++++++--------- .../java/io/swagger/client/model/Pet.java | 33 ++++++++++--------- 17 files changed, 88 insertions(+), 76 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelEnum.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelEnum.mustache index a24100f5cc03..f7af4c89f2f8 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelEnum.mustache @@ -2,7 +2,7 @@ * {{^description}}Gets or Sets {{name}}{{/description}}{{#description}}{{description}}{{/description}} */ public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { - {{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}) + {{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelInnerEnum.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelInnerEnum.mustache index a95fd93249d7..30ebf3febb61 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelInnerEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/modelInnerEnum.mustache @@ -2,7 +2,7 @@ * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} */ public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { - {{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}) + {{#allowableValues}}{{#enumVars}}@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{{name}}}({{{value}}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache index 1c9e06fa556c..b20499078a21 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache @@ -5,9 +5,9 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} -{{>libraries/okhttp-gson/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}} +{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}} -{{>libraries/okhttp-gson/modelInnerEnum}}{{/items}}{{/items.isEnum}} +{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}} @SerializedName("{{baseName}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; {{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/model.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/model.mustache index 779a56fedb76..1de150a9237a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/model.mustache @@ -17,9 +17,9 @@ import com.google.gson.annotations.SerializedName; public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} -{{>libraries/okhttp-gson/enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} +{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}} -{{>libraries/okhttp-gson/enumClass}}{{/items}}{{/items.isEnum}} +{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}} @SerializedName("{{baseName}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; {{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/model.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/model.mustache index 779a56fedb76..1de150a9237a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/model.mustache @@ -17,9 +17,9 @@ import com.google.gson.annotations.SerializedName; public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} -{{>libraries/okhttp-gson/enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} +{{>libraries/common/modelInnerEnum}}{{/isEnum}}{{#items.isEnum}}{{#items}} -{{>libraries/okhttp-gson/enumClass}}{{/items}}{{/items.isEnum}} +{{>libraries/common/modelInnerEnum}}{{/items}}{{/items.isEnum}} @SerializedName("{{baseName}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; {{/vars}} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 6a437716d9c1..7c440acc914d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index 92cadce33c3e..3bb31938c36f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index 41324a8941d6..ff86c29b167f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 0bc5d09320d6..67f661726b18 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index df09446d3b7a..c4e0be3e7118 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index 2d459e2da07c..e05568f8f383 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:54:58.477+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:09:59.809+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 8f94eebd211f..fb5b299a7066 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T15:51:06.629+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:10:49.444+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java index b875279fa88d..2f774c13834e 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -26,27 +26,30 @@ public class Order { private Date shipDate = null; -public enum StatusEnum { - @SerializedName(""placed"") - PLACED(""placed""), + /** + * Order Status + */ + public enum StatusEnum { + @SerializedName("placed") + PLACED("placed"), - @SerializedName(""approved"") - APPROVED(""approved""), + @SerializedName("approved") + APPROVED("approved"), - @SerializedName(""delivered"") - DELIVERED(""delivered""); + @SerializedName("delivered") + DELIVERED("delivered"); - private String value; + private String value; - StatusEnum(String value) { - this.value = value; - } + StatusEnum(String value) { + this.value = value; + } - @Override - public String toString() { - return value; + @Override + public String toString() { + return String.valueOf(value); + } } -} @SerializedName("status") private StatusEnum status = null; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java index 9620e9086c54..8efc46bc471d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Pet.java @@ -32,27 +32,30 @@ public class Pet { private List tags = new ArrayList(); -public enum StatusEnum { - @SerializedName(""available"") - AVAILABLE(""available""), + /** + * pet status in the store + */ + public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), - @SerializedName(""pending"") - PENDING(""pending""), + @SerializedName("pending") + PENDING("pending"), - @SerializedName(""sold"") - SOLD(""sold""); + @SerializedName("sold") + SOLD("sold"); - private String value; + private String value; - StatusEnum(String value) { - this.value = value; - } + StatusEnum(String value) { + this.value = value; + } - @Override - public String toString() { - return value; + @Override + public String toString() { + return String.valueOf(value); + } } -} @SerializedName("status") private StatusEnum status = null; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index a677427c46c1..fe188deeaf5d 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T00:22:56.942+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:12:35.075+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java index b875279fa88d..2f774c13834e 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java @@ -26,27 +26,30 @@ public class Order { private Date shipDate = null; -public enum StatusEnum { - @SerializedName(""placed"") - PLACED(""placed""), + /** + * Order Status + */ + public enum StatusEnum { + @SerializedName("placed") + PLACED("placed"), - @SerializedName(""approved"") - APPROVED(""approved""), + @SerializedName("approved") + APPROVED("approved"), - @SerializedName(""delivered"") - DELIVERED(""delivered""); + @SerializedName("delivered") + DELIVERED("delivered"); - private String value; + private String value; - StatusEnum(String value) { - this.value = value; - } + StatusEnum(String value) { + this.value = value; + } - @Override - public String toString() { - return value; + @Override + public String toString() { + return String.valueOf(value); + } } -} @SerializedName("status") private StatusEnum status = null; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Pet.java index 9620e9086c54..8efc46bc471d 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Pet.java @@ -32,27 +32,30 @@ public class Pet { private List tags = new ArrayList(); -public enum StatusEnum { - @SerializedName(""available"") - AVAILABLE(""available""), + /** + * pet status in the store + */ + public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), - @SerializedName(""pending"") - PENDING(""pending""), + @SerializedName("pending") + PENDING("pending"), - @SerializedName(""sold"") - SOLD(""sold""); + @SerializedName("sold") + SOLD("sold"); - private String value; + private String value; - StatusEnum(String value) { - this.value = value; - } + StatusEnum(String value) { + this.value = value; + } - @Override - public String toString() { - return value; + @Override + public String toString() { + return String.valueOf(value); + } } -} @SerializedName("status") private StatusEnum status = null;