Skip to content

[java][Feign] consolidate Java Feign client tests - #25967

Open
wing328 wants to merge 2 commits into
masterfrom
feign-test
Open

wing328 wants to merge 2 commits into
masterfrom
feign-test

Conversation

@wing328

@wing328 wing328 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Consolidates the Java Feign client CI tests into a single workflow that runs over all Feign sample projects. The two separate workflows for the Jackson JSON header and tagged oneOf runtime tests are removed, and those tests now live in dedicated generated sample projects under samples/client/petstore/java/.

Written for commit 2fc2f66. Summary will update on new commits.

View guided diff Turn on auto-fix

@wing328 wing328 added this to the 7.29.0 milestone Dec 4, 2026
@wing328
wing328 marked this pull request as ready for review December 4, 2026 08:22

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

13 issues found across 93 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/samples-java-feign.yaml">

<violation number="1" location=".github/workflows/samples-java-feign.yaml:6">
P2: Changes to `JavaClientCodegen.java` or the Feign templates no longer trigger this runtime suite. Add those generator paths to both event filters, as the deleted Feign workflows did, so generator regressions cannot bypass these tests.</violation>

<violation number="2" location=".github/workflows/samples-java-feign.yaml:39">
P3: This job enables setup-java's Gradle cache, then restores and saves `~/.gradle/caches` again in the next cache step. Remove one mechanism to avoid duplicate cache traffic and cache entries.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/build.sbt">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/build.sbt:21">
P1: The SBT build omits `jackson-databind-nullable`, although `ApiClient` imports `JsonNullableModule`, so `sbt compile` cannot compile this client. Add the same dependency already present in the Maven and Gradle builds.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java:32">
P2: `RFC3339JavaTimeModule` adds its deserializers after `SimpleModule` has registered them, so the custom RFC3339 parsing never takes effect. Register the deserializers before calling `super.setupModule(context)`.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-tagged-oneof/build.sbt">

<violation number="1" location="samples/client/petstore/java/feign-jackson-tagged-oneof/build.sbt:23">
P2: This sbt build omits `jackson-databind-nullable`, but `ApiClient.java` imports `org.openapitools.jackson.nullable.JsonNullableModule`, so `sbt compile` will fail. Add the dependency the pom already declares (0.2.13). The same gap is in the `build.sbt.mustache` template, so fix it there as well.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-tagged-oneof/src/main/java/org/openapitools/client/model/ApiResponse.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-tagged-oneof/src/main/java/org/openapitools/client/model/ApiResponse.java:36">
P3: Typo in the Javadoc: "response bod" should be "response body". This comes from the generator template `Java/libraries/feign/model/ApiResponse.mustache`, so fix it there and regenerate rather than editing this generated file by hand.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiResponseDecoder.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiResponseDecoder.java:90">
P3: A malformed or platform-invalid `Content-Disposition` filename makes this throw instead of falling back. `Paths.get("/").getFileName()` returns null, so `.toString()` throws an NPE. On Windows, names with `:` throw `InvalidPathException`. Handle the null case and fall back to a generated name.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiClient.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiClient.java:59">
P3: `expand` copies the whole `ObjectMapper` for every header value. `copy()` starts with empty serializer caches, so each call re-introspects the type. Build the configured copy once, for example when the `ApiClient` is constructed or when the mapper is set, and reuse it.</violation>

<violation number="2" location="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiClient.java:206">
P2: `setFeignBuilder` silently replaces the caller's Feign contract with `jsonHeaderContract()`, which wraps only `Contract.Default`. A builder configured with a custom contract loses it without any warning. Either preserve the existing contract by wrapping it, or document that this overrides it.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/README.md">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/README.md:40">
P3: The usage example does not describe this generated client: every nonempty auth constructor throws, and the documented auth methods and API types are absent. Replace it with a compiling `new ApiClient()`/`DefaultApi` example for this sample.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-tagged-oneof/README.md">

<violation number="1" location="samples/client/petstore/java/feign-jackson-tagged-oneof/README.md:40">
P2: This README is the generic Petstore template rather than a usable example for this client: its auth calls and `PetApi` types do not exist, and every shown auth constructor throws. Replace it with a compiling `DefaultApi`/`getMetadata` example.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ServerConfiguration.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ServerConfiguration.java:55">
P2: `ServerConfiguration.URL` dereferences nullable `enumValues`, so overriding a server variable without an enum throws `NullPointerException`. Guard the set before checking its size and contents.</violation>
</file>

<file name="samples/client/petstore/java/feign-jackson-tagged-oneof/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java">

<violation number="1" location="samples/client/petstore/java/feign-jackson-tagged-oneof/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java:32">
P2: Jackson registers this module before these deserializers are added, so the custom RFC3339 handlers are never installed. Add them before `super.setupModule(context)`; otherwise inputs requiring the custom space-to-`T` normalization use the default Java-time parser.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

"io.github.openfeign" % "feign-okhttp" % "13.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.21.8" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.21.8" % "compile",

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.

P1: The SBT build omits jackson-databind-nullable, although ApiClient imports JsonNullableModule, so sbt compile cannot compile this client. Add the same dependency already present in the Maven and Gradle builds.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/build.sbt, line 21:

<comment>The SBT build omits `jackson-databind-nullable`, although `ApiClient` imports `JsonNullableModule`, so `sbt compile` cannot compile this client. Add the same dependency already present in the Maven and Gradle builds.</comment>

<file context>
@@ -0,0 +1,34 @@
+      "io.github.openfeign" % "feign-okhttp" % "13.5" % "compile",
+      "com.fasterxml.jackson.core" % "jackson-core" % "2.21.8" % "compile",
+      "com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
+      "com.fasterxml.jackson.core" % "jackson-databind" % "2.21.8" % "compile",
+      "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.21.1" % "compile",
+      "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.18.2" % "compile",
</file context>

on:
push:
paths:
- samples/client/petstore/java/feign/**

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.

P2: Changes to JavaClientCodegen.java or the Feign templates no longer trigger this runtime suite. Add those generator paths to both event filters, as the deleted Feign workflows did, so generator regressions cannot bypass these tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/samples-java-feign.yaml, line 6:

<comment>Changes to `JavaClientCodegen.java` or the Feign templates no longer trigger this runtime suite. Add those generator paths to both event filters, as the deleted Feign workflows did, so generator regressions cannot bypass these tests.</comment>

<file context>
@@ -0,0 +1,73 @@
+on:
+  push:
+    paths:
+      - samples/client/petstore/java/feign/**
+      - samples/client/petstore/java/feign-hc5/**
+      - samples/client/petstore/java/feign-no-nullable/**
</file context>


@Override
public void setupModule(SetupContext context) {
super.setupModule(context);

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.

P2: RFC3339JavaTimeModule adds its deserializers after SimpleModule has registered them, so the custom RFC3339 parsing never takes effect. Register the deserializers before calling super.setupModule(context).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java, line 32:

<comment>`RFC3339JavaTimeModule` adds its deserializers after `SimpleModule` has registered them, so the custom RFC3339 parsing never takes effect. Register the deserializers before calling `super.setupModule(context)`.</comment>

<file context>
@@ -0,0 +1,39 @@
+
+   @Override
+   public void setupModule(SetupContext context) {
+       super.setupModule(context);
+
+       addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT);
</file context>

"com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.21.8" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.21.1" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.18.2" % "compile",

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.

P2: This sbt build omits jackson-databind-nullable, but ApiClient.java imports org.openapitools.jackson.nullable.JsonNullableModule, so sbt compile will fail. Add the dependency the pom already declares (0.2.13). The same gap is in the build.sbt.mustache template, so fix it there as well.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-tagged-oneof/build.sbt, line 23:

<comment>This sbt build omits `jackson-databind-nullable`, but `ApiClient.java` imports `org.openapitools.jackson.nullable.JsonNullableModule`, so `sbt compile` will fail. Add the dependency the pom already declares (0.2.13). The same gap is in the `build.sbt.mustache` template, so fix it there as well.</comment>

<file context>
@@ -0,0 +1,34 @@
+      "com.fasterxml.jackson.core" % "jackson-annotations" % "2.21" % "compile",
+      "com.fasterxml.jackson.core" % "jackson-databind" % "2.21.8" % "compile",
+      "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.21.1" % "compile",
+      "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.18.2" % "compile",
+      "com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
+      "com.brsanthu" % "migbase64" % "2.2" % "compile",
</file context>


public ApiClient setFeignBuilder(Feign.Builder feignBuilder) {
this.feignBuilder = feignBuilder;
this.feignBuilder.contract(jsonHeaderContract());

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.

P2: setFeignBuilder silently replaces the caller's Feign contract with jsonHeaderContract(), which wraps only Contract.Default. A builder configured with a custom contract loses it without any warning. Either preserve the existing contract by wrapping it, or document that this overrides it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiClient.java, line 206:

<comment>`setFeignBuilder` silently replaces the caller's Feign contract with `jsonHeaderContract()`, which wraps only `Contract.Default`. A builder configured with a custom contract loses it without any warning. Either preserve the existing contract by wrapping it, or document that this overrides it.</comment>

<file context>
@@ -0,0 +1,348 @@
+
+  public ApiClient setFeignBuilder(Feign.Builder feignBuilder) {
+    this.feignBuilder = feignBuilder;
+    this.feignBuilder.contract(jsonHeaderContract());
+    return this;
+  }
</file context>

with:
distribution: 'temurin'
java-version: 17
cache: gradle

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: This job enables setup-java's Gradle cache, then restores and saves ~/.gradle/caches again in the next cache step. Remove one mechanism to avoid duplicate cache traffic and cache entries.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/samples-java-feign.yaml, line 39:

<comment>This job enables setup-java's Gradle cache, then restores and saves `~/.gradle/caches` again in the next cache step. Remove one mechanism to avoid duplicate cache traffic and cache entries.</comment>

<file context>
@@ -0,0 +1,73 @@
+        with:
+          distribution: 'temurin'
+          java-version: 17
+          cache: gradle
+      - name: Cache maven dependencies
+        uses: actions/cache@v6
</file context>

/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod

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: Typo in the Javadoc: "response bod" should be "response body". This comes from the generator template Java/libraries/feign/model/ApiResponse.mustache, so fix it there and regenerate rather than editing this generated file by hand.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-tagged-oneof/src/main/java/org/openapitools/client/model/ApiResponse.java, line 36:

<comment>Typo in the Javadoc: "response bod" should be "response body". This comes from the generator template `Java/libraries/feign/model/ApiResponse.mustache`, so fix it there and regenerate rather than editing this generated file by hand.</comment>

<file context>
@@ -0,0 +1,56 @@
+    /**
+     * @param statusCode The status code of HTTP response
+     * @param headers The headers of HTTP response
+     * @param data The object deserialized from response bod
+     */
+    public ApiResponse(int statusCode, Map<String, Collection<String>> headers, T data) {
</file context>

File file;
if (filename != null) {
// Sanitize: strip path components to prevent path traversal
String safeName = Paths.get(filename).getFileName().toString();

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: A malformed or platform-invalid Content-Disposition filename makes this throw instead of falling back. Paths.get("/").getFileName() returns null, so .toString() throws an NPE. On Windows, names with : throw InvalidPathException. Handle the null case and fall back to a generated name.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiResponseDecoder.java, line 90:

<comment>A malformed or platform-invalid `Content-Disposition` filename makes this throw instead of falling back. `Paths.get("/").getFileName()` returns null, so `.toString()` throws an NPE. On Windows, names with `:` throw `InvalidPathException`. Handle the null case and fall back to a generated name.</comment>

<file context>
@@ -0,0 +1,116 @@
+        File file;
+        if (filename != null) {
+            // Sanitize: strip path components to prevent path traversal
+            String safeName = Paths.get(filename).getFileName().toString();
+            java.nio.file.Path tempDir = Files.createTempDirectory("feign-download");
+            file = Files.createFile(tempDir.resolve(safeName)).toFile();
</file context>

public String expand(Object value) {
try {
if (value instanceof JsonHeaderIterable) value = ((JsonHeaderIterable) value).value;
return client.objectMapper.copy()

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: expand copies the whole ObjectMapper for every header value. copy() starts with empty serializer caches, so each call re-introspects the type. Build the configured copy once, for example when the ApiClient is constructed or when the mapper is set, and reuse it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/src/main/java/org/openapitools/client/ApiClient.java, line 59:

<comment>`expand` copies the whole `ObjectMapper` for every header value. `copy()` starts with empty serializer caches, so each call re-introspects the type. Build the configured copy once, for example when the `ApiClient` is constructed or when the mapper is set, and reuse it.</comment>

<file context>
@@ -0,0 +1,348 @@
+    public String expand(Object value) {
+      try {
+        if (value instanceof JsonHeaderIterable) value = ((JsonHeaderIterable) value).value;
+        return client.objectMapper.copy()
+            .setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)
+            .writer()
</file context>

```java

//Set bearer token manually
ApiClient apiClient = new ApiClient("petstore_auth_client");

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: The usage example does not describe this generated client: every nonempty auth constructor throws, and the documented auth methods and API types are absent. Replace it with a compiling new ApiClient()/DefaultApi example for this sample.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/petstore/java/feign-jackson-json-header/README.md, line 40:

<comment>The usage example does not describe this generated client: every nonempty auth constructor throws, and the documented auth methods and API types are absent. Replace it with a compiling `new ApiClient()`/`DefaultApi` example for this sample.</comment>

<file context>
@@ -0,0 +1,77 @@
+```java
+
+    //Set bearer token manually
+    ApiClient apiClient = new ApiClient("petstore_auth_client");
+    apiClient.setBasePath("https://localhost:8243/petstore/1/");
+    apiClient.setAccessToken("TOKEN", 10000);
</file context>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant