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
73 changes: 73 additions & 0 deletions .github/workflows/samples-java-feign.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Samples Java Feign Client JDK17

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>

- samples/client/petstore/java/feign-hc5/**
- samples/client/petstore/java/feign-no-nullable/**
- samples/client/petstore/java/feign-jackson-json-header/**
- samples/client/petstore/java/feign-jackson-tagged-oneof/**

pull_request:
paths:
- samples/client/petstore/java/feign/**
- samples/client/petstore/java/feign-hc5/**
- samples/client/petstore/java/feign-no-nullable/**
- samples/client/petstore/java/feign-jackson-json-header/**
- samples/client/petstore/java/feign-jackson-tagged-oneof/**
jobs:
build:
name: Build Java Client JDK17
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
# clients
- samples/client/petstore/java/feign/
- samples/client/petstore/java/feign-hc5/
- samples/client/petstore/java/feign-no-nullable/
- samples/client/petstore/java/feign-jackson-json-header/
- samples/client/petstore/java/feign-jackson-tagged-oneof/
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
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>

- name: Cache maven dependencies
uses: actions/cache@v6
env:
cache-name: maven-repository
with:
path: |
~/.m2
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}

- name: Build with Maven
working-directory: ${{ matrix.sample }}
run: mvn clean package --no-transfer-progress

- name: Cache gradle dependencies
uses: actions/cache@v6
env:
cache-name: gradle-caches
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/*.gradle', '**/*.gradle.kts') }}

- name: Cache gradle wrapper
uses: actions/cache@v6
env:
cache-name: gradle-wrapper
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

- name: Build
working-directory: ${{ matrix.sample }}
# the microprofile library does not generate a Gradle build; skip samples without a wrapper
if: ${{ hashFiles(format('{0}/gradlew', matrix.sample)) != '' }}
run: /bin/sh gradlew build -x test --no-daemon
32 changes: 0 additions & 32 deletions .github/workflows/test-java-feign-jackson-headers.yaml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/test-java-feign-jackson-oneof.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions bin/configs/java-feign-jackson-json-header.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generatorName: java
outputDir: samples/client/petstore/java/feign-jackson-json-header
library: feign
inputSpec: modules/openapi-generator/src/test/resources/3_1/java/feign-jackson-json-header.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
booleanGetterPrefix: is
artifactId: feign-jackson-json-header
hideGenerationTimestamp: "true"
serializationLibrary: jackson
9 changes: 9 additions & 0 deletions bin/configs/java-feign-jackson-tagged-oneof.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
generatorName: java
outputDir: samples/client/petstore/java/feign-jackson-tagged-oneof
library: feign
inputSpec: modules/openapi-generator/src/test/resources/3_1/java/feign-jackson-tagged-oneof.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
booleanGetterPrefix: is
artifactId: feign-jackson-tagged-oneof
hideGenerationTimestamp: "true"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
#
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)

name: Java CI with Maven

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
name: Build Feign JSON header
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --no-transfer-progress --file pom.xml
21 changes: 21 additions & 0 deletions samples/client/petstore/java/feign-jackson-json-header/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# exclude jar for gradle wrapper
!gradle/wrapper/*.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# build files
**/target
target
.gradle
build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.github/workflows/maven.yml
.gitignore
.travis.yml
README.md
api/openapi.yaml
build.gradle
build.sbt
git_push.sh
gradle.properties
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
pom.xml
settings.gradle
src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiClient.java
src/main/java/org/openapitools/client/ApiResponseDecoder.java
src/main/java/org/openapitools/client/EncodingUtils.java
src/main/java/org/openapitools/client/ParamExpander.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
src/main/java/org/openapitools/client/api/DefaultApi.java
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
src/main/java/org/openapitools/client/model/ApiResponse.java
src/main/java/org/openapitools/client/model/HeaderArg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.29.0-SNAPSHOT
22 changes: 22 additions & 0 deletions samples/client/petstore/java/feign-jackson-json-header/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
# Ref: https://docs.travis-ci.com/user/languages/java/
#
language: java
jdk:
- openjdk12
- openjdk11
- openjdk10
- openjdk9
- openjdk8
before_install:
# ensure gradlew has proper permission
- chmod a+x ./gradlew
script:
# test using maven
#- mvn test
# test using gradle
- gradle test
# test using sbt
# - sbt test
77 changes: 77 additions & 0 deletions samples/client/petstore/java/feign-jackson-json-header/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# feign-jackson-json-header

## Requirements

Building the API client library requires [Maven](https://maven.apache.org/) to be installed.

## Installation & Usage

To install the API client library to your local Maven repository, simply execute:

```shell
mvn install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn deploy
```

Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.

After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*:

```xml
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>feign-jackson-json-header</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>

```

And to use the api you can follow the examples below:

```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>

apiClient.setBasePath("https://localhost:8243/petstore/1/");
apiClient.setAccessToken("TOKEN", 10000);

//Use api key
ApiClient apiClient = new ApiClient("api_key", "API KEY");
apiClient.setBasePath("https://localhost:8243/petstore/1/");

//Use http basic authentication
ApiClient apiClient = new ApiClient("basicAuth");
apiClient.setBasePath("https://localhost:8243/petstore/1/");
apiClient.setCredentials("username", "password");

//Oauth password
ApiClient apiClient = new ApiClient("oauth_password");
apiClient.setBasePath("https://localhost:8243/petstore/1/");
apiClient.setOauthPassword("username", "password", "client_id", "client_secret");

//Oauth client credentials flow
ApiClient apiClient = new ApiClient("oauth_client_credentials");
apiClient.setBasePath("https://localhost:8243/petstore/1/");
apiClient.setClientCredentials("client_id", "client_secret");

PetApi petApi = apiClient.buildClient(PetApi.class);
Pet petById = petApi.getPetById(12345L);

System.out.println(petById);
}
```

## Recommendation

It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.

## Author



Loading
Loading