diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index e60f802f17b..e028fb0a8d4 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-groovy| diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md index c3cac83c15e..daf59d31693 100644 --- a/docs/generators/java-camel.md +++ b/docs/generators/java-camel.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |annotationLibrary|Select the complementary documentation annotation library.|
**none**
Do not annotate Model and Api with complementary annotations.
**swagger1**
Annotate Model and Api using the Swagger Annotations 1.x library.
**swagger2**
Annotate Model and Api using the Swagger Annotations 2.x library.
|swagger2| |apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false| diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md index a2c57ac695e..809503a3cf1 100644 --- a/docs/generators/java-helidon-client.md +++ b/docs/generators/java-helidon-client.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.client.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md index b96f1730758..4a216c0e814 100644 --- a/docs/generators/java-helidon-server.md +++ b/docs/generators/java-helidon-server.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.server.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md index 8dfd8797cd7..67a83702c8f 100644 --- a/docs/generators/java-inflector.md +++ b/docs/generators/java-inflector.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.controllers| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md index b0368d3ef59..bf0e245caea 100644 --- a/docs/generators/java-micronaut-client.md +++ b/docs/generators/java-micronaut-client.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |applicationName|Micronaut application name (Defaults to the artifactId value)| |openapi-micronaut-client| diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md index 85422ca8bbc..d0ccd44dbb1 100644 --- a/docs/generators/java-micronaut-server.md +++ b/docs/generators/java-micronaut-server.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |applicationName|Micronaut application name (Defaults to the artifactId value)| |openapi-micronaut| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md index 15ab35ba4eb..c270a4d7308 100644 --- a/docs/generators/java-msf4j.md +++ b/docs/generators/java-msf4j.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md index efb3e265c27..9cb8ea5de8d 100644 --- a/docs/generators/java-pkmst.md +++ b/docs/generators/java-pkmst.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |com.prokarma.pkmst.controller| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md index 65ae38fc1ac..e9dd7e0a5e8 100644 --- a/docs/generators/java-play-framework.md +++ b/docs/generators/java-play-framework.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |controllers| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md index 019efb9117a..302c87ee3ae 100644 --- a/docs/generators/java-undertow-server.md +++ b/docs/generators/java-undertow-server.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |null| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md index 3a721083c20..1a8cd03de9c 100644 --- a/docs/generators/java-vertx-web.md +++ b/docs/generators/java-vertx-web.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.vertxweb.server.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md index d5e12fe3f3b..b32f93066cb 100644 --- a/docs/generators/java-vertx.md +++ b/docs/generators/java-vertx.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.server.api.verticle| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/java.md b/docs/generators/java.md index 750e9c99442..63e46d8ed38 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |annotationLibrary|Select the complementary documentation annotation library.|
**none**
Do not annotate Model and Api with complementary annotations.
**swagger1**
Annotate Model and Api using the Swagger Annotations 1.x library.
|none| |apiPackage|package for generated api classes| |org.openapitools.client.api| diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index 6cd328248a4..2cff133ebab 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index 72cb6f71bcb..6d11b061092 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index e1778d3101b..8ec8348a5ad 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -21,6 +21,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |addConsumesProducesJson|Add @Consumes/@Produces Json to API interface| |false| |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index e54504b1ca2..6135b64fa80 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -21,6 +21,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |addConsumesProducesJson|Add @Consumes/@Produces Json to API interface| |false| |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md index 73bf0d8f6b2..653373ccb5f 100644 --- a/docs/generators/jaxrs-jersey.md +++ b/docs/generators/jaxrs-jersey.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md index 726c44cd45c..8667af28b1e 100644 --- a/docs/generators/jaxrs-resteasy-eap.md +++ b/docs/generators/jaxrs-resteasy-eap.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md index aa92d499db2..a24cbf60f4b 100644 --- a/docs/generators/jaxrs-resteasy.md +++ b/docs/generators/jaxrs-resteasy.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index 84aea15c97e..3922bf97d0e 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |org.openapitools.api| |artifactDescription|artifact description in generated pom.xml| |OpenAPI Java| diff --git a/docs/generators/spring.md b/docs/generators/spring.md index 9d28e7915e7..e6e72361eb2 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -20,6 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null| |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| +|additionalOneOfTypeAnnotations|Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null| |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |annotationLibrary|Select the complementary documentation annotation library.|
**none**
Do not annotate Model and Api with complementary annotations.
**swagger1**
Annotate Model and Api using the Swagger Annotations 1.x library.
**swagger2**
Annotate Model and Api using the Swagger Annotations 2.x library.
|swagger2| |apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 572575e0882..a5c578041d1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -75,6 +75,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code public static final String BOOLEAN_GETTER_PREFIX = "booleanGetterPrefix"; public static final String IGNORE_ANYOF_IN_ENUM = "ignoreAnyOfInEnum"; public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS = "additionalModelTypeAnnotations"; + public static final String ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS = "additionalOneOfTypeAnnotations"; public static final String ADDITIONAL_ENUM_TYPE_ANNOTATIONS = "additionalEnumTypeAnnotations"; public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive"; public static final String OPENAPI_NULLABLE = "openApiNullable"; @@ -126,6 +127,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code protected String parentVersion = ""; protected boolean parentOverridden = false; protected List additionalModelTypeAnnotations = new LinkedList<>(); + protected List additionalOneOfTypeAnnotations = new LinkedList<>(); protected List additionalEnumTypeAnnotations = new LinkedList<>(); protected boolean openApiNullable = true; protected String outputTestFolder = ""; @@ -265,6 +267,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code cliOptions.add(CliOption.newBoolean(IGNORE_ANYOF_IN_ENUM, "Ignore anyOf keyword in enum", ignoreAnyOfInEnum)); cliOptions.add(CliOption.newString(ADDITIONAL_ENUM_TYPE_ANNOTATIONS, "Additional annotations for enum type(class level annotations)")); cliOptions.add(CliOption.newString(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)")); + cliOptions.add(CliOption.newString(ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS, "Additional annotations for oneOf interfaces(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)")); cliOptions.add(CliOption.newBoolean(OPENAPI_NULLABLE, "Enable OpenAPI Jackson Nullable library", this.openApiNullable)); cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Skip header parameters in the generated API methods using @ApiImplicitParams annotation.", implicitHeaders)); cliOptions.add(CliOption.newString(IMPLICIT_HEADERS_REGEX, "Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true")); @@ -373,6 +376,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code this.setAdditionalModelTypeAnnotations(Arrays.asList(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*"))); } + if (additionalProperties.containsKey(ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS)) { + String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS).toString(); + this.setAdditionalOneOfTypeAnnotations(Arrays.asList(additionalAnnotationsList.trim().split("\\s*(;|\\r?\\n)\\s*"))); + } + if (additionalProperties.containsKey(ADDITIONAL_ENUM_TYPE_ANNOTATIONS)) { String additionalAnnotationsList = additionalProperties.get(ADDITIONAL_ENUM_TYPE_ANNOTATIONS).toString(); @@ -671,14 +679,21 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code if (!additionalModelTypeAnnotations.isEmpty()) { for (String modelName : objs.keySet()) { - Map models = (Map) objs.get(modelName); + Map models = objs.get(modelName); models.put(ADDITIONAL_MODEL_TYPE_ANNOTATIONS, additionalModelTypeAnnotations); } } + if (!additionalOneOfTypeAnnotations.isEmpty()) { + for (String modelName : objs.keySet()) { + Map models = objs.get(modelName); + models.put(ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS, additionalOneOfTypeAnnotations); + } + } + if (!additionalEnumTypeAnnotations.isEmpty()) { for (String modelName : objs.keySet()) { - Map models = (Map) objs.get(modelName); + Map models = objs.get(modelName); models.put(ADDITIONAL_ENUM_TYPE_ANNOTATIONS, additionalEnumTypeAnnotations); } } @@ -2075,6 +2090,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code this.additionalModelTypeAnnotations = additionalModelTypeAnnotations; } + public List getAdditionalOneOfTypeAnnotations() { + return additionalOneOfTypeAnnotations; + } + + public void setAdditionalOneOfTypeAnnotations(final List additionalOneOfTypeAnnotations) { + this.additionalOneOfTypeAnnotations = additionalOneOfTypeAnnotations; + } + public void setAdditionalEnumTypeAnnotations(final List additionalEnumTypeAnnotations) { this.additionalEnumTypeAnnotations = additionalEnumTypeAnnotations; } diff --git a/modules/openapi-generator/src/main/resources/Java/additionalOneOfTypeAnnotations.mustache b/modules/openapi-generator/src/main/resources/Java/additionalOneOfTypeAnnotations.mustache new file mode 100644 index 00000000000..283f8f91e74 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/Java/additionalOneOfTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalOneOfTypeAnnotations}}{{{.}}} +{{/additionalOneOfTypeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/Java/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/Java/oneof_interface.mustache index 02deb483d5f..d6727727460 100644 --- a/modules/openapi-generator/src/main/resources/Java/oneof_interface.mustache +++ b/modules/openapi-generator/src/main/resources/Java/oneof_interface.mustache @@ -1,4 +1,4 @@ -{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} +{{>additionalOneOfTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { {{#discriminator}} public {{propertyType}} {{propertyGetter}}(); diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/additionalOneOfTypeAnnotations.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/additionalOneOfTypeAnnotations.mustache new file mode 100644 index 00000000000..283f8f91e74 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/JavaSpring/additionalOneOfTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalOneOfTypeAnnotations}}{{{.}}} +{{/additionalOneOfTypeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache index 7ec79444bb9..679fe3d8831 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache @@ -1,4 +1,4 @@ -{{>additionalModelTypeAnnotations}} +{{>additionalOneOfTypeAnnotations}} {{#withXml}} {{>xmlAnnotation}} {{/withXml}} diff --git a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/additionalOneOfTypeAnnotations.mustache b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/additionalOneOfTypeAnnotations.mustache new file mode 100644 index 00000000000..283f8f91e74 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/additionalOneOfTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalOneOfTypeAnnotations}}{{{.}}} +{{/additionalOneOfTypeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/oneof_interface.mustache index 02deb483d5f..d6727727460 100644 --- a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/oneof_interface.mustache +++ b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/mp/oneof_interface.mustache @@ -1,4 +1,4 @@ -{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} +{{>additionalOneOfTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { {{#discriminator}} public {{propertyType}} {{propertyGetter}}(); diff --git a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/additionalOneOfTypeAnnotations.mustache b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/additionalOneOfTypeAnnotations.mustache new file mode 100644 index 00000000000..283f8f91e74 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/additionalOneOfTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalOneOfTypeAnnotations}}{{{.}}} +{{/additionalOneOfTypeAnnotations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/oneof_interface.mustache index 02deb483d5f..d6727727460 100644 --- a/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/oneof_interface.mustache +++ b/modules/openapi-generator/src/main/resources/java-helidon/client/libraries/se/oneof_interface.mustache @@ -1,4 +1,4 @@ -{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} +{{>additionalOneOfTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { {{#discriminator}} public {{propertyType}} {{propertyGetter}}(); diff --git a/modules/openapi-generator/src/main/resources/java-micronaut/common/model/oneof_interface.mustache b/modules/openapi-generator/src/main/resources/java-micronaut/common/model/oneof_interface.mustache index 33c3d6530fe..fbf0a8340cf 100644 --- a/modules/openapi-generator/src/main/resources/java-micronaut/common/model/oneof_interface.mustache +++ b/modules/openapi-generator/src/main/resources/java-micronaut/common/model/oneof_interface.mustache @@ -1,6 +1,6 @@ -{{#additionalModelTypeAnnotations}} +{{#additionalOneOfTypeAnnotations}} {{{.}}} -{{/additionalModelTypeAnnotations}} +{{/additionalOneOfTypeAnnotations}} {{>common/generatedAnnotation}}{{>common/model/typeInfoAnnotation}}{{>common/model/xmlAnnotation}} public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { {{#discriminator}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/JavaFileAssert.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/JavaFileAssert.java index e0621b31662..7111d389223 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/JavaFileAssert.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/assertions/JavaFileAssert.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ConstructorDeclaration; import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.Assertions; @@ -18,6 +19,7 @@ import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.nodeTypes.NodeWithName; +import com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAbstractModifier; @CanIgnoreReturnValue public class JavaFileAssert extends AbstractAssert { @@ -46,6 +48,30 @@ public class JavaFileAssert extends AbstractAssert methods = paramTypes.length == 0 ? actual.getType(0).getMethodsByName(methodName) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index d97a3c6ab44..e7c9b733cd1 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -1618,6 +1618,46 @@ public class SpringCodegenTest { .bodyContainsLines("return Arrays.equals(this.picture, testObject.picture);"); } + @Test + public void shouldHandleSeparatelyInterfaceAndModelAdditionalAnnotations() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/bugs/issue_13917.yaml", null, new ParseOptions()).getOpenAPI(); + SpringCodegen codegen = new SpringCodegen(); + codegen.setLibrary(SPRING_BOOT); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(SpringCodegen.INTERFACE_ONLY, "true"); + codegen.additionalProperties().put(SpringCodegen.USE_BEANVALIDATION, "true"); + codegen.additionalProperties().put(SpringCodegen.PERFORM_BEANVALIDATION, "true"); + codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.model"); + codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.controller"); + codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@marker.Class1;@marker.Class2;@marker.Common"); + codegen.additionalProperties().put(AbstractJavaCodegen.ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS, "@marker.Interface1;@marker.Common"); + + ClientOptInput input = new ClientOptInput() + .openAPI(openAPI) + .config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + Map files = generator.opts(input).generate().stream() + .collect(Collectors.toMap(File::getName, Function.identity())); + + JavaFileAssert.assertThat(files.get("PatchRequestInner.java")) + .isInterface() + .assertTypeAnnotations() + .containsWithName("marker.Interface1") + .containsWithName("marker.Common"); + + JavaFileAssert.assertThat(files.get("JSONPatchRequestRemove.java")) + .isNormalClass() + .assertTypeAnnotations() + .containsWithName("marker.Class1") + .containsWithName("marker.Class2") + .containsWithName("marker.Common"); + } + @Test public void contractWithoutEnumDoesNotContainsEnumConverter() throws IOException { Map output = generateFromContract("src/test/resources/3_0/generic.yaml", SPRING_BOOT); diff --git a/modules/openapi-generator/src/test/resources/bugs/issue_13917.yaml b/modules/openapi-generator/src/test/resources/bugs/issue_13917.yaml new file mode 100644 index 00000000000..85e84252fc7 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/bugs/issue_13917.yaml @@ -0,0 +1,87 @@ +openapi: 3.0.3 +info: + description: xxx + version: 0.0.1 + title: x + x-audience: company-internal + +paths: + + /users/{id}: + patch: + description: Returns an organization + operationId: GetOrganization + parameters: + - in: path + name: id + required: true + schema: + #minLength: 36 + type: string + format: uuid + style: simple + requestBody: + content: + application/json-patch+json: + schema: + $ref: '#/components/schemas/PatchRequest' + responses: + '200': + description: Successful response. + + + +components: + schemas: + PatchRequest: + type: array + items: + oneOf: + - $ref: '#/components/schemas/JSONPatchRequestAddReplaceTest' + - $ref: '#/components/schemas/JSONPatchRequestRemove' + - $ref: '#/components/schemas/JSONPatchRequestMoveCopy' + JSONPatchRequestAddReplaceTest: + type: object + additionalProperties: false + required: + - value + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + value: + description: The value to add, replace or test. + JSONPatchRequestRemove: + type: object + additionalProperties: false + required: + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + op: + description: The operation to perform. + type: string + enum: + - remove + JSONPatchRequestMoveCopy: + type: object + additionalProperties: false + required: + - from + - op + - path + properties: + path: + description: A JSON Pointer path. + type: string + op: + description: The operation to perform. + type: string + enum: + - move + - copy \ No newline at end of file