Skip to content

Commit fbf011e

Browse files
fix compile errors
1 parent 3bc4c27 commit fbf011e

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
120120
public static final String SERIALIZATION_LIBRARY_JSONB = "jsonb";
121121

122122
public static final String USE_SPRING_BOOT4 = "useSpringBoot4";
123-
public static final String USE_JACKSON_3 = "useJackson3";
124123
private static final String JACKSON2_PACKAGE = "com.fasterxml.jackson";
125124
private static final String JACKSON3_PACKAGE = "tools.jackson";
126125
private static final String JACKSON_PACKAGE = "jacksonPackage";
@@ -167,7 +166,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
167166
*/
168167
@Getter protected String serializationLibrary = null;
169168
@Getter @Setter protected boolean useSpringBoot4 = false;
170-
@Getter @Setter protected boolean useJackson3 = false;
171169
@Setter protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
172170
protected String rootJavaEEPackage;
173171
protected Map<String, MpRestClientVersion> mpRestClientVersions = new LinkedHashMap<>();
@@ -272,7 +270,7 @@ public JavaClientCodegen() {
272270
cliOptions.add(CliOption.newBoolean(SUPPORT_URL_QUERY, "Generate toUrlQueryString in POJO (default to true). Available on `native`, `apache-httpclient` libraries."));
273271
cliOptions.add(CliOption.newBoolean(USE_ENUM_CASE_INSENSITIVE, "Use `equalsIgnoreCase` when String for enum comparison", useEnumCaseInsensitive));
274272
cliOptions.add(CliOption.newBoolean(FAIL_ON_UNKNOWN_PROPERTIES, "Fail Jackson de-serialization on unknown properties", this.failOnUnknownProperties));
275-
cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Use Jackson 3 instead of Jackson 2 for JSON processing. Only supported for 'native' library.", this.useJackson3));
273+
cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Use Jackson 3 instead of Jackson 2. Supported for 'native' library and for 'restclient' library (requires useSpringBoot4=true).", this.useJackson3));
276274
cliOptions.add(CliOption.newBoolean(SUPPORT_VERTX_FUTURE, "Also generate api methods that return a vertx Future instead of taking a callback. Only `vertx` supports this option. Requires vertx 4 or greater.", this.supportVertxFuture));
277275
cliOptions.add(CliOption.newBoolean(USE_SEALED_ONE_OF_INTERFACES, "Generate the oneOf interfaces as sealed interfaces. Only supported for WebClient and RestClient.", this.useSealedOneOfInterfaces));
278276
cliOptions.add(CliOption.newBoolean(USE_UNARY_INTERCEPTOR, "If true it will generate ResponseInterceptors using a UnaryOperator. This can be usefull for manipulating the request before it gets passed, for example doing your own decryption", this.useUnaryInterceptor));
@@ -310,7 +308,7 @@ public JavaClientCodegen() {
310308
serializationLibrary.setEnum(serializationOptions);
311309
cliOptions.add(serializationLibrary);
312310
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT4, "Generate code and provide dependencies for use with Spring Boot 4.x.", useSpringBoot4));
313-
cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Set it in order to use jackson 3 dependencies (only allowed when `" + USE_SPRING_BOOT4 + "` is set and incompatible with `"+OPENAPI_NULLABLE+"`).", useJackson3)); // Ensure the OAS 3.x discriminator mappings include any descendent schemas that allOf
311+
// Ensure the OAS 3.x discriminator mappings include any descendent schemas that allOf
314312
// inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values,
315313
// and the discriminator mapping schemas in the OAS document.
316314
this.setLegacyDiscriminatorBehavior(false);
@@ -381,11 +379,17 @@ public void processOpts() {
381379
convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, this::setUseOneOfDiscriminatorLookup);
382380
convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3);
383381
convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4, this::setUseSpringBoot4);
384-
if(isUseJackson3() && !isUseSpringBoot4()){
385-
throw new IllegalArgumentException("useJackson3 is only available with Spring Boot >= 4");
382+
if (useJackson3 && libRestClient && !useSpringBoot4) {
383+
throw new IllegalArgumentException("useJackson3 for the restclient library requires useSpringBoot4=true");
384+
} else if (useJackson3 && !libNative && !libRestClient) {
385+
LOGGER.warn("useJackson3 is only supported for 'native' and 'restclient' libraries. Disabling useJackson3.");
386+
useJackson3 = false;
387+
additionalProperties.put(USE_JACKSON_3, false);
386388
}
387-
if(isUseJackson3() && isOpenApiNullable()){
388-
throw new IllegalArgumentException("openApiNullable cannot be set with useJackson3");
389+
if (useJackson3 && openApiNullable) {
390+
LOGGER.warn("openApiNullable is not supported with useJackson3=true (jackson-databind-nullable has no Jackson 3 release). Disabling openApiNullable.");
391+
openApiNullable = false;
392+
additionalProperties.put(OPENAPI_NULLABLE, false);
389393
}
390394

391395
if(this.useJackson3){
@@ -481,12 +485,6 @@ public void processOpts() {
481485
convertPropertyToBooleanAndWriteBack(WEBCLIENT_BLOCKING_OPERATIONS, op -> webclientBlockingOperations = op);
482486
convertPropertyToBooleanAndWriteBack(FAIL_ON_UNKNOWN_PROPERTIES, this::setFailOnUnknownProperties);
483487
convertPropertyToBooleanAndWriteBack(SUPPORT_VERTX_FUTURE, this::setSupportVertxFuture);
484-
convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3);
485-
if (useJackson3 && openApiNullable) {
486-
LOGGER.warn("openApiNullable is not supported with useJackson3=true (jackson-databind-nullable has no Jackson 3 release). Disabling openApiNullable.");
487-
openApiNullable = false;
488-
additionalProperties.put(OPENAPI_NULLABLE, false);
489-
}
490488

491489
// add URL query deepObject support to native, apache-httpclient by default
492490
if (!additionalProperties.containsKey(SUPPORT_URL_QUERY)) {

0 commit comments

Comments
 (0)