Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/generators/groovy.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|


## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-camel.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useTags|use tags for creating interface and controller classnames| |false|
|virtualService|Generates the virtual service. For more details refer - https://github.com/virtualansoftware/virtualan/wiki| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-dubbo.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useTags|use tags for creating interface and controller classnames| |true|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-helidon-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|x-helidon-groupBy|Selects how to group operations into APIs|<dl><dt>**tags**</dt><dd>Use the 'tags' settings on each operation</dd><dt>**first-path-segment**</dt><dd>Use the first segment of the path</dd></dl>|tags|
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-helidon-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|x-helidon-groupBy|Selects how to group operations into APIs|<dl><dt>**tags**</dt><dd>Use the 'tags' settings on each operation</dd><dt>**first-path-segment**</dt><dd>Use the first segment of the path</dd></dl>|tags|
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-inflector.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-micronaut-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|visitable|Generate visitor for subtypes with a discriminator| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|wrapInHttpResponse|Wrap the response in HttpResponse object| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-micronaut-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|visitable|Generate visitor for subtypes with a discriminator| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|wrapInHttpResponse|Wrap the response in HttpResponse object| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-microprofile.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-msf4j.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useTags|use tags for creating interface and controller classnames| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-pkmst.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|zipkinUri|Zipkin URI| |null|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-play-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useSwaggerUI|Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies| |true|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|wrapCalls|Add a wrapper to each controller function to handle things like metrics, response modification, etc..| |true|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-undertow-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-vertx-web.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-vertx.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|vertxSwaggerRouterVersion|Specify the version of the swagger router library| |null|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java-wiremock.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
1 change: 1 addition & 0 deletions docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false|
|withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|disableDiscriminatorFieldIgnore| whether to add jackson @JsonIgnoreProperties for discriminator in base class | |false|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
Expand Down Expand Up @@ -51,7 +50,6 @@
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.templating.mustache.ReplaceAllLambda;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -102,6 +100,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String JAVAX_PACKAGE = "javaxPackage";
public static final String USE_JAKARTA_EE = "useJakartaEe";
public static final String CONTAINER_DEFAULT_TO_NULL = "containerDefaultToNull";
public static final String DISABLE_DISCRIMINATOR_FIELD_IGNORE = "disableDiscriminatorFieldIgnore";

public static final String CAMEL_CASE_DOLLAR_SIGN = "camelCaseDollarSign";
public static final String USE_ONE_OF_INTERFACES = "useOneOfInterfaces";
Expand Down Expand Up @@ -198,6 +197,8 @@ protected enum ENUM_PROPERTY_NAMING_TYPE {MACRO_CASE, legacy, original}
protected boolean jackson = false;
@Getter @Setter
protected boolean generateBuilders;
@Getter @Setter
protected boolean disableDiscriminatorFieldIgnore = false;
/**
* useBeanValidation has been moved from child generators to AbstractJavaCodegen.
* The reason is that getBeanValidation needs it
Expand Down Expand Up @@ -345,6 +346,7 @@ public AbstractJavaCodegen() {
cliOptions.add(CliOption.newBoolean(CONTAINER_DEFAULT_TO_NULL, "Set containers (array, set, map) default to null"));
cliOptions.add(CliOption.newBoolean(GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, "whether to generate a constructor for all arguments").defaultValue(Boolean.FALSE.toString()));
cliOptions.add(CliOption.newBoolean(GENERATE_BUILDERS, "Whether to generate builders for models").defaultValue(Boolean.FALSE.toString()));
cliOptions.add(CliOption.newBoolean(DISABLE_DISCRIMINATOR_FIELD_IGNORE, "Ignore discriminator field allOf, oneOf for Jackson serialization", disableDiscriminatorFieldIgnore));

cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
Expand Down Expand Up @@ -424,6 +426,7 @@ public void processOpts() {

convertPropertyToBooleanAndWriteBack(GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, this::setGenerateConstructorWithAllArgs);
convertPropertyToBooleanAndWriteBack(GENERATE_BUILDERS, this::setGenerateBuilders);
convertPropertyToBooleanAndWriteBack(DISABLE_DISCRIMINATOR_FIELD_IGNORE, this::setDisableDiscriminatorFieldIgnore);
if (StringUtils.isEmpty(System.getenv("JAVA_POST_PROCESS_FILE"))) {
LOGGER.info("Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)");
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Setter protected boolean supportVertxFuture = false;
@Setter protected boolean useSealedOneOfInterfaces = false;
@Setter protected boolean useUnaryInterceptor = false;

protected String authFolder;
/**
* Serialization library.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{#jackson}}

{{^disableDiscriminatorFieldIgnore}}
@JsonIgnoreProperties(
value = "{{{discriminator.propertyBaseName}}}", // ignore manually set {{{discriminator.propertyBaseName}}}, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the {{{discriminator.propertyBaseName}}} to be set during deserialization
)
{{/disableDiscriminatorFieldIgnore}}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
{{#discriminator.mappedModels}}
{{#-first}}
Expand Down
Loading