From 8387c1528d25b1b6d4dac3ef34809a44e60c2e62 Mon Sep 17 00:00:00 2001 From: florianwermelskirchen Date: Tue, 5 May 2026 14:53:09 +0200 Subject: [PATCH 1/4] [REQ] [JavaJaxRS] [CXF] Add Support for Jackson3 #23616 --- bin/configs/jaxrs-cxf-client-jackson.yaml | 2 ++ .../languages/JavaCXFClientCodegen.java | 23 +++++++++++++++++++ .../resources/JavaJaxRS/cxf/api_test.mustache | 10 ++++++++ .../main/resources/JavaJaxRS/cxf/pom.mustache | 14 ++++++++--- .../petstore/jaxrs-cxf-client-jackson/pom.xml | 17 +++++--------- .../gen/java/org/openapitools/api/PetApi.java | 2 +- .../java/org/openapitools/api/StoreApi.java | 2 +- .../java/org/openapitools/api/UserApi.java | 2 +- .../java/org/openapitools/api/PetApiTest.java | 6 ++--- .../org/openapitools/api/StoreApiTest.java | 6 ++--- .../org/openapitools/api/UserApiTest.java | 6 ++--- 11 files changed, 64 insertions(+), 26 deletions(-) diff --git a/bin/configs/jaxrs-cxf-client-jackson.yaml b/bin/configs/jaxrs-cxf-client-jackson.yaml index 86cb90696fe7..70b64667d5ba 100644 --- a/bin/configs/jaxrs-cxf-client-jackson.yaml +++ b/bin/configs/jaxrs-cxf-client-jackson.yaml @@ -5,3 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf additionalProperties: artifactId: jaxrs-cxf-jackson-petstore-client jackson: "true" + useJackson3: "true" + useJakartaEe: "true" \ No newline at end of file diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java index eed6ae36da88..1da91379f095 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaCXFClientCodegen.java @@ -51,6 +51,11 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles"; + public static final String USE_JACKSON_3 = "useJackson3"; + public static final String JACKSON2_PACKAGE = "com.fasterxml.jackson"; + public static final String JACKSON3_PACKAGE = "tools.jackson"; + public static final String JACKSON_PACKAGE = "jacksonPackage"; + @Getter protected boolean useGenericResponse = false; @Getter protected boolean useGzipFeatureForTests = false; @@ -59,6 +64,8 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen @Setter protected boolean useAbstractionForFiles = false; + @Getter @Setter protected boolean useJackson3 = false; + public JavaCXFClientCodegen() { super(); @@ -97,6 +104,8 @@ public JavaCXFClientCodegen() { cliOptions.add(CliOption.newBoolean(USE_LOGGING_FEATURE_FOR_TESTS, "Use Logging Feature for tests")); cliOptions.add(CliOption.newBoolean(USE_GENERIC_RESPONSE, "Use generic response")); cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk.")); + cliOptions.add(CliOption.newBoolean(USE_JACKSON_3, "Use Jackson 3 instead of Jackson 2.", this.useJackson3)); + } @Override @@ -107,7 +116,13 @@ public void processOpts() { convertPropertyToBooleanAndWriteBack(USE_LOGGING_FEATURE_FOR_TESTS, this::setUseLoggingFeatureForTests); convertPropertyToBooleanAndWriteBack(JACKSON, this::setJackson); convertPropertyToBooleanAndWriteBack(USE_ABSTRACTION_FOR_FILES, this::setUseAbstractionForFiles); + convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3); + if (this.useJackson3) { + this.applyJackson3Package(); + } else { + this.applyJackson2Package(); + } supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml") @@ -206,4 +221,12 @@ public void setUseGenericResponse(boolean useGenericResponse) { this.useGenericResponse = useGenericResponse; } + + protected void applyJackson2Package() { + writePropertyBack(JACKSON_PACKAGE, JACKSON2_PACKAGE); + } + + protected void applyJackson3Package() { + writePropertyBack(JACKSON_PACKAGE, JACKSON3_PACKAGE); + } } diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache index 6e760e411a8c..52f1908f81ed 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/api_test.mustache @@ -24,7 +24,17 @@ import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; {{/useLoggingFeature}} +{{#useJackson3}} +import {{jacksonPackage}}.jakarta.rs.json.JacksonJsonProvider; +{{/useJackson3}} +{{^useJackson3}} +{{#useJakartaEe}} +import {{jacksonPackage}}.jakarta.rs.json.JacksonJsonProvider; +{{/useJakartaEe}} +{{^useJakartaEe}} import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +{{/useJakartaEe}} +{{/useJackson3}} import java.util.ArrayList; import java.util.HashMap; diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache index 1adc6861f0d3..d03fe69ddb51 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache @@ -102,7 +102,7 @@ - com.fasterxml.jackson + {{jacksonPackage}} jackson-bom ${jackson-jaxrs-version} pom @@ -196,7 +196,7 @@ for this project used jakarta.validation-api --> {{^useJakartaEe}} - com.fasterxml.jackson.jaxrs + {{jacksonPackage}}.jaxrs jackson-jaxrs-json-provider ${jackson-jaxrs-version} compile @@ -204,17 +204,19 @@ for this project used jakarta.validation-api --> {{/useJakartaEe}} {{#useJakartaEe}} - com.fasterxml.jackson.jakarta.rs + {{jacksonPackage}}.jakarta.rs jackson-jakarta-rs-json-provider ${jackson-jaxrs-version} compile {{/useJakartaEe}} + {{^useJackson3}} com.fasterxml.jackson.datatype jackson-datatype-jsr310 ${jackson-jaxrs-version} + {{/useJackson3}} {{#useBeanValidationFeature}} org.hibernate @@ -259,8 +261,14 @@ for this project used jakarta.validation-api --> {{#useBeanValidation}} 2.0.2 {{/useBeanValidation}} + {{#useJackson3}} + 4.2.0 + 3.1.2 + {{/useJackson3}} + {{^useJackson3}} 3.5.9 2.17.1 + {{/useJackson3}} {{#useJakartaEe}} 2.1.1 {{/useJakartaEe}} diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml index 225668bf584e..9a4c6c3671de 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml @@ -84,7 +84,7 @@ - com.fasterxml.jackson + tools.jackson jackson-bom ${jackson-jaxrs-version} pom @@ -159,16 +159,11 @@ for this project used jakarta.validation-api --> compile - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider + tools.jackson.jakarta.rs + jackson-jakarta-rs-json-provider ${jackson-jaxrs-version} compile - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson-jaxrs-version} - jakarta.annotation jakarta.annotation-api @@ -198,9 +193,9 @@ for this project used jakarta.validation-api --> 9.2.9.v20150224 4.13.2 1.5.25 - 3.5.9 - 2.17.1 - 1.3.5 + 4.2.0 + 3.1.2 + 2.1.1 UTF-8 diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java index 9ed0722a827a..59b14eed1050 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/PetApi.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -import javax.ws.rs.*; +import jakarta.ws.rs.*; import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java index 89f06783cef6..963bd880873a 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/StoreApi.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; -import javax.ws.rs.*; +import jakarta.ws.rs.*; import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java index 3b1dd0ef5745..d1c687771abe 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/gen/java/org/openapitools/api/UserApi.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import javax.ws.rs.*; +import jakarta.ws.rs.*; import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java index 5fc4823c1c74..32f583cf704a 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/PetApiTest.java @@ -1,4 +1,4 @@ -/** +/* * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * @@ -20,13 +20,13 @@ import org.junit.Before; import static org.junit.Assert.*; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import tools.jackson.jakarta.rs.json.JacksonJsonProvider; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java index b5c96c77b9bd..9a8c4637e59f 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/StoreApiTest.java @@ -1,4 +1,4 @@ -/** +/* * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * @@ -18,13 +18,13 @@ import org.junit.Before; import static org.junit.Assert.*; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import tools.jackson.jakarta.rs.json.JacksonJsonProvider; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java index 0825dbb0f6e7..231ea93dfe3a 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/src/test/java/org/openapitools/api/UserApiTest.java @@ -1,4 +1,4 @@ -/** +/* * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * @@ -19,13 +19,13 @@ import org.junit.Before; import static org.junit.Assert.*; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import tools.jackson.jakarta.rs.json.JacksonJsonProvider; import java.util.ArrayList; import java.util.HashMap; From 05fdd18ba26be49cfb8b2fa593e100d0bb71c9f3 Mon Sep 17 00:00:00 2001 From: florianwermelskirchen Date: Tue, 5 May 2026 14:56:50 +0200 Subject: [PATCH 2/4] [REQ] [JavaJaxRS] [CXF] Add Support for Jackson3 #23616 --- docs/generators/jaxrs-cxf-client.md | 1 + docs/generators/jaxrs-cxf-extended.md | 1 + docs/generators/jaxrs-cxf.md | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index 58557b0ba047..a3835496fda8 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -76,6 +76,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useBeanValidation|Use BeanValidation API annotations| |false| |useGenericResponse|Use generic response| |false| |useGzipFeatureForTests|Use Gzip Feature for tests| |false| +|useJackson3|Use Jackson 3 instead of Jackson 2.| |false| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| |useLoggingFeatureForTests|Use Logging Feature for tests| |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| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index e8575723b309..b5d36a9f50b0 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -92,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useGenericResponse|Use generic response| |false| |useGzipFeature|Use Gzip Feature| |false| |useGzipFeatureForTests|Use Gzip Feature for tests| |false| +|useJackson3|Use Jackson 3 instead of Jackson 2.| |false| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| |useLoggingFeature|Use Logging Feature| |false| |useLoggingFeatureForTests|Use Logging Feature for tests| |false| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index c54b42ab061c..c5629dfee633 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -87,6 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useGenericResponse|Use generic response| |false| |useGzipFeature|Use Gzip Feature| |false| |useGzipFeatureForTests|Use Gzip Feature for tests| |false| +|useJackson3|Use Jackson 3 instead of Jackson 2.| |false| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| |useLoggingFeature|Use Logging Feature| |false| |useLoggingFeatureForTests|Use Logging Feature for tests| |false| From e268e17ceaa771838854cb61288710aafe203fdf Mon Sep 17 00:00:00 2001 From: florianwermelskirchen Date: Fri, 8 May 2026 16:01:41 +0200 Subject: [PATCH 3/4] [REQ] [JavaJaxRS] [CXF] Add Support for Jackson3 #23616 --- .../src/main/resources/JavaJaxRS/cxf/pom.mustache | 7 ++++++- .../jaxrs-cxf-client-jackson/.openapi-generator/VERSION | 2 +- samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache index d03fe69ddb51..915914f91e54 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache @@ -246,7 +246,12 @@ for this project used jakarta.validation-api --> - 1.8 + {{#useJackson3}} + 11 + {{/useJackson3}} + {{^useJackson3}} + java.version>8 + {{/useJackson3}} ${java.version} ${java.version} {{#swagger1AnnotationLibrary}} diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION index ca7bf6e46889..f7962df3e243 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION @@ -1 +1 @@ -7.23.0-SNAPSHOT +7.22.0-SNAPSHOT diff --git a/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml index 9a4c6c3671de..1562a4c49d92 100644 --- a/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml +++ b/samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml @@ -186,7 +186,7 @@ for this project used jakarta.validation-api --> - 1.8 + 11 ${java.version} ${java.version} 1.6.6 From d4876fcf6186cb87d89c1a58358930276426a9e7 Mon Sep 17 00:00:00 2001 From: florianwermelskirchen Date: Fri, 8 May 2026 16:10:36 +0200 Subject: [PATCH 4/4] [REQ] [JavaJaxRS] [CXF] Add Support for Jackson3 #23616 --- .../src/main/resources/JavaJaxRS/cxf/pom.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache index 915914f91e54..4593c0fdd742 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf/pom.mustache @@ -250,7 +250,7 @@ for this project used jakarta.validation-api --> 11 {{/useJackson3}} {{^useJackson3}} - java.version>8 + 8 {{/useJackson3}} ${java.version} ${java.version}