From 7deb1c6be96ae2dfa548862e56a831c6bef693ba Mon Sep 17 00:00:00 2001 From: Stephan Schnabel Date: Wed, 16 Aug 2023 09:37:02 +0200 Subject: [PATCH] Generate interfaces instead of abstract classes --- .../InheritanceExtendedAllOf.java | 103 ----------- .../InheritanceWithEnumType1AllOf.java | 102 ----------- .../InheritanceWithEnumType2AllOf.java | 102 ----------- .../InheritanceWithStringType1AllOf.java | 102 ----------- .../InheritanceWithStringType2AllOf.java | 102 ----------- .../InheritanceWithoutType1AllOf.java | 102 ----------- .../InheritanceWithoutType2AllOf.java | 102 ----------- .../micronaut_pojo/InheritanceExtended.java | 3 +- .../micronaut_pojo/InheritanceSimple.java | 58 +----- .../InheritanceSimpleDefault.java | 56 ++++++ .../InheritanceWithEnumType.java | 36 +--- .../InheritanceWithEnumType1.java | 8 +- .../InheritanceWithEnumType2.java | 8 +- .../InheritanceWithEnumType3.java | 4 +- .../InheritanceWithStringType.java | 61 +------ .../InheritanceWithStringType1.java | 27 ++- .../InheritanceWithStringType2.java | 27 ++- .../InheritanceWithoutType.java | 61 +------ .../InheritanceWithoutType1.java | 27 ++- .../InheritanceWithoutType2.java | 27 ++- .../micronaut_pojo/OneOfImplementor1.java | 6 +- .../micronaut_pojo/OneOfImplementor2.java | 6 +- .../InheritanceExtended.java | 3 +- .../InheritanceSimple.java | 58 +----- .../InheritanceSimpleDefault.java | 56 ++++++ .../InheritanceWithEnumType.java | 36 +--- .../InheritanceWithEnumType1.java | 8 +- .../InheritanceWithEnumType2.java | 8 +- .../InheritanceWithEnumType3.java | 4 +- .../InheritanceWithStringType.java | 61 +------ .../InheritanceWithStringType1.java | 27 ++- .../InheritanceWithStringType2.java | 27 ++- .../InheritanceWithoutType.java | 61 +------ .../InheritanceWithoutType1.java | 27 ++- .../InheritanceWithoutType2.java | 27 ++- .../OneOfImplementor1.java | 6 +- .../OneOfImplementor2.java | 6 +- .../nomicronaut/InheritanceExtended.java | 3 +- .../nomicronaut/InheritanceSimple.java | 57 +----- .../nomicronaut/InheritanceSimpleDefault.java | 54 ++++++ .../nomicronaut/InheritanceWithEnumType.java | 35 +--- .../nomicronaut/InheritanceWithEnumType1.java | 8 +- .../nomicronaut/InheritanceWithEnumType2.java | 8 +- .../nomicronaut/InheritanceWithEnumType3.java | 4 +- .../InheritanceWithStringType.java | 60 +----- .../InheritanceWithStringType1.java | 27 ++- .../InheritanceWithStringType2.java | 27 ++- .../nomicronaut/InheritanceWithoutType.java | 60 +----- .../nomicronaut/InheritanceWithoutType1.java | 27 ++- .../nomicronaut/InheritanceWithoutType2.java | 27 ++- .../nomicronaut/OneOfImplementor1.java | 6 +- .../nomicronaut/OneOfImplementor2.java | 6 +- .../InheritanceSimpleDefaultTestExample.java | 10 + .../InheritanceSimpleTestExample.java | 4 +- .../test-model-additional-properties/pom.xml | 4 + src/it/test-model-one-of-interfaces/pom.xml | 4 + .../pom.xml | 4 + .../codegen/languages/MicronautCodegen.java | 171 +++++++++++++++++- src/main/resources/Micronaut/model.mustache | 2 +- .../Micronaut/modelInterface.mustache | 56 ++++++ .../resources/Micronaut/modelPojo.mustache | 74 +++----- .../Micronaut/testExampleObject.mustache | 42 ++--- 62 files changed, 845 insertions(+), 1480 deletions(-) delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceExtendedAllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType1AllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType2AllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithStringType1AllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithStringType2AllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithoutType1AllOf.java delete mode 100644 gen/main/java/testmodel/micronaut_java/InheritanceWithoutType2AllOf.java create mode 100644 gen/main/java/testmodel/micronaut_pojo/InheritanceSimpleDefault.java create mode 100644 gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimpleDefault.java create mode 100644 gen/main/java/testmodel/nomicronaut/InheritanceSimpleDefault.java create mode 100644 gen/test/java/testmodel/nomicronaut/InheritanceSimpleDefaultTestExample.java create mode 100644 src/main/resources/Micronaut/modelInterface.mustache diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceExtendedAllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceExtendedAllOf.java deleted file mode 100644 index 8358cced..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceExtendedAllOf.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceExtendedAllOf - */ -@JsonPropertyOrder({ - InheritanceExtendedAllOf.JSON_PROPERTY_BAR -}) -@JsonTypeName("InheritanceExtended_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceExtendedAllOf { - public static final String JSON_PROPERTY_BAR = "bar"; - private String bar; - - public InheritanceExtendedAllOf(String bar) { - this.bar = bar; - } - - public InheritanceExtendedAllOf bar(String bar) { - this.bar = bar; - return this; - } - - /** - * Get bar - * @return bar - **/ - @NotNull - @JsonProperty(JSON_PROPERTY_BAR) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getBar() { - return bar; - } - - @JsonProperty(JSON_PROPERTY_BAR) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setBar(String bar) { - this.bar = bar; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceExtendedAllOf inheritanceExtendedAllOf = (InheritanceExtendedAllOf) o; - return Objects.equals(this.bar, inheritanceExtendedAllOf.bar); - } - - @Override - public int hashCode() { - return Objects.hash(bar); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceExtendedAllOf {\n"); - sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType1AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType1AllOf.java deleted file mode 100644 index 4f6b2f52..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType1AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithEnumType1AllOf - */ -@JsonPropertyOrder({ - InheritanceWithEnumType1AllOf.JSON_PROPERTY_D -}) -@JsonTypeName("InheritanceWithEnumType1_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithEnumType1AllOf { - public static final String JSON_PROPERTY_D = "d"; - private String d; - - public InheritanceWithEnumType1AllOf() { - } - - public InheritanceWithEnumType1AllOf d(String d) { - this.d = d; - return this; - } - - /** - * Get d - * @return d - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_D) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getD() { - return d; - } - - @JsonProperty(JSON_PROPERTY_D) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setD(String d) { - this.d = d; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithEnumType1AllOf inheritanceWithEnumType1AllOf = (InheritanceWithEnumType1AllOf) o; - return Objects.equals(this.d, inheritanceWithEnumType1AllOf.d); - } - - @Override - public int hashCode() { - return Objects.hash(d); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithEnumType1AllOf {\n"); - sb.append(" d: ").append(toIndentedString(d)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType2AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType2AllOf.java deleted file mode 100644 index dd95a64b..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithEnumType2AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithEnumType2AllOf - */ -@JsonPropertyOrder({ - InheritanceWithEnumType2AllOf.JSON_PROPERTY_E -}) -@JsonTypeName("InheritanceWithEnumType2_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithEnumType2AllOf { - public static final String JSON_PROPERTY_E = "e"; - private String e; - - public InheritanceWithEnumType2AllOf() { - } - - public InheritanceWithEnumType2AllOf e(String e) { - this.e = e; - return this; - } - - /** - * Get e - * @return e - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_E) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getE() { - return e; - } - - @JsonProperty(JSON_PROPERTY_E) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setE(String e) { - this.e = e; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithEnumType2AllOf inheritanceWithEnumType2AllOf = (InheritanceWithEnumType2AllOf) o; - return Objects.equals(this.e, inheritanceWithEnumType2AllOf.e); - } - - @Override - public int hashCode() { - return Objects.hash(e); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithEnumType2AllOf {\n"); - sb.append(" e: ").append(toIndentedString(e)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType1AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType1AllOf.java deleted file mode 100644 index 68cf163c..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType1AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithStringType1AllOf - */ -@JsonPropertyOrder({ - InheritanceWithStringType1AllOf.JSON_PROPERTY_B -}) -@JsonTypeName("InheritanceWithStringType1_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithStringType1AllOf { - public static final String JSON_PROPERTY_B = "b"; - private String b; - - public InheritanceWithStringType1AllOf() { - } - - public InheritanceWithStringType1AllOf b(String b) { - this.b = b; - return this; - } - - /** - * Get b - * @return b - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_B) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getB() { - return b; - } - - @JsonProperty(JSON_PROPERTY_B) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setB(String b) { - this.b = b; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithStringType1AllOf inheritanceWithStringType1AllOf = (InheritanceWithStringType1AllOf) o; - return Objects.equals(this.b, inheritanceWithStringType1AllOf.b); - } - - @Override - public int hashCode() { - return Objects.hash(b); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithStringType1AllOf {\n"); - sb.append(" b: ").append(toIndentedString(b)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType2AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType2AllOf.java deleted file mode 100644 index b537fa48..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithStringType2AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithStringType2AllOf - */ -@JsonPropertyOrder({ - InheritanceWithStringType2AllOf.JSON_PROPERTY_C -}) -@JsonTypeName("InheritanceWithStringType2_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithStringType2AllOf { - public static final String JSON_PROPERTY_C = "c"; - private String c; - - public InheritanceWithStringType2AllOf() { - } - - public InheritanceWithStringType2AllOf c(String c) { - this.c = c; - return this; - } - - /** - * Get c - * @return c - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_C) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getC() { - return c; - } - - @JsonProperty(JSON_PROPERTY_C) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setC(String c) { - this.c = c; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithStringType2AllOf inheritanceWithStringType2AllOf = (InheritanceWithStringType2AllOf) o; - return Objects.equals(this.c, inheritanceWithStringType2AllOf.c); - } - - @Override - public int hashCode() { - return Objects.hash(c); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithStringType2AllOf {\n"); - sb.append(" c: ").append(toIndentedString(c)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType1AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType1AllOf.java deleted file mode 100644 index aad8a2c5..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType1AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithoutType1AllOf - */ -@JsonPropertyOrder({ - InheritanceWithoutType1AllOf.JSON_PROPERTY_F -}) -@JsonTypeName("InheritanceWithoutType1_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithoutType1AllOf { - public static final String JSON_PROPERTY_F = "f"; - private String f; - - public InheritanceWithoutType1AllOf() { - } - - public InheritanceWithoutType1AllOf f(String f) { - this.f = f; - return this; - } - - /** - * Get f - * @return f - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_F) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getF() { - return f; - } - - @JsonProperty(JSON_PROPERTY_F) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setF(String f) { - this.f = f; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithoutType1AllOf inheritanceWithoutType1AllOf = (InheritanceWithoutType1AllOf) o; - return Objects.equals(this.f, inheritanceWithoutType1AllOf.f); - } - - @Override - public int hashCode() { - return Objects.hash(f); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithoutType1AllOf {\n"); - sb.append(" f: ").append(toIndentedString(f)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType2AllOf.java b/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType2AllOf.java deleted file mode 100644 index a68b3aa1..00000000 --- a/gen/main/java/testmodel/micronaut_java/InheritanceWithoutType2AllOf.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Spec for api tests. - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 1 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package testmodel.micronaut_java; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.*; - -import javax.validation.constraints.*; -import javax.validation.Valid; -import io.micronaut.core.annotation.*; -import javax.annotation.Generated; - -/** - * InheritanceWithoutType2AllOf - */ -@JsonPropertyOrder({ - InheritanceWithoutType2AllOf.JSON_PROPERTY_G -}) -@JsonTypeName("InheritanceWithoutType2_allOf") -@java.lang.SuppressWarnings("all") -@Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") -@Introspected -public class InheritanceWithoutType2AllOf { - public static final String JSON_PROPERTY_G = "g"; - private String g; - - public InheritanceWithoutType2AllOf() { - } - - public InheritanceWithoutType2AllOf g(String g) { - this.g = g; - return this; - } - - /** - * Get g - * @return g - **/ - @Nullable - @JsonProperty(JSON_PROPERTY_G) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getG() { - return g; - } - - @JsonProperty(JSON_PROPERTY_G) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setG(String g) { - this.g = g; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InheritanceWithoutType2AllOf inheritanceWithoutType2AllOf = (InheritanceWithoutType2AllOf) o; - return Objects.equals(this.g, inheritanceWithoutType2AllOf.g); - } - - @Override - public int hashCode() { - return Objects.hash(g); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InheritanceWithoutType2AllOf {\n"); - sb.append(" g: ").append(toIndentedString(g)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceExtended.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceExtended.java index fd94b762..57ab10ed 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceExtended.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceExtended.java @@ -2,9 +2,8 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceExtended { +public class InheritanceExtended implements InheritanceSimple { - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; public static final java.lang.String JSON_PROPERTY_BAR = "bar"; @jakarta.validation.constraints.NotNull diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceSimple.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceSimple.java index c3aeaef0..cad2549b 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceSimple.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceSimple.java @@ -1,58 +1,20 @@ package testmodel.micronaut_pojo; @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") -@io.micronaut.serde.annotation.Serdeable -public class InheritanceSimple { +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = InheritanceSimpleDefault.class) +public interface InheritanceSimple { + + java.lang.String JSON_PROPERTY_FOO = "foo"; + - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; @jakarta.validation.constraints.NotNull @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) - private java.lang.String foo; - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceSimple other = (InheritanceSimple) object; - return java.util.Objects.equals(foo, other.foo); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(foo); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceSimple[") - .append("foo=").append(foo) - .append("]") - .toString(); - } + java.lang.String getFoo(); - // fluent - - public InheritanceSimple foo(java.lang.String newFoo) { - this.foo = newFoo; - return this; - } - - // getter/setter - - public java.lang.String getFoo() { - return foo; - } - - public void setFoo(java.lang.String newFoo) { - this.foo = newFoo; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + void setFoo( + @jakarta.validation.constraints.NotNull + java.lang.String newFoo); } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceSimpleDefault.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceSimpleDefault.java new file mode 100644 index 00000000..bea403d6 --- /dev/null +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceSimpleDefault.java @@ -0,0 +1,56 @@ +package testmodel.micronaut_pojo; + +@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") +@io.micronaut.serde.annotation.Serdeable +public class InheritanceSimpleDefault implements InheritanceSimple { + + @jakarta.validation.constraints.NotNull + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) + private java.lang.String foo; + + // methods + + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } + if (object == null || getClass() != object.getClass()) { + return false; + } + InheritanceSimpleDefault other = (InheritanceSimpleDefault) object; + return java.util.Objects.equals(foo, other.foo); + } + + @Override + public int hashCode() { + return java.util.Objects.hash(foo); + } + + @Override + public java.lang.String toString() { + return new java.lang.StringBuilder() + .append("InheritanceSimpleDefault[") + .append("foo=").append(foo) + .append("]") + .toString(); + } + + // fluent + + public InheritanceSimpleDefault foo(java.lang.String newFoo) { + this.foo = newFoo; + return this; + } + + // getter/setter + + public java.lang.String getFoo() { + return foo; + } + + public void setFoo(java.lang.String newFoo) { + this.foo = newFoo; + } +} diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType.java index 9f832ff4..77f68196 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType.java @@ -7,42 +7,12 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType2.class, name = "Inheritance2"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType3.class, name = "Inheritance3") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithEnumType { +public interface InheritanceWithEnumType { - public static final java.lang.String JSON_DISCRIMINATOR = "type"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract InheritanceWithEnumTypeEnum getType(); + InheritanceWithEnumTypeEnum getType(); - // methods - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithEnumType other = (InheritanceWithEnumType) object; - return java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(getType()); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithEnumType[") - .append("]") - .toString(); - } - - // fluent - - // getter/setter } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType1.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType1.java index 0ffbed11..adfe8c69 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType1.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType1.java @@ -2,7 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType1 extends InheritanceWithEnumType { +public class InheritanceWithEnumType1 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_D = "d"; @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType1 other = (InheritanceWithEnumType1) object; - return java.util.Objects.equals(d, other.d) - && super.equals(object); + return java.util.Objects.equals(d, other.d); } @Override public int hashCode() { - return java.util.Objects.hash(d, super.hashCode()); + return java.util.Objects.hash(d); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType1[") - .append("super").append(super.toString()) .append("d=").append(d) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType2.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType2.java index 57dd745a..6d503086 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType2.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType2.java @@ -2,7 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType2 extends InheritanceWithEnumType { +public class InheritanceWithEnumType2 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_E = "e"; @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType2 other = (InheritanceWithEnumType2) object; - return java.util.Objects.equals(e, other.e) - && super.equals(object); + return java.util.Objects.equals(e, other.e); } @Override public int hashCode() { - return java.util.Objects.hash(e, super.hashCode()); + return java.util.Objects.hash(e); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType2[") - .append("super").append(super.toString()) .append("e=").append(e) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType3.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType3.java index 720764d2..9ccf4c16 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType3.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithEnumType3.java @@ -2,8 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType3 extends InheritanceWithEnumType { - +public class InheritanceWithEnumType3 implements InheritanceWithEnumType { @Override public InheritanceWithEnumTypeEnum getType() { @@ -32,7 +31,6 @@ public int hashCode() { public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType3[") - .append("super").append(super.toString()) .append("]") .toString(); } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType.java index 6889bc23..f236807b 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType.java @@ -6,62 +6,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType2.class, name = "Inheritance2") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithStringType { +public interface InheritanceWithStringType { - public static final java.lang.String JSON_PROPERTY_A = "a"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String a; + java.lang.String JSON_PROPERTY_A = "a"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithStringType other = (InheritanceWithStringType) object; - return java.util.Objects.equals(a, other.a) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(a, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithStringType[") - .append("a=").append(a) - .append("]") - .toString(); - } - // fluent - public InheritanceWithStringType a(java.lang.String newA) { - this.a = newA; - return this; - } - - // getter/setter - - public java.lang.String getA() { - return a; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getA(); - public void setA(java.lang.String newA) { - this.a = newA; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + void setA( + java.lang.String newA); } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType1.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType1.java index de97d60f..080e930f 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType1.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType1.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithStringType1 extends InheritanceWithStringType { +public class InheritanceWithStringType1 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_B = "b"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_B) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String b; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType1 other = (InheritanceWithStringType1) object; - return java.util.Objects.equals(b, other.b) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(b, other.b); } @Override public int hashCode() { - return java.util.Objects.hash(b, super.hashCode()); + return java.util.Objects.hash(a, b); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType1[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("b=").append(b) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType1 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType1 b(java.lang.String newB) { this.b = newB; return this; @@ -54,6 +63,14 @@ public InheritanceWithStringType1 b(java.lang.String newB) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getB() { return b; } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType2.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType2.java index 41e05f84..35d08200 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType2.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithStringType2.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithStringType2 extends InheritanceWithStringType { +public class InheritanceWithStringType2 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_C = "c"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_C) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String c; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType2 other = (InheritanceWithStringType2) object; - return java.util.Objects.equals(c, other.c) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(c, other.c); } @Override public int hashCode() { - return java.util.Objects.hash(c, super.hashCode()); + return java.util.Objects.hash(a, c); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType2[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("c=").append(c) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType2 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType2 c(java.lang.String newC) { this.c = newC; return this; @@ -54,6 +63,14 @@ public InheritanceWithStringType2 c(java.lang.String newC) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getC() { return c; } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType.java index 5c3ceaeb..b27a113f 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType.java @@ -6,62 +6,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType2.class, name = "Inheritance2") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithoutType { +public interface InheritanceWithoutType { - public static final java.lang.String JSON_PROPERTY_E = "e"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String e; + java.lang.String JSON_PROPERTY_E = "e"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithoutType other = (InheritanceWithoutType) object; - return java.util.Objects.equals(e, other.e) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(e, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithoutType[") - .append("e=").append(e) - .append("]") - .toString(); - } - // fluent - public InheritanceWithoutType e(java.lang.String newE) { - this.e = newE; - return this; - } - - // getter/setter - - public java.lang.String getE() { - return e; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getE(); - public void setE(java.lang.String newE) { - this.e = newE; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + void setE( + java.lang.String newE); } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType1.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType1.java index 42e6f85d..a4da6a82 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType1.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType1.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithoutType1 extends InheritanceWithoutType { +public class InheritanceWithoutType1 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_F = "f"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_F) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String f; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType1 other = (InheritanceWithoutType1) object; - return java.util.Objects.equals(f, other.f) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(f, other.f); } @Override public int hashCode() { - return java.util.Objects.hash(f, super.hashCode()); + return java.util.Objects.hash(e, f); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType1[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("f=").append(f) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType1 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType1 f(java.lang.String newF) { this.f = newF; return this; @@ -54,6 +63,14 @@ public InheritanceWithoutType1 f(java.lang.String newF) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getF() { return f; } diff --git a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType2.java b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType2.java index 9d66c529..e4b5c942 100644 --- a/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType2.java +++ b/gen/main/java/testmodel/micronaut_pojo/InheritanceWithoutType2.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithoutType2 extends InheritanceWithoutType { +public class InheritanceWithoutType2 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_G = "g"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_G) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String g; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType2 other = (InheritanceWithoutType2) object; - return java.util.Objects.equals(g, other.g) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(g, other.g); } @Override public int hashCode() { - return java.util.Objects.hash(g, super.hashCode()); + return java.util.Objects.hash(e, g); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType2[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("g=").append(g) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType2 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType2 g(java.lang.String newG) { this.g = newG; return this; @@ -54,6 +63,14 @@ public InheritanceWithoutType2 g(java.lang.String newG) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getG() { return g; } diff --git a/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor1.java b/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor1.java index 1c1e6760..349f19fe 100644 --- a/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor1.java +++ b/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor1.java @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor1 other = (OneOfImplementor1) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor1[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor2.java b/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor2.java index 0d9a3e39..bfcb1993 100644 --- a/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor2.java +++ b/gen/main/java/testmodel/micronaut_pojo/OneOfImplementor2.java @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor2 other = (OneOfImplementor2) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor2[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceExtended.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceExtended.java index 48aeaef9..d9837058 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceExtended.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceExtended.java @@ -2,9 +2,8 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceExtended { +public class InheritanceExtended implements InheritanceSimple { - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; public static final java.lang.String JSON_PROPERTY_BAR = "bar"; @jakarta.validation.constraints.NotNull diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimple.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimple.java index 0b4d587c..70f8b4bd 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimple.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimple.java @@ -1,58 +1,20 @@ package testmodel.micronaut_pojo_nullable; @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") -@io.micronaut.serde.annotation.Serdeable -public class InheritanceSimple { +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = InheritanceSimpleDefault.class) +public interface InheritanceSimple { + + java.lang.String JSON_PROPERTY_FOO = "foo"; + - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; @jakarta.validation.constraints.NotNull @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) - private java.lang.String foo; - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceSimple other = (InheritanceSimple) object; - return java.util.Objects.equals(foo, other.foo); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(foo); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceSimple[") - .append("foo=").append(foo) - .append("]") - .toString(); - } + java.lang.String getFoo(); - // fluent - - public InheritanceSimple foo(java.lang.String newFoo) { - this.foo = newFoo; - return this; - } - - // getter/setter - - public java.lang.String getFoo() { - return foo; - } - - public void setFoo(java.lang.String newFoo) { - this.foo = newFoo; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + void setFoo( + @jakarta.validation.constraints.NotNull + java.lang.String newFoo); } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimpleDefault.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimpleDefault.java new file mode 100644 index 00000000..b911f736 --- /dev/null +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceSimpleDefault.java @@ -0,0 +1,56 @@ +package testmodel.micronaut_pojo_nullable; + +@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") +@io.micronaut.serde.annotation.Serdeable +public class InheritanceSimpleDefault implements InheritanceSimple { + + @jakarta.validation.constraints.NotNull + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) + private java.lang.String foo; + + // methods + + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } + if (object == null || getClass() != object.getClass()) { + return false; + } + InheritanceSimpleDefault other = (InheritanceSimpleDefault) object; + return java.util.Objects.equals(foo, other.foo); + } + + @Override + public int hashCode() { + return java.util.Objects.hash(foo); + } + + @Override + public java.lang.String toString() { + return new java.lang.StringBuilder() + .append("InheritanceSimpleDefault[") + .append("foo=").append(foo) + .append("]") + .toString(); + } + + // fluent + + public InheritanceSimpleDefault foo(java.lang.String newFoo) { + this.foo = newFoo; + return this; + } + + // getter/setter + + public java.lang.String getFoo() { + return foo; + } + + public void setFoo(java.lang.String newFoo) { + this.foo = newFoo; + } +} diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType.java index 9ec82c97..164b119b 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType.java @@ -7,42 +7,12 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType2.class, name = "Inheritance2"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType3.class, name = "Inheritance3") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithEnumType { +public interface InheritanceWithEnumType { - public static final java.lang.String JSON_DISCRIMINATOR = "type"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract InheritanceWithEnumTypeEnum getType(); + InheritanceWithEnumTypeEnum getType(); - // methods - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithEnumType other = (InheritanceWithEnumType) object; - return java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(getType()); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithEnumType[") - .append("]") - .toString(); - } - - // fluent - - // getter/setter } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType1.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType1.java index 3f8b480e..53cc3d79 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType1.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType1.java @@ -2,7 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType1 extends InheritanceWithEnumType { +public class InheritanceWithEnumType1 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_D = "d"; @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType1 other = (InheritanceWithEnumType1) object; - return java.util.Objects.equals(d, other.d) - && super.equals(object); + return java.util.Objects.equals(d, other.d); } @Override public int hashCode() { - return java.util.Objects.hash(d, super.hashCode()); + return java.util.Objects.hash(d); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType1[") - .append("super").append(super.toString()) .append("d=").append(d) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType2.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType2.java index 9b8a70de..760954ce 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType2.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType2.java @@ -2,7 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType2 extends InheritanceWithEnumType { +public class InheritanceWithEnumType2 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_E = "e"; @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType2 other = (InheritanceWithEnumType2) object; - return java.util.Objects.equals(e, other.e) - && super.equals(object); + return java.util.Objects.equals(e, other.e); } @Override public int hashCode() { - return java.util.Objects.hash(e, super.hashCode()); + return java.util.Objects.hash(e); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType2[") - .append("super").append(super.toString()) .append("e=").append(e) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType3.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType3.java index e549d667..daae7d5c 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType3.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithEnumType3.java @@ -2,8 +2,7 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithEnumType3 extends InheritanceWithEnumType { - +public class InheritanceWithEnumType3 implements InheritanceWithEnumType { @Override public InheritanceWithEnumTypeEnum getType() { @@ -32,7 +31,6 @@ public int hashCode() { public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType3[") - .append("super").append(super.toString()) .append("]") .toString(); } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType.java index a28404de..9c0981ab 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType.java @@ -6,62 +6,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType2.class, name = "Inheritance2") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithStringType { +public interface InheritanceWithStringType { - public static final java.lang.String JSON_PROPERTY_A = "a"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String a; + java.lang.String JSON_PROPERTY_A = "a"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithStringType other = (InheritanceWithStringType) object; - return java.util.Objects.equals(a, other.a) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(a, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithStringType[") - .append("a=").append(a) - .append("]") - .toString(); - } - // fluent - public InheritanceWithStringType a(java.lang.String newA) { - this.a = newA; - return this; - } - - // getter/setter - - public java.lang.String getA() { - return a; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getA(); - public void setA(java.lang.String newA) { - this.a = newA; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + void setA( + java.lang.String newA); } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType1.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType1.java index a60e8f52..05702f6f 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType1.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType1.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithStringType1 extends InheritanceWithStringType { +public class InheritanceWithStringType1 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_B = "b"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_B) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String b; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType1 other = (InheritanceWithStringType1) object; - return java.util.Objects.equals(b, other.b) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(b, other.b); } @Override public int hashCode() { - return java.util.Objects.hash(b, super.hashCode()); + return java.util.Objects.hash(a, b); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType1[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("b=").append(b) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType1 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType1 b(java.lang.String newB) { this.b = newB; return this; @@ -54,6 +63,14 @@ public InheritanceWithStringType1 b(java.lang.String newB) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getB() { return b; } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType2.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType2.java index 6ff32358..5584f9f2 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType2.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithStringType2.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithStringType2 extends InheritanceWithStringType { +public class InheritanceWithStringType2 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_C = "c"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_C) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String c; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType2 other = (InheritanceWithStringType2) object; - return java.util.Objects.equals(c, other.c) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(c, other.c); } @Override public int hashCode() { - return java.util.Objects.hash(c, super.hashCode()); + return java.util.Objects.hash(a, c); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType2[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("c=").append(c) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType2 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType2 c(java.lang.String newC) { this.c = newC; return this; @@ -54,6 +63,14 @@ public InheritanceWithStringType2 c(java.lang.String newC) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getC() { return c; } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType.java index 9cd6db1b..d04cf506 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType.java @@ -6,62 +6,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType2.class, name = "Inheritance2") }) -@io.micronaut.serde.annotation.Serdeable -public abstract class InheritanceWithoutType { +public interface InheritanceWithoutType { - public static final java.lang.String JSON_PROPERTY_E = "e"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String e; + java.lang.String JSON_PROPERTY_E = "e"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithoutType other = (InheritanceWithoutType) object; - return java.util.Objects.equals(e, other.e) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(e, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithoutType[") - .append("e=").append(e) - .append("]") - .toString(); - } - // fluent - public InheritanceWithoutType e(java.lang.String newE) { - this.e = newE; - return this; - } - - // getter/setter - - public java.lang.String getE() { - return e; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getE(); - public void setE(java.lang.String newE) { - this.e = newE; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + void setE( + java.lang.String newE); } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType1.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType1.java index d94e90db..644b84eb 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType1.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType1.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithoutType1 extends InheritanceWithoutType { +public class InheritanceWithoutType1 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_F = "f"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_F) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String f; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType1 other = (InheritanceWithoutType1) object; - return java.util.Objects.equals(f, other.f) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(f, other.f); } @Override public int hashCode() { - return java.util.Objects.hash(f, super.hashCode()); + return java.util.Objects.hash(e, f); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType1[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("f=").append(f) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType1 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType1 f(java.lang.String newF) { this.f = newF; return this; @@ -54,6 +63,14 @@ public InheritanceWithoutType1 f(java.lang.String newF) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getF() { return f; } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType2.java b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType2.java index 5a2a056a..27bbf6d7 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType2.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/InheritanceWithoutType2.java @@ -2,10 +2,14 @@ @jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen") @io.micronaut.serde.annotation.Serdeable -public class InheritanceWithoutType2 extends InheritanceWithoutType { +public class InheritanceWithoutType2 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_G = "g"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_G) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String g; @@ -26,20 +30,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType2 other = (InheritanceWithoutType2) object; - return java.util.Objects.equals(g, other.g) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(g, other.g); } @Override public int hashCode() { - return java.util.Objects.hash(g, super.hashCode()); + return java.util.Objects.hash(e, g); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType2[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("g=").append(g) .append("]") .toString(); @@ -47,6 +51,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType2 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType2 g(java.lang.String newG) { this.g = newG; return this; @@ -54,6 +63,14 @@ public InheritanceWithoutType2 g(java.lang.String newG) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getG() { return g; } diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor1.java b/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor1.java index 688aa0f4..4ec30bdf 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor1.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor1.java @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor1 other = (OneOfImplementor1) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor1[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor2.java b/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor2.java index 32114c4d..4df71c28 100644 --- a/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor2.java +++ b/gen/main/java/testmodel/micronaut_pojo_nullable/OneOfImplementor2.java @@ -26,20 +26,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor2 other = (OneOfImplementor2) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor2[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceExtended.java b/gen/main/java/testmodel/nomicronaut/InheritanceExtended.java index ac30309a..e08e4f1c 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceExtended.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceExtended.java @@ -1,8 +1,7 @@ package testmodel.nomicronaut; -public class InheritanceExtended { +public class InheritanceExtended implements InheritanceSimple { - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; public static final java.lang.String JSON_PROPERTY_BAR = "bar"; @jakarta.validation.constraints.NotNull diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceSimple.java b/gen/main/java/testmodel/nomicronaut/InheritanceSimple.java index 05eddcfd..e52234f4 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceSimple.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceSimple.java @@ -1,56 +1,19 @@ package testmodel.nomicronaut; -public class InheritanceSimple { +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = InheritanceSimpleDefault.class) +public interface InheritanceSimple { + + java.lang.String JSON_PROPERTY_FOO = "foo"; + - public static final java.lang.String JSON_PROPERTY_FOO = "foo"; @jakarta.validation.constraints.NotNull @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) - private java.lang.String foo; - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceSimple other = (InheritanceSimple) object; - return java.util.Objects.equals(foo, other.foo); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(foo); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceSimple[") - .append("foo=").append(foo) - .append("]") - .toString(); - } + java.lang.String getFoo(); - // fluent - - public InheritanceSimple foo(java.lang.String newFoo) { - this.foo = newFoo; - return this; - } - - // getter/setter - - public java.lang.String getFoo() { - return foo; - } - - public void setFoo(java.lang.String newFoo) { - this.foo = newFoo; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + void setFoo( + @jakarta.validation.constraints.NotNull + java.lang.String newFoo); } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceSimpleDefault.java b/gen/main/java/testmodel/nomicronaut/InheritanceSimpleDefault.java new file mode 100644 index 00000000..22de3387 --- /dev/null +++ b/gen/main/java/testmodel/nomicronaut/InheritanceSimpleDefault.java @@ -0,0 +1,54 @@ +package testmodel.nomicronaut; + +public class InheritanceSimpleDefault implements InheritanceSimple { + + @jakarta.validation.constraints.NotNull + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS) + private java.lang.String foo; + + // methods + + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } + if (object == null || getClass() != object.getClass()) { + return false; + } + InheritanceSimpleDefault other = (InheritanceSimpleDefault) object; + return java.util.Objects.equals(foo, other.foo); + } + + @Override + public int hashCode() { + return java.util.Objects.hash(foo); + } + + @Override + public java.lang.String toString() { + return new java.lang.StringBuilder() + .append("InheritanceSimpleDefault[") + .append("foo=").append(foo) + .append("]") + .toString(); + } + + // fluent + + public InheritanceSimpleDefault foo(java.lang.String newFoo) { + this.foo = newFoo; + return this; + } + + // getter/setter + + public java.lang.String getFoo() { + return foo; + } + + public void setFoo(java.lang.String newFoo) { + this.foo = newFoo; + } +} diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType.java index d66eae7e..17be6b0d 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType.java @@ -6,41 +6,12 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType2.class, name = "Inheritance2"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType3.class, name = "Inheritance3") }) -public abstract class InheritanceWithEnumType { +public interface InheritanceWithEnumType { - public static final java.lang.String JSON_DISCRIMINATOR = "type"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract InheritanceWithEnumTypeEnum getType(); + InheritanceWithEnumTypeEnum getType(); - // methods - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithEnumType other = (InheritanceWithEnumType) object; - return java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(getType()); - } - - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithEnumType[") - .append("]") - .toString(); - } - - // fluent - - // getter/setter } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType1.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType1.java index 968a8386..b07fc438 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType1.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType1.java @@ -1,6 +1,6 @@ package testmodel.nomicronaut; -public class InheritanceWithEnumType1 extends InheritanceWithEnumType { +public class InheritanceWithEnumType1 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_D = "d"; @@ -24,20 +24,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType1 other = (InheritanceWithEnumType1) object; - return java.util.Objects.equals(d, other.d) - && super.equals(object); + return java.util.Objects.equals(d, other.d); } @Override public int hashCode() { - return java.util.Objects.hash(d, super.hashCode()); + return java.util.Objects.hash(d); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType1[") - .append("super").append(super.toString()) .append("d=").append(d) .append("]") .toString(); diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType2.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType2.java index 3da555ad..10e9d90f 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType2.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType2.java @@ -1,6 +1,6 @@ package testmodel.nomicronaut; -public class InheritanceWithEnumType2 extends InheritanceWithEnumType { +public class InheritanceWithEnumType2 implements InheritanceWithEnumType { public static final java.lang.String JSON_PROPERTY_E = "e"; @@ -24,20 +24,18 @@ public boolean equals(Object object) { return false; } InheritanceWithEnumType2 other = (InheritanceWithEnumType2) object; - return java.util.Objects.equals(e, other.e) - && super.equals(object); + return java.util.Objects.equals(e, other.e); } @Override public int hashCode() { - return java.util.Objects.hash(e, super.hashCode()); + return java.util.Objects.hash(e); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType2[") - .append("super").append(super.toString()) .append("e=").append(e) .append("]") .toString(); diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType3.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType3.java index 29be003b..026d3be8 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType3.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithEnumType3.java @@ -1,7 +1,6 @@ package testmodel.nomicronaut; -public class InheritanceWithEnumType3 extends InheritanceWithEnumType { - +public class InheritanceWithEnumType3 implements InheritanceWithEnumType { @Override public InheritanceWithEnumTypeEnum getType() { @@ -30,7 +29,6 @@ public int hashCode() { public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithEnumType3[") - .append("super").append(super.toString()) .append("]") .toString(); } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType.java index cce890c9..ac61ea57 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType.java @@ -5,61 +5,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType2.class, name = "Inheritance2") }) -public abstract class InheritanceWithStringType { +public interface InheritanceWithStringType { - public static final java.lang.String JSON_PROPERTY_A = "a"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String a; + java.lang.String JSON_PROPERTY_A = "a"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithStringType other = (InheritanceWithStringType) object; - return java.util.Objects.equals(a, other.a) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(a, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithStringType[") - .append("a=").append(a) - .append("]") - .toString(); - } - // fluent - public InheritanceWithStringType a(java.lang.String newA) { - this.a = newA; - return this; - } - - // getter/setter - - public java.lang.String getA() { - return a; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getA(); - public void setA(java.lang.String newA) { - this.a = newA; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + void setA( + java.lang.String newA); } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType1.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType1.java index 0e8dfe6b..4b433e73 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType1.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType1.java @@ -1,9 +1,13 @@ package testmodel.nomicronaut; -public class InheritanceWithStringType1 extends InheritanceWithStringType { +public class InheritanceWithStringType1 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_B = "b"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_B) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String b; @@ -24,20 +28,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType1 other = (InheritanceWithStringType1) object; - return java.util.Objects.equals(b, other.b) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(b, other.b); } @Override public int hashCode() { - return java.util.Objects.hash(b, super.hashCode()); + return java.util.Objects.hash(a, b); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType1[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("b=").append(b) .append("]") .toString(); @@ -45,6 +49,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType1 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType1 b(java.lang.String newB) { this.b = newB; return this; @@ -52,6 +61,14 @@ public InheritanceWithStringType1 b(java.lang.String newB) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getB() { return b; } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType2.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType2.java index 681dca4b..14998deb 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType2.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithStringType2.java @@ -1,9 +1,13 @@ package testmodel.nomicronaut; -public class InheritanceWithStringType2 extends InheritanceWithStringType { +public class InheritanceWithStringType2 implements InheritanceWithStringType { public static final java.lang.String JSON_PROPERTY_C = "c"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_A) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String a; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_C) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String c; @@ -24,20 +28,20 @@ public boolean equals(Object object) { return false; } InheritanceWithStringType2 other = (InheritanceWithStringType2) object; - return java.util.Objects.equals(c, other.c) - && super.equals(object); + return java.util.Objects.equals(a, other.a) + && java.util.Objects.equals(c, other.c); } @Override public int hashCode() { - return java.util.Objects.hash(c, super.hashCode()); + return java.util.Objects.hash(a, c); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithStringType2[") - .append("super").append(super.toString()) + .append("a=").append(a).append(",") .append("c=").append(c) .append("]") .toString(); @@ -45,6 +49,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithStringType2 a(java.lang.String newA) { + this.a = newA; + return this; + } + public InheritanceWithStringType2 c(java.lang.String newC) { this.c = newC; return this; @@ -52,6 +61,14 @@ public InheritanceWithStringType2 c(java.lang.String newC) { // getter/setter + public java.lang.String getA() { + return a; + } + + public void setA(java.lang.String newA) { + this.a = newA; + } + public java.lang.String getC() { return c; } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType.java index 92232b93..f04f63d4 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType.java @@ -5,61 +5,21 @@ @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType1.class, name = "Inheritance1"), @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType2.class, name = "Inheritance2") }) -public abstract class InheritanceWithoutType { +public interface InheritanceWithoutType { - public static final java.lang.String JSON_PROPERTY_E = "e"; - public static final java.lang.String JSON_DISCRIMINATOR = "type"; - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) - @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) - private java.lang.String e; + java.lang.String JSON_PROPERTY_E = "e"; + java.lang.String JSON_DISCRIMINATOR = "type"; @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - public abstract java.lang.String getType(); - - // methods - - @Override - public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - InheritanceWithoutType other = (InheritanceWithoutType) object; - return java.util.Objects.equals(e, other.e) - && java.util.Objects.equals(getType(), other.getType()); - } - - @Override - public int hashCode() { - return java.util.Objects.hash(e, getType()); - } + java.lang.String getType(); - @Override - public java.lang.String toString() { - return new java.lang.StringBuilder() - .append("InheritanceWithoutType[") - .append("e=").append(e) - .append("]") - .toString(); - } - // fluent - public InheritanceWithoutType e(java.lang.String newE) { - this.e = newE; - return this; - } - - // getter/setter - - public java.lang.String getE() { - return e; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + java.lang.String getE(); - public void setE(java.lang.String newE) { - this.e = newE; - } + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + void setE( + java.lang.String newE); } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType1.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType1.java index c4a02c1b..91dbbb66 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType1.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType1.java @@ -1,9 +1,13 @@ package testmodel.nomicronaut; -public class InheritanceWithoutType1 extends InheritanceWithoutType { +public class InheritanceWithoutType1 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_F = "f"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_F) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String f; @@ -24,20 +28,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType1 other = (InheritanceWithoutType1) object; - return java.util.Objects.equals(f, other.f) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(f, other.f); } @Override public int hashCode() { - return java.util.Objects.hash(f, super.hashCode()); + return java.util.Objects.hash(e, f); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType1[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("f=").append(f) .append("]") .toString(); @@ -45,6 +49,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType1 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType1 f(java.lang.String newF) { this.f = newF; return this; @@ -52,6 +61,14 @@ public InheritanceWithoutType1 f(java.lang.String newF) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getF() { return f; } diff --git a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType2.java b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType2.java index 56d7f51e..ef8d0b62 100644 --- a/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType2.java +++ b/gen/main/java/testmodel/nomicronaut/InheritanceWithoutType2.java @@ -1,9 +1,13 @@ package testmodel.nomicronaut; -public class InheritanceWithoutType2 extends InheritanceWithoutType { +public class InheritanceWithoutType2 implements InheritanceWithoutType { public static final java.lang.String JSON_PROPERTY_G = "g"; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_E) + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + private java.lang.String e; + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_G) @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) private java.lang.String g; @@ -24,20 +28,20 @@ public boolean equals(Object object) { return false; } InheritanceWithoutType2 other = (InheritanceWithoutType2) object; - return java.util.Objects.equals(g, other.g) - && super.equals(object); + return java.util.Objects.equals(e, other.e) + && java.util.Objects.equals(g, other.g); } @Override public int hashCode() { - return java.util.Objects.hash(g, super.hashCode()); + return java.util.Objects.hash(e, g); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("InheritanceWithoutType2[") - .append("super").append(super.toString()) + .append("e=").append(e).append(",") .append("g=").append(g) .append("]") .toString(); @@ -45,6 +49,11 @@ public java.lang.String toString() { // fluent + public InheritanceWithoutType2 e(java.lang.String newE) { + this.e = newE; + return this; + } + public InheritanceWithoutType2 g(java.lang.String newG) { this.g = newG; return this; @@ -52,6 +61,14 @@ public InheritanceWithoutType2 g(java.lang.String newG) { // getter/setter + public java.lang.String getE() { + return e; + } + + public void setE(java.lang.String newE) { + this.e = newE; + } + public java.lang.String getG() { return g; } diff --git a/gen/main/java/testmodel/nomicronaut/OneOfImplementor1.java b/gen/main/java/testmodel/nomicronaut/OneOfImplementor1.java index d4cec238..20845b42 100644 --- a/gen/main/java/testmodel/nomicronaut/OneOfImplementor1.java +++ b/gen/main/java/testmodel/nomicronaut/OneOfImplementor1.java @@ -24,20 +24,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor1 other = (OneOfImplementor1) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor1[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/main/java/testmodel/nomicronaut/OneOfImplementor2.java b/gen/main/java/testmodel/nomicronaut/OneOfImplementor2.java index f2582f57..f27daf99 100644 --- a/gen/main/java/testmodel/nomicronaut/OneOfImplementor2.java +++ b/gen/main/java/testmodel/nomicronaut/OneOfImplementor2.java @@ -24,20 +24,18 @@ public boolean equals(Object object) { return false; } OneOfImplementor2 other = (OneOfImplementor2) object; - return java.util.Objects.equals(property, other.property) - && super.equals(object); + return java.util.Objects.equals(property, other.property); } @Override public int hashCode() { - return java.util.Objects.hash(property, super.hashCode()); + return java.util.Objects.hash(property); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() .append("OneOfImplementor2[") - .append("super").append(super.toString()) .append("property=").append(property) .append("]") .toString(); diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceSimpleDefaultTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleDefaultTestExample.java new file mode 100644 index 00000000..6eb7a4af --- /dev/null +++ b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleDefaultTestExample.java @@ -0,0 +1,10 @@ +package testmodel.nomicronaut; + +public class InheritanceSimpleDefaultTestExample { + + public static InheritanceSimpleDefault build() { + InheritanceSimpleDefault exampleInstance = new InheritanceSimpleDefault(); + exampleInstance.setFoo("string"); + return exampleInstance; + } +} diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java index 17f3ccdd..5cbe20d6 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java @@ -3,8 +3,6 @@ public class InheritanceSimpleTestExample { public static InheritanceSimple build() { - InheritanceSimple exampleInstance = new InheritanceSimple(); - exampleInstance.setFoo("string"); - return exampleInstance; + return InheritanceExtendedTestExample.build(); } } diff --git a/src/it/test-model-additional-properties/pom.xml b/src/it/test-model-additional-properties/pom.xml index 1b0f23f6..a5cf2d71 100644 --- a/src/it/test-model-additional-properties/pom.xml +++ b/src/it/test-model-additional-properties/pom.xml @@ -17,6 +17,10 @@ com.fasterxml.jackson.core jackson-annotations + + com.fasterxml.jackson.core + jackson-databind + diff --git a/src/it/test-model-one-of-interfaces/pom.xml b/src/it/test-model-one-of-interfaces/pom.xml index e14c8cd8..3e0b26ef 100644 --- a/src/it/test-model-one-of-interfaces/pom.xml +++ b/src/it/test-model-one-of-interfaces/pom.xml @@ -17,6 +17,10 @@ com.fasterxml.jackson.core jackson-annotations + + com.fasterxml.jackson.core + jackson-databind + diff --git a/src/it/test-model-only-jackson-without-nullable/pom.xml b/src/it/test-model-only-jackson-without-nullable/pom.xml index 8747c3ce..47a481d8 100644 --- a/src/it/test-model-only-jackson-without-nullable/pom.xml +++ b/src/it/test-model-only-jackson-without-nullable/pom.xml @@ -17,6 +17,10 @@ com.fasterxml.jackson.core jackson-annotations + + com.fasterxml.jackson.core + jackson-databind + diff --git a/src/main/java/org/openapitools/codegen/languages/MicronautCodegen.java b/src/main/java/org/openapitools/codegen/languages/MicronautCodegen.java index 7ef7daf5..9df17bf3 100644 --- a/src/main/java/org/openapitools/codegen/languages/MicronautCodegen.java +++ b/src/main/java/org/openapitools/codegen/languages/MicronautCodegen.java @@ -6,6 +6,9 @@ import static org.openapitools.codegen.CodegenConstants.SOURCE_FOLDER_DESC; import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -24,6 +27,7 @@ import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.OptionalFeatures; import org.openapitools.codegen.languages.features.UseGenericResponseFeatures; +import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.StringUtils; @@ -431,6 +435,57 @@ public Map updateAllModels(Map objs) { "valueType", model.getAdditionalProperties().getDataType())); } + // oneOf handling + + if (model.oneOf != null && !model.oneOf.isEmpty()) { + model.children = model.oneOf.stream().map(allModels::get).collect(Collectors.toList()); + model.hasChildren = true; + model.interfaceModels.removeAll(model.children); + for (var child : model.children) { + if (child.interfaceModels == null) { + child.interfaceModels = new ArrayList<>(); + } + child.interfaceModels.add(model); + } + model.allVars = new ArrayList<>(); + model.vars = new ArrayList<>(); + model.hasVars = false; + } + + // model all parents as interfaces + + model.parent = null; + model.parentModel = null; + model.parentSchema = null; + model.parentVars = List.of(); + model.allParents = List.of(); + if (model.interfaceModels != null) { + for (var interfaceModel : model.interfaceModels) { + + // add missing children + if (interfaceModel.children == null) { + interfaceModel.children = new ArrayList<>(); + } + if (!interfaceModel.children.contains(model)) { + LOG.debug("Add model " + model.name + " as children to " + interfaceModel.name + "."); + interfaceModel.children.add(model); + interfaceModel.hasChildren = true; + } + + // strip parent vars from vars + model.vars.removeIf(property -> { + var remove = interfaceModel.allVars.stream() + .map(CodegenProperty::getBaseName) + .anyMatch(property.getBaseName()::equals); + if (remove) { + LOG.debug("Remove property " + property.getBaseName() + " from " + model.name + + " because already present on " + interfaceModel.name + "."); + } + return remove; + }); + } + } + // handle discriminator var discriminator = model.discriminator; @@ -457,11 +512,6 @@ public Map updateAllModels(Map objs) { model.name, discriminator.getPropertyName(), mappedModel.getModelName()); continue; } - if (subModel.parentModel == null) { - subModel.parentModel = model; - subModel.parent = model.getClassname(); - LOG.warn("{} added missing sub model {}", model.name, subModel.name); - } subModel.vars.removeIf(property -> property.getName().equals(discriminator.getPropertyName())); subModel.allVars.removeIf(property -> property.getName().equals(discriminator.getPropertyName())); @@ -477,6 +527,32 @@ public Map updateAllModels(Map objs) { } } + // add default classes + + for (var model : allModels.values()) { + if (model.hasChildren && model.discriminator == null && model.oneOf.isEmpty()) { + + var suffix = "Default"; + var copy = copy(model); + copy.name = model.name + suffix; + copy.classname = model.classname + suffix; + copy.classFilename = model.classFilename + suffix; + copy.children = null; + copy.hasChildren = false; + copy.interfaces = List.of(model.name); + copy.interfaceModels = List.of(model); + copy.vars = List.of(); + copy.hasVars = false; + + var obj = new ModelsMap(); + obj.putAll(superObjs.get(model.name)); + obj.put("classname", copy.classname); + obj.setModels(List.of(new ModelMap(Map.of("model", copy)))); + superObjs.put(model.name + "Default", obj); + } + + } + return superObjs; } @@ -660,4 +736,89 @@ private void addSupportingFile(String folder, String packageString, String file) supportingFiles.add(supportingFile); } } + + private CodegenModel copy(CodegenModel model) { + var copy = new CodegenModel(); + + copy.additionalPropertiesType = model.additionalPropertiesType; + copy.allMandatory = model.allMandatory == null ? null : new HashSet<>(model.allMandatory); + copy.allOf = model.allOf == null ? null : new HashSet<>(model.allOf); + copy.allowableValues = model.allowableValues == null ? null : Map.copyOf(model.allowableValues); + copy.allParents = model.allParents == null ? null : new ArrayList<>(model.allParents); + copy.allVars = model.allVars == null ? null : new ArrayList<>(model.allVars); + copy.anyOf = model.anyOf == null ? null : new HashSet<>(model.anyOf); + copy.arrayModelType = model.arrayModelType; + copy.children = model.children == null ? null : new ArrayList<>(model.children); + copy.classFilename = model.classFilename; + copy.classname = model.classname; + copy.classVarName = model.classVarName; + copy.dataType = model.dataType; + copy.defaultValue = model.defaultValue; + copy.description = model.description; + copy.discriminator = model.discriminator; + copy.emptyVars = model.emptyVars; + copy.externalDocumentation = model.externalDocumentation; + copy.hasChildren = model.hasChildren; + copy.hasEnums = model.hasEnums; + copy.hasMoreModels = model.hasMoreModels; + copy.hasOnlyReadOnly = model.hasOnlyReadOnly; + copy.hasOptional = model.hasOptional; + copy.hasRequired = model.hasRequired; + copy.hasValidation = model.hasValidation; + copy.hasVars = model.hasVars; + copy.imports = model.imports == null ? null : new HashSet<>(model.imports); + copy.interfaceModels = model.interfaceModels == null ? null : new ArrayList<>(model.interfaceModels); + copy.interfaces = model.interfaces == null ? null : new ArrayList<>(model.interfaces); + copy.isAdditionalPropertiesTrue = model.isAdditionalPropertiesTrue; + copy.isAlias = model.isAdditionalPropertiesTrue; + copy.isArray = model.isAdditionalPropertiesTrue; + copy.isBoolean = model.isAdditionalPropertiesTrue; + copy.isDate = model.isAdditionalPropertiesTrue; + copy.isDateTime = model.isAdditionalPropertiesTrue; + copy.isDecimal = model.isAdditionalPropertiesTrue; + copy.isDeprecated = model.isAdditionalPropertiesTrue; + copy.isDouble = model.isAdditionalPropertiesTrue; + copy.isEnum = model.isAdditionalPropertiesTrue; + copy.isFloat = model.isAdditionalPropertiesTrue; + copy.isInteger = model.isAdditionalPropertiesTrue; + copy.isLong = model.isAdditionalPropertiesTrue; + copy.isMap = model.isAdditionalPropertiesTrue; + copy.isNull = model.isAdditionalPropertiesTrue; + copy.isNullable = model.isAdditionalPropertiesTrue; + copy.isNumber = model.isAdditionalPropertiesTrue; + copy.isNumeric = model.isAdditionalPropertiesTrue; + copy.isPrimitiveType = model.isAdditionalPropertiesTrue; + copy.isShort = model.isAdditionalPropertiesTrue; + copy.isString = model.isAdditionalPropertiesTrue; + copy.isUnboundedInteger = model.isAdditionalPropertiesTrue; + copy.isVoid = model.isAdditionalPropertiesTrue; + copy.mandatory = model.mandatory; + copy.modelJson = model.modelJson; + copy.name = model.name; + copy.nonNullableVars = model.nonNullableVars == null ? null : new ArrayList<>(model.nonNullableVars); + copy.oneOf = model.oneOf == null ? null : new HashSet<>(model.oneOf); + copy.optionalVars = model.optionalVars == null ? null : new ArrayList<>(model.optionalVars); + copy.parent = model.parent; + copy.parentModel = model.parentModel; + copy.parentRequiredVars = model.parentRequiredVars == null ? null : new ArrayList<>(model.parentRequiredVars); + copy.parentSchema = model.parentSchema; + copy.parentVars = model.parentVars == null ? null : new ArrayList<>(model.parentVars); + copy.readOnlyVars = model.readOnlyVars == null ? null : new ArrayList<>(model.readOnlyVars); + copy.readWriteVars = model.readWriteVars == null ? null : new ArrayList<>(model.readWriteVars); + copy.requiredVars = model.requiredVars == null ? null : new ArrayList<>(model.requiredVars); + copy.testCases = model.testCases == null ? null : new HashMap<>(model.testCases); + copy.title = model.title; + copy.unescapedDescription = model.unescapedDescription; + copy.vars = model.vars == null ? null : new ArrayList<>(model.vars); + copy.vendorExtensions = model.vendorExtensions == null ? null : new HashMap<>(model.vendorExtensions); + copy.xmlName = model.xmlName; + copy.xmlNamespace = model.xmlNamespace; + copy.xmlPrefix = model.xmlPrefix; + + copy.setIsAnyType(model.getIsAnyType()); + copy.setIsModel(model.getIsModel()); + copy.setIsUuid(model.getIsUuid()); + + return copy; + } } diff --git a/src/main/resources/Micronaut/model.mustache b/src/main/resources/Micronaut/model.mustache index ee958971..3aa485b3 100644 --- a/src/main/resources/Micronaut/model.mustache +++ b/src/main/resources/Micronaut/model.mustache @@ -3,6 +3,6 @@ package {{package}}; {{#description}}/** * {{description}} **/ -{{/description}}{{>generated}}{{#models}}{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelPojo}}{{/isEnum}} +{{/description}}{{>generated}}{{#models}}{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#hasChildren}}{{>modelInterface}}{{/hasChildren}}{{^hasChildren}}{{>modelPojo}}{{/hasChildren}}{{/isEnum}} {{/model}} {{/models}} diff --git a/src/main/resources/Micronaut/modelInterface.mustache b/src/main/resources/Micronaut/modelInterface.mustache new file mode 100644 index 00000000..8f20c81c --- /dev/null +++ b/src/main/resources/Micronaut/modelInterface.mustache @@ -0,0 +1,56 @@ +{{^vendorExtensions.x-is-one-of-interface}}{{#discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.EXISTING_PROPERTY, property = {{classname}}.JSON_DISCRIMINATOR) +@com.fasterxml.jackson.annotation.JsonSubTypes({ + {{#discriminator.mappedModels}} + @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"){{^-last}},{{/-last}} + {{/discriminator.mappedModels}} +}) +{{/discriminator}}{{^discriminator}}@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = {{classname}}Default.class) +{{/discriminator}} +public interface {{classname}}{{#interfaces}}{{#-first}} extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/interfaces}} { + +{{#vars}} + java.lang.String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}"; +{{/vars}}{{#discriminator}} java.lang.String JSON_DISCRIMINATOR = "{{propertyBaseName}}"; +{{/discriminator}} + +{{#discriminator}} @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) + {{discriminator.propertyType}} {{discriminator.propertyGetter}}(); + +{{/discriminator}}{{#vendorExtensions.additionalPropertiesMap}} + @com.fasterxml.jackson.annotation.JsonAnyGetter + java.util.Map<{{{vendorExtensions.additionalPropertiesMap.keyType}}}, {{{vendorExtensions.additionalPropertiesMap.valueType}}}> getAdditionalProperties(); + + @com.fasterxml.jackson.annotation.JsonAnySetter + void setAdditionalProperties({{{vendorExtensions.additionalPropertiesMap.keyType}}} propertyKey,{{{vendorExtensions.additionalPropertiesMap.valueType}}} value); +{{/vendorExtensions.additionalPropertiesMap}}{{#hasVars}}{{#vars}} + +{{#description}} /** {{description}} */ +{{/description}}{{#useBeanValidation}}{{>modelPropertyValidation}}{{/useBeanValidation}}{{>modelPropertyJackson}} + {{>modelPropertyType}} {{getter}}(); + + @com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}) + void {{setter}}( + {{#useBeanValidation}}{{>modelPropertyValidation}} {{/useBeanValidation}}{{>modelPropertyType}} new{{nameInCamelCase}});{{/vars}}{{#vars}}{{#isEnum}} + +{{>modelEnum}}{{/isEnum}}{{/vars}}{{/hasVars}} +}{{/vendorExtensions.x-is-one-of-interface}}{{#vendorExtensions.x-is-one-of-interface}}{{^discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.DEDUCTION, visible = true) +@com.fasterxml.jackson.annotation.JsonSubTypes({ + {{#oneOf}} + @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{{.}}}.class){{^-last}},{{/-last}} + {{/oneOf}} +}) +{{/discriminator}}{{#discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.EXISTING_PROPERTY, property = {{classname}}.JSON_DISCRIMINATOR) +@com.fasterxml.jackson.annotation.JsonSubTypes({ + {{#discriminator.mappedModels}} + @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), + {{/discriminator.mappedModels}} +}) +{{/discriminator}} +public interface {{classname}}{{#vendorExtensions.x-implements}}{{#-first}} extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}}{{^discriminator}} {}{{/discriminator}}{{#discriminator}} { +{{#discriminator}} + + java.lang.String JSON_DISCRIMINATOR = "{{propertyBaseName}}";{{/discriminator}} + + @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) + {{discriminator.propertyType}} {{discriminator.propertyGetter}}(); +}{{/discriminator}}{{/vendorExtensions.x-is-one-of-interface}} \ No newline at end of file diff --git a/src/main/resources/Micronaut/modelPojo.mustache b/src/main/resources/Micronaut/modelPojo.mustache index 3e8f5879..e985d556 100644 --- a/src/main/resources/Micronaut/modelPojo.mustache +++ b/src/main/resources/Micronaut/modelPojo.mustache @@ -1,23 +1,17 @@ -{{^vendorExtensions.x-is-one-of-interface}}{{#discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.EXISTING_PROPERTY, property = {{classname}}.JSON_DISCRIMINATOR) -@com.fasterxml.jackson.annotation.JsonSubTypes({ - {{#discriminator.mappedModels}} - @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"){{^-last}},{{/-last}} - {{/discriminator.mappedModels}} -}) -{{/discriminator}}{{#serdeable}}@io.micronaut.serde.annotation.Serdeable +{{#serdeable}}@io.micronaut.serde.annotation.Serdeable {{/serdeable}} -public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parentModel.interfaces}}{{#parent}} extends {{{parent}}}{{/parent}}{{/parentModel.interfaces}}{{#vendorExtensions.x-implements}}{{#-first}} implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { +public class {{classname}}{{#interfaceModels}}{{#-first}} implements{{/-first}} {{classname}}{{^-last}}, {{/-last}}{{/interfaceModels}} { +{{#hasVars}} -{{#vars}} - public static final java.lang.String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}"; -{{/vars}}{{#discriminator}} public static final java.lang.String JSON_DISCRIMINATOR = "{{propertyBaseName}}"; -{{/discriminator}} +{{#vars}} public static final java.lang.String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}"; +{{/vars}} +{{/hasVars}} -{{#vars}}{{#description}} /** {{description}} */ +{{#allVars}}{{#description}} /** {{description}} */ {{/description}}{{#useBeanValidation}}{{>modelPropertyValidation}}{{/useBeanValidation}}{{>modelPropertyJackson}} private {{>modelPropertyType}} {{name}}{{>modelPropertyDefault}}; -{{/vars}} +{{/allVars}} {{#vendorExtensions.additionalPropertiesMap}} private java.util.Map<{{{vendorExtensions.additionalPropertiesMap.keyType}}}, {{{vendorExtensions.additionalPropertiesMap.valueType}}}> additionalProperties; {{/vendorExtensions.additionalPropertiesMap}}{{#discriminator}} @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) @@ -38,31 +32,29 @@ public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parent if (object == null || getClass() != object.getClass()) { return false; } -{{^vars}}{{#discriminator}} {{classname}} other = ({{classname}}) object; -{{/discriminator}}{{/vars}}{{#vars}}{{#-last}} {{classname}} other = ({{classname}}) object; -{{/-last}}{{/vars}} return {{^vars}}{{#discriminator}}java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}());{{/discriminator}}{{^discriminator}}super.equals(object);{{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}java.util.Objects{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays{{/isByteArray}}{{#isFile}}java.util.Arrays{{/isFile}}.equals({{name}}, other.{{name}}){{^-last}} +{{^allVars}}{{#discriminator}} {{classname}} other = ({{classname}}) object; +{{/discriminator}}{{/allVars}}{{#allVars}}{{#-last}} {{classname}} other = ({{classname}}) object; +{{/-last}}{{/allVars}} return {{^allVars}}{{#discriminator}}java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}());{{/discriminator}}{{^discriminator}}super.equals(object);{{/discriminator}}{{/allVars}}{{#allVars}}{{^isFile}}{{^isByteArray}}java.util.Objects{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays{{/isByteArray}}{{#isFile}}java.util.Arrays{{/isFile}}.equals({{name}}, other.{{name}}){{^-last}} && {{/-last}}{{#-last}}{{#discriminator}} - && java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}()){{/discriminator}}{{#parent}} - && super.equals(object){{/parent}};{{/-last}}{{/vars}} + && java.util.Objects.equals({{discriminator.propertyGetter}}(), other.{{discriminator.propertyGetter}}()){{/discriminator}};{{/-last}}{{/allVars}} } @Override public int hashCode() { - return java.util.Objects.hash({{^vars}}{{#discriminator}}{{discriminator.propertyGetter}}(){{/discriminator}}{{/vars}}{{#vars}}{{^isFile}}{{^isByteArray}}{{name}}{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays.hashCode({{name}}){{/isByteArray}}{{#isFile}}java.util.Arrays.hashCode({{name}}){{/isFile}}{{^-last}}, {{/-last}}{{#-last}}{{#discriminator}}, {{discriminator.propertyGetter}}(){{/discriminator}}{{#parent}}, super.hashCode(){{/parent}}{{/-last}}{{/vars}}); + return java.util.Objects.hash({{^allVars}}{{#discriminator}}{{discriminator.propertyGetter}}(){{/discriminator}}{{/allVars}}{{#allVars}}{{^isFile}}{{^isByteArray}}{{name}}{{/isByteArray}}{{/isFile}}{{#isByteArray}}java.util.Arrays.hashCode({{name}}){{/isByteArray}}{{#isFile}}java.util.Arrays.hashCode({{name}}){{/isFile}}{{^-last}}, {{/-last}}{{#-last}}{{#discriminator}}, {{discriminator.propertyGetter}}(){{/discriminator}}{{/-last}}{{/allVars}}); } @Override public java.lang.String toString() { return new java.lang.StringBuilder() - .append("{{classname}}["){{#parent}} - .append("super").append(super.toString()){{/parent}} - {{#vars}} .append("{{name}}{{^isByteArray}}=").append({{name}}{{/isByteArray}}{{#isByteArray}}.length=").append({{name}} == null ? null : {{name}}.length{{/isByteArray}}){{^-last}}.append(","){{/-last}} - {{/vars}} .append("]") + .append("{{classname}}[") + {{#allVars}} .append("{{name}}{{^isByteArray}}=").append({{name}}{{/isByteArray}}{{#isByteArray}}.length=").append({{name}} == null ? null : {{name}}.length{{/isByteArray}}){{^-last}}.append(","){{/-last}} + {{/allVars}} .append("]") .toString(); } // fluent - {{#vars}} + {{#allVars}} public {{classname}} {{name}}({{>modelPropertyType}} new{{nameInCamelCase}}) { this.{{name}} = new{{nameInCamelCase}}; @@ -113,7 +105,7 @@ public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parent {{/isNullable}} return this; }{{/isContainer}} -{{/vars}}{{#vendorExtensions.additionalPropertiesMap}} +{{/allVars}}{{#vendorExtensions.additionalPropertiesMap}} @com.fasterxml.jackson.annotation.JsonAnyGetter public java.util.Map<{{{vendorExtensions.additionalPropertiesMap.keyType}}}, {{{vendorExtensions.additionalPropertiesMap.valueType}}}> getAdditionalProperties() { return additionalProperties; @@ -128,7 +120,7 @@ public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parent } {{/vendorExtensions.additionalPropertiesMap}} - // getter/setter{{#vars}} + // getter/setter{{#allVars}} public {{>modelPropertyType}} {{getter}}() { return {{name}}; @@ -136,27 +128,7 @@ public {{#discriminator}}abstract {{/discriminator}}class {{classname}}{{^parent public void {{setter}}({{>modelPropertyType}} new{{nameInCamelCase}}) { this.{{name}} = new{{nameInCamelCase}}; - }{{/vars}}{{#vars}}{{#isEnum}} - -{{>modelEnum}}{{/isEnum}}{{/vars}} -}{{/vendorExtensions.x-is-one-of-interface}}{{#vendorExtensions.x-is-one-of-interface}}{{^discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.DEDUCTION, visible = true) -{{#interfaces}} -{{#-first}}@com.fasterxml.jackson.annotation.JsonSubTypes({ - @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{{.}}}.class),{{/-first}}{{^-first}}{{^-last}} @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{{.}}}.class),{{/-last}}{{/-first}}{{#-last}} @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{{.}}}.class) -}){{/-last}} -{{/interfaces}} -{{/discriminator}}{{#discriminator}}@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.EXISTING_PROPERTY, property = {{classname}}.JSON_DISCRIMINATOR) -@com.fasterxml.jackson.annotation.JsonSubTypes({ - {{#discriminator.mappedModels}} - @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/discriminator.mappedModels}} -}) -{{/discriminator}} -public interface {{classname}}{{#vendorExtensions.x-implements}}{{#-first}} extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}}{{^discriminator}} {}{{/discriminator}}{{#discriminator}} { -{{#discriminator}} - - java.lang.String JSON_DISCRIMINATOR = "{{propertyBaseName}}";{{/discriminator}} - - @com.fasterxml.jackson.annotation.JsonProperty(JSON_DISCRIMINATOR) - {{discriminator.propertyType}} {{discriminator.propertyGetter}}(); -}{{/discriminator}}{{/vendorExtensions.x-is-one-of-interface}} \ No newline at end of file + }{{/allVars}}{{#allVars}}{{#isEnum}} + +{{>modelEnum}}{{/isEnum}}{{/allVars}} +} \ No newline at end of file diff --git a/src/main/resources/Micronaut/testExampleObject.mustache b/src/main/resources/Micronaut/testExampleObject.mustache index df58a0b7..aa405e14 100644 --- a/src/main/resources/Micronaut/testExampleObject.mustache +++ b/src/main/resources/Micronaut/testExampleObject.mustache @@ -9,8 +9,14 @@ public class {{classname}}TestExample { return {{classname}}.values()[0]; {{/isEnum}} {{^isEnum}} - {{^vendorExtensions.x-is-one-of-interface}} - {{^discriminator}} + {{#hasChildren}} + {{#children}} + {{#-first}} + return {{{classname}}}TestExample.build(); + {{/-first}} + {{/children}} + {{/hasChildren}} + {{^hasChildren}} {{classname}} exampleInstance = new {{classname}}(); {{#allVars}} {{#isEnum}} @@ -29,35 +35,9 @@ public class {{classname}}TestExample { {{/isEnum}} {{/allVars}} return exampleInstance; - {{/discriminator}} - {{#discriminator}} - {{#discriminator.mappedModels}} - {{#-first}} - return {{{modelName}}}TestExample.build(); - {{/-first}} - {{/discriminator.mappedModels}} - {{/discriminator}} - {{/vendorExtensions.x-is-one-of-interface}} + {{/hasChildren}} {{/isEnum}} - {{#vendorExtensions.x-is-one-of-interface}} - {{^discriminator}} - {{#interfaceModels}} - {{#-first}} - return {{{classname}}}TestExample.build(); - {{/-first}} - {{/interfaceModels}} - {{^interfaceModels}} - return null; - {{/interfaceModels}} - {{/discriminator}} - {{#discriminator}} - {{#discriminator.mappedModels}} - {{#-first}} - return {{{modelName}}}TestExample.build(); - {{/-first}} - {{/discriminator.mappedModels}} - {{/discriminator}} - {{/vendorExtensions.x-is-one-of-interface}} - }{{/model}} + } + {{/model}} } {{/models}}