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 bin/configs/jaxrs-cxf-client-jackson.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions docs/generators/jaxrs-cxf-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
1 change: 1 addition & 0 deletions docs/generators/jaxrs-cxf-extended.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
|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|
Expand Down
1 change: 1 addition & 0 deletions docs/generators/jaxrs-cxf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,6 +64,8 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen

@Setter protected boolean useAbstractionForFiles = false;

@Getter @Setter protected boolean useJackson3 = false;

public JavaCXFClientCodegen() {
super();

Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<groupId>{{jacksonPackage}}</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson-jaxrs-version}</version>
<type>pom</type>
Expand Down Expand Up @@ -196,25 +196,27 @@ for this project used jakarta.validation-api -->
</dependency>
{{^useJakartaEe}}
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<groupId>{{jacksonPackage}}.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-jaxrs-version}</version>
<scope>compile</scope>
</dependency>
{{/useJakartaEe}}
{{#useJakartaEe}}
<dependency>
<groupId>com.fasterxml.jackson.jakarta.rs</groupId>
<groupId>{{jacksonPackage}}.jakarta.rs</groupId>
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
<version>${jackson-jaxrs-version}</version>
<scope>compile</scope>
</dependency>
{{/useJakartaEe}}
{{^useJackson3}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-jaxrs-version}</version>
</dependency>
{{/useJackson3}}
{{#useBeanValidationFeature}}
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -244,7 +246,12 @@ for this project used jakarta.validation-api -->
</repository>
</repositories>
<properties>
<java.version>1.8</java.version>
{{#useJackson3}}
<java.version>11</java.version>
{{/useJackson3}}
{{^useJackson3}}
<java.version>8</java.version>
{{/useJackson3}}
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
{{#swagger1AnnotationLibrary}}
Expand All @@ -259,8 +266,14 @@ for this project used jakarta.validation-api -->
{{#useBeanValidation}}
<beanvalidation-version>2.0.2</beanvalidation-version>
{{/useBeanValidation}}
{{#useJackson3}}
<cxf-version>4.2.0</cxf-version>
<jackson-jaxrs-version>3.1.2</jackson-jaxrs-version>
{{/useJackson3}}
{{^useJackson3}}
<cxf-version>3.5.9</cxf-version>
<jackson-jaxrs-version>2.17.1</jackson-jaxrs-version>
{{/useJackson3}}
{{#useJakartaEe}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
{{/useJakartaEe}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.23.0-SNAPSHOT
7.22.0-SNAPSHOT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Generated sample metadata was downgraded to an older generator snapshot, making the sample inconsistent with the repo's current version.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/jaxrs-cxf-client-jackson/.openapi-generator/VERSION, line 1:

<comment>Generated sample metadata was downgraded to an older generator snapshot, making the sample inconsistent with the repo's current version.</comment>

<file context>
@@ -1 +1 @@
-7.23.0-SNAPSHOT
+7.22.0-SNAPSHOT
</file context>
Suggested change
7.22.0-SNAPSHOT
+7.23.0-SNAPSHOT

19 changes: 7 additions & 12 deletions samples/client/petstore/jaxrs-cxf-client-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<groupId>tools.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson-jaxrs-version}</version>
<type>pom</type>
Expand Down Expand Up @@ -159,16 +159,11 @@ for this project used jakarta.validation-api -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<groupId>tools.jackson.jakarta.rs</groupId>
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
<version>${jackson-jaxrs-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-jaxrs-version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand All @@ -191,16 +186,16 @@ for this project used jakarta.validation-api -->
</repository>
</repositories>
<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.6.6</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<junit-version>4.13.2</junit-version>
<logback-version>1.5.25</logback-version>
<cxf-version>3.5.9</cxf-version>
<jackson-jaxrs-version>2.17.1</jackson-jaxrs-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<cxf-version>4.2.0</cxf-version>
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
<jackson-jaxrs-version>3.1.2</jackson-jaxrs-version>
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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;
Expand Down
Loading