Repository navigation
[java][Feign] consolidate Java Feign client tests #25967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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/** | ||
| - 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Prompt for AI agents |
||
| - 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 | ||
This file was deleted.
This file was deleted.
| 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 |
| 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 |
| 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 |
| 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 |
| 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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Prompt for AI agents |
||
| 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 | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Changes to
JavaClientCodegen.javaor 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