From 7d87d50d8907e38b0010ddaa8cd1aa7a9540b0f4 Mon Sep 17 00:00:00 2001 From: Timon Link Date: Wed, 11 Dec 2024 13:53:38 +0100 Subject: [PATCH 1/3] bugfix-20188: use numeric check to ensure that generated inner enums do not use valueOf factory method for BigDecimals. --- .../src/main/resources/Java/modelInnerEnum.mustache | 2 +- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 12 ++++++------ .../java/org/openapitools/client/model/EnumTest.java | 12 ++++++------ .../java/org/openapitools/client/model/EnumTest.java | 12 ++++++------ .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 8 ++++---- .../java/org/openapitools/client/model/EnumTest.java | 12 ++++++------ 28 files changed, 117 insertions(+), 117 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache index f875240996b3..48b49ecff542 100644 --- a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache @@ -23,7 +23,7 @@ {{#withXml}} @XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{/withXml}} - {{{name}}}({{^isUri}}{{dataType}}.valueOf({{/isUri}}{{{value}}}{{^isUri}}){{/isUri}}){{^-last}}, + {{{name}}}({{^isUri}}{{^isNumeric}}{{dataType}}.valueOf({{/isNumeric}}{{/isUri}}{{{value}}}{{^isUri}}{{^isNumeric}}){{/isNumeric}}{{/isUri}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java index da8586607db2..041170157607 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -136,9 +136,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -175,9 +175,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java index 2301e8fd6db1..ed0881d28d70 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java @@ -128,9 +128,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -167,9 +167,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java index bc4c9156c2c8..3a5313b7dbf2 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java index 7056c1fe6f17..a4b06cc62375 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java @@ -123,9 +123,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -162,9 +162,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java index 5bc0186abdf2..c569dbe738b6 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java @@ -126,9 +126,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -165,9 +165,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java index 5bc0186abdf2..c569dbe738b6 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java @@ -126,9 +126,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -165,9 +165,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java index bbdb97eafd11..17f5371f4be7 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java @@ -141,9 +141,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -180,9 +180,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(Integer.valueOf(2)), + NUMBER_2(2), - NUMBER_MINUS_2(Integer.valueOf(-2)); + NUMBER_MINUS_2(-2); private Integer value; @@ -219,9 +219,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java index 00f3c70332d9..cafc34f1d4cb 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java @@ -139,9 +139,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -178,9 +178,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(Integer.valueOf(2)), + NUMBER_2(2), - NUMBER_MINUS_2(Integer.valueOf(-2)); + NUMBER_MINUS_2(-2); private Integer value; @@ -217,9 +217,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java index 21df7ad3edeb..f95da430dceb 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java @@ -141,9 +141,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -180,9 +180,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(Integer.valueOf(2)), + NUMBER_2(2), - NUMBER_MINUS_2(Integer.valueOf(-2)); + NUMBER_MINUS_2(-2); private Integer value; @@ -219,9 +219,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java index 3b3703002540..3ce661afccdd 100644 --- a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java @@ -126,9 +126,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -165,9 +165,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java index 1607734ae0d2..6fc9bab5880b 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java @@ -144,9 +144,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -196,9 +196,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index 2cc97b1a582a..5ca677cfe11b 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -134,9 +134,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -173,9 +173,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java index c59ee53a528e..c8696355532c 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java index c59ee53a528e..c8696355532c 100644 --- a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java index 148fe53d536e..382834a7ffca 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java index 34e77f98c05f..d3c1004dcb2c 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java @@ -155,10 +155,10 @@ public static EnumStringRequiredEnum fromValue(String value) { @XmlEnum(Integer.class) public enum EnumIntegerEnum { @XmlEnumValue("1") - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), @XmlEnumValue("-1") - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -199,10 +199,10 @@ public static EnumIntegerEnum fromValue(Integer value) { @XmlEnum(Double.class) public enum EnumNumberEnum { @XmlEnumValue("1.1") - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), @XmlEnumValue("-1.2") - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java index dccb75274f16..6106c2b0a2e7 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java index dfc3aef715d0..c0368bd8e048 100644 --- a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java @@ -125,9 +125,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -164,9 +164,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java index 9d96c16b6ef2..ec5524ac24b9 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -141,9 +141,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -193,9 +193,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java index 9d96c16b6ef2..ec5524ac24b9 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -141,9 +141,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -193,9 +193,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java index 9d96c16b6ef2..ec5524ac24b9 100644 --- a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java @@ -141,9 +141,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -193,9 +193,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java index 7056c1fe6f17..a4b06cc62375 100644 --- a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java @@ -123,9 +123,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -162,9 +162,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java index 148fe53d536e..382834a7ffca 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java index c59ee53a528e..c8696355532c 100644 --- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index 2b76dde8df67..edd5a9b750b7 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -134,9 +134,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -173,9 +173,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java index 148fe53d536e..382834a7ffca 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -133,9 +133,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java index bd9760a10e43..58b36dd2154a 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java @@ -139,9 +139,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(Integer.valueOf(1)), + NUMBER_1(1), - NUMBER_MINUS_1(Integer.valueOf(-1)); + NUMBER_MINUS_1(-1); private Integer value; @@ -178,9 +178,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(Integer.valueOf(2)), + NUMBER_2(2), - NUMBER_MINUS_2(Integer.valueOf(-2)); + NUMBER_MINUS_2(-2); private Integer value; @@ -217,9 +217,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(Double.valueOf(1.1)), + NUMBER_1_DOT_1(1.1), - NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); + NUMBER_MINUS_1_DOT_2(-1.2); private Double value; From fffb0e850cccaeb2696af51d2cb6894736127e06 Mon Sep 17 00:00:00 2001 From: Timon Link Date: Tue, 17 Dec 2024 09:34:48 +0100 Subject: [PATCH 2/3] bugfix-20188: Add test data to fake Api in petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml --- ...points-models-for-testing-okhttp-gson.yaml | 29 ++++++ .../java/okhttp-gson/api/openapi.yaml | 29 ++++++ .../AllOfModelArrayAnyOfAllOfAttributesC.md | 10 +++ .../petstore/java/okhttp-gson/docs/FakeApi.md | 8 +- .../petstore/java/okhttp-gson/docs/Order.md | 10 +++ .../org/openapitools/client/api/FakeApi.java | 34 +++++-- .../AllOfModelArrayAnyOfAllOfAttributesC.java | 1 + .../org/openapitools/client/model/Order.java | 88 ++++++++++++++++++- 8 files changed, 196 insertions(+), 13 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml index fa56ab5043cf..0e700e8d22b6 100644 --- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml @@ -681,6 +681,23 @@ paths: - '-efg' - (xyz) default: '-efg' + enum_form_integer: + description: Form parameter enum test (integer) + type: integer + enum: + - 1 + - -1 + - 0 + default: 1 + enum_form_double: + description: Form parameter enum test (double) + type: double + enum: + - 1.1 + - -1.1 + - 0.1 + - 0.0 + default: 1.1 post: tags: - fake @@ -1558,6 +1575,18 @@ components: complete: type: boolean default: false + paymentMethod: + type: number + format: int32 + description: "Various payment methods" + default: 1 + example: 1 + x-enum-description: + - Paypal + - Creditcard + enum: + - 1 + - 2 xml: name: Order Category: diff --git a/samples/client/petstore/java/okhttp-gson/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson/api/openapi.yaml index c20e25778928..fdf2306b1874 100644 --- a/samples/client/petstore/java/okhttp-gson/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson/api/openapi.yaml @@ -1597,6 +1597,7 @@ components: example: petId: 6 quantity: 1 + paymentMethod: 1 id: 0 shipDate: 2020-02-02T20:20:20.000222Z complete: false @@ -1625,6 +1626,18 @@ components: complete: default: false type: boolean + paymentMethod: + default: 1 + description: Various payment methods + enum: + - 1 + - 2 + example: 1 + format: int32 + type: number + x-enum-description: + - Paypal + - Creditcard type: object xml: name: Order @@ -2913,6 +2926,22 @@ components: - -efg - (xyz) type: string + enum_form_integer: + default: 1 + description: Form parameter enum test (integer) + enum: + - 1 + - -1 + - 0 + type: integer + enum_form_double: + description: Form parameter enum test (double) + enum: + - 1.1 + - -1.1 + - 0.1 + - 0.0 + type: double type: object testEndpointParameters_request: properties: diff --git a/samples/client/petstore/java/okhttp-gson/docs/AllOfModelArrayAnyOfAllOfAttributesC.md b/samples/client/petstore/java/okhttp-gson/docs/AllOfModelArrayAnyOfAllOfAttributesC.md index 5229de89b299..f94d7753cfb0 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/AllOfModelArrayAnyOfAllOfAttributesC.md +++ b/samples/client/petstore/java/okhttp-gson/docs/AllOfModelArrayAnyOfAllOfAttributesC.md @@ -17,6 +17,7 @@ |**quantity** | **Integer** | | [optional] | |**shipDate** | **OffsetDateTime** | | [optional] | |**complete** | **Boolean** | | [optional] | +|**paymentMethod** | [**PaymentMethodEnum**](#PaymentMethodEnum) | Various payment methods | [optional] | @@ -30,3 +31,12 @@ +## Enum: PaymentMethodEnum + +| Name | Value | +|---- | -----| +| NUMBER_1 | new BigDecimal("1") | +| NUMBER_2 | new BigDecimal("2") | + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md index eb2f76491a83..b031ec7edd76 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md @@ -982,7 +982,7 @@ null (empty response body) # **testEnumParameters** -> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString) +> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble) To test enum parameters @@ -1011,8 +1011,10 @@ public class Example { Double enumQueryDouble = 1.1D; // Double | Query parameter enum test (double) List enumFormStringArray = Arrays.asList("$"); // List | Form parameter enum test (string array) String enumFormString = "_abc"; // String | Form parameter enum test (string) + Integer enumFormInteger = 1; // Integer | Form parameter enum test (integer) + Double enumFormDouble = 1.1D; // Double | Form parameter enum test (double) try { - apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble); } catch (ApiException e) { System.err.println("Exception when calling FakeApi#testEnumParameters"); System.err.println("Status code: " + e.getCode()); @@ -1036,6 +1038,8 @@ public class Example { | **enumQueryDouble** | **Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2] | | **enumFormStringArray** | [**List<String>**](String.md)| Form parameter enum test (string array) | [optional] [enum: >, $] | | **enumFormString** | **String**| Form parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)] | +| **enumFormInteger** | **Integer**| Form parameter enum test (integer) | [optional] [default to 1] [enum: 1, -1, 0] | +| **enumFormDouble** | [**Double**](Double.md)| Form parameter enum test (double) | [optional] [enum: 1.1, -1.1, 0.1, 0.0] | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson/docs/Order.md b/samples/client/petstore/java/okhttp-gson/docs/Order.md index 27af32855c5c..b25552d366d9 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/Order.md +++ b/samples/client/petstore/java/okhttp-gson/docs/Order.md @@ -13,6 +13,7 @@ |**shipDate** | **OffsetDateTime** | | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | |**complete** | **Boolean** | | [optional] | +|**paymentMethod** | [**PaymentMethodEnum**](#PaymentMethodEnum) | Various payment methods | [optional] | @@ -26,3 +27,12 @@ +## Enum: PaymentMethodEnum + +| Name | Value | +|---- | -----| +| NUMBER_1 | new BigDecimal("1") | +| NUMBER_2 | new BigDecimal("2") | + + + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java index 26fa4abab65e..98cfd44d411e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/api/FakeApi.java @@ -2108,6 +2108,8 @@ public okhttp3.Call testEndpointParametersAsync(BigDecimal number, Double _doubl * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumFormInteger Form parameter enum test (integer) (optional, default to 1) + * @param enumFormDouble Form parameter enum test (double) (optional) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -2119,7 +2121,7 @@ public okhttp3.Call testEndpointParametersAsync(BigDecimal number, Double _doubl 404 Not found - */ - public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { + public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, Integer enumFormInteger, Double enumFormDouble, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -2152,6 +2154,14 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S localVarFormParams.put("enum_form_string", enumFormString); } + if (enumFormInteger != null) { + localVarFormParams.put("enum_form_integer", enumFormInteger); + } + + if (enumFormDouble != null) { + localVarFormParams.put("enum_form_double", enumFormDouble); + } + if (enumQueryStringArray != null) { localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "enum_query_string_array", enumQueryStringArray)); } @@ -2198,8 +2208,8 @@ public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, S } @SuppressWarnings("rawtypes") - private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { - return testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); + private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, Integer enumFormInteger, Double enumFormDouble, final ApiCallback _callback) throws ApiException { + return testEnumParametersCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble, _callback); } @@ -2214,6 +2224,8 @@ private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeade * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumFormInteger Form parameter enum test (integer) (optional, default to 1) + * @param enumFormDouble Form parameter enum test (double) (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -2223,8 +2235,8 @@ private okhttp3.Call testEnumParametersValidateBeforeCall(List enumHeade
404 Not found -
*/ - public void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws ApiException { - testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + public void testEnumParameters(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, Integer enumFormInteger, Double enumFormDouble) throws ApiException { + testEnumParametersWithHttpInfo(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble); } /** @@ -2238,6 +2250,8 @@ public void testEnumParameters(List enumHeaderStringArray, String enumHe * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumFormInteger Form parameter enum test (integer) (optional, default to 1) + * @param enumFormDouble Form parameter enum test (double) (optional) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -2248,8 +2262,8 @@ public void testEnumParameters(List enumHeaderStringArray, String enumHe 404 Not found - */ - public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, null); + public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, Integer enumFormInteger, Double enumFormDouble) throws ApiException { + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble, null); return localVarApiClient.execute(localVarCall); } @@ -2264,6 +2278,8 @@ public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderS * @param enumQueryDouble Query parameter enum test (double) (optional) * @param enumFormStringArray Form parameter enum test (string array) (optional) * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumFormInteger Form parameter enum test (integer) (optional, default to 1) + * @param enumFormDouble Form parameter enum test (double) (optional) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -2275,9 +2291,9 @@ public ApiResponse testEnumParametersWithHttpInfo(List enumHeaderS 404 Not found - */ - public okhttp3.Call testEnumParametersAsync(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException { + public okhttp3.Call testEnumParametersAsync(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, Integer enumFormInteger, Double enumFormDouble, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, _callback); + okhttp3.Call localVarCall = testEnumParametersValidateBeforeCall(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/AllOfModelArrayAnyOfAllOfAttributesC.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/AllOfModelArrayAnyOfAllOfAttributesC.java index a5585c1cd9b0..adb01b58045d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/AllOfModelArrayAnyOfAllOfAttributesC.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/AllOfModelArrayAnyOfAllOfAttributesC.java @@ -20,6 +20,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.math.BigDecimal; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Arrays; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java index 1013694c0c6c..c110cb8a129e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java @@ -20,6 +20,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.math.BigDecimal; import java.time.OffsetDateTime; import java.util.Arrays; @@ -135,6 +136,63 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti @javax.annotation.Nullable private Boolean complete = false; + /** + * Various payment methods + */ + @JsonAdapter(PaymentMethodEnum.Adapter.class) + public enum PaymentMethodEnum { + NUMBER_1(new BigDecimal("1")), + + NUMBER_2(new BigDecimal("2")); + + private BigDecimal value; + + PaymentMethodEnum(BigDecimal value) { + this.value = value; + } + + public BigDecimal getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static PaymentMethodEnum fromValue(BigDecimal value) { + for (PaymentMethodEnum b : PaymentMethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final PaymentMethodEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public PaymentMethodEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return PaymentMethodEnum.fromValue(new BigDecimal(value)); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + PaymentMethodEnum.fromValue(new BigDecimal(value)); + } + } + + public static final String SERIALIZED_NAME_PAYMENT_METHOD = "paymentMethod"; + @SerializedName(SERIALIZED_NAME_PAYMENT_METHOD) + @javax.annotation.Nullable + private PaymentMethodEnum paymentMethod = PaymentMethodEnum.NUMBER_1; + public Order() { } @@ -251,6 +309,25 @@ public void setComplete(@javax.annotation.Nullable Boolean complete) { this.complete = complete; } + + public Order paymentMethod(@javax.annotation.Nullable PaymentMethodEnum paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + /** + * Various payment methods + * @return paymentMethod + */ + @javax.annotation.Nullable + public PaymentMethodEnum getPaymentMethod() { + return paymentMethod; + } + + public void setPaymentMethod(@javax.annotation.Nullable PaymentMethodEnum paymentMethod) { + this.paymentMethod = paymentMethod; + } + /** * A container for additional, undeclared properties. * This is a holder for any undeclared properties as specified with @@ -311,13 +388,14 @@ public boolean equals(Object o) { Objects.equals(this.quantity, order.quantity) && Objects.equals(this.shipDate, order.shipDate) && Objects.equals(this.status, order.status) && - Objects.equals(this.complete, order.complete)&& + Objects.equals(this.complete, order.complete) && + Objects.equals(this.paymentMethod, order.paymentMethod)&& Objects.equals(this.additionalProperties, order.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, petId, quantity, shipDate, status, complete, additionalProperties); + return Objects.hash(id, petId, quantity, shipDate, status, complete, paymentMethod, additionalProperties); } @Override @@ -330,6 +408,7 @@ public String toString() { sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append(" paymentMethod: ").append(toIndentedString(paymentMethod)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); @@ -359,6 +438,7 @@ private String toIndentedString(Object o) { openapiFields.add("shipDate"); openapiFields.add("status"); openapiFields.add("complete"); + openapiFields.add("paymentMethod"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); @@ -384,6 +464,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { StatusEnum.validateJsonElement(jsonObj.get("status")); } + // validate the optional field `paymentMethod` + if (jsonObj.get("paymentMethod") != null && !jsonObj.get("paymentMethod").isJsonNull()) { + PaymentMethodEnum.validateJsonElement(jsonObj.get("paymentMethod")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { From a8d3e7da44e268d32818e6d02d0a111d58f7bbea Mon Sep 17 00:00:00 2001 From: Timon Link Date: Tue, 17 Dec 2024 09:53:34 +0100 Subject: [PATCH 3/3] bugfix-20188: Fix compilation error in FakeApiTest.java --- .../test/java/org/openapitools/client/api/FakeApiTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java index 9a44aacd233a..609fc9f0a40f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/FakeApiTest.java @@ -220,7 +220,9 @@ public void testEnumParametersTest() throws ApiException { Double enumQueryDouble = null; List enumFormStringArray = null; String enumFormString = null; - api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); + Integer enumFormInteger = null; + Double enumFormDouble = null; + api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, enumFormInteger, enumFormDouble); // TODO: test validations }