Repository navigation
[java][native] support useOneOfInterfaces and useDeductionForOneOfInterfaces #25813
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,9 @@ | ||
| generatorName: java | ||
| outputDir: samples/client/others/java/native-oneof-interface | ||
| library: native | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/java/native/oneof-interface-deduction.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/Java | ||
| additionalProperties: | ||
| hideGenerationTimestamp: "true" | ||
| useOneOfInterfaces: "true" | ||
| useDeductionForOneOfInterfaces: "true" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,12 +56,14 @@ import org.hibernate.validator.constraints.*; | |
|
|
||
| {{#models}} | ||
| {{#model}} | ||
| {{^vendorExtensions.x-is-one-of-interface}} | ||
| {{#oneOf}} | ||
| {{#-first}} | ||
| import {{jacksonPackage}}.core.type.TypeReference; | ||
| {{/-first}} | ||
| {{/oneOf}} | ||
| {{/vendorExtensions.x-is-one-of-interface}} | ||
|
|
||
| {{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#oneOf}}{{#-first}}{{>oneof_model}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>anyof_model}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>pojo}}{{/anyOf}}{{/oneOf}}{{/isEnum}} | ||
| {{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}{{^vendorExtensions.x-is-one-of-interface}}{{#oneOf}}{{#-first}}{{>oneof_model}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>anyof_model}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>pojo}}{{/anyOf}}{{/oneOf}}{{/vendorExtensions.x-is-one-of-interface}}{{/isEnum}} | ||
|
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. P2: With Prompt for AI agents |
||
| {{/model}} | ||
| {{/models}} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {{#supportUrlQuery}} | ||
| /** | ||
| * Convert the instance into URL query string. | ||
| * | ||
| * @param prefix prefix of the query string | ||
| * @return URL query string | ||
| */ | ||
| public String toUrlQueryString(String prefix); | ||
|
|
||
| /** | ||
| * Convert the instance into URL query string. | ||
| * | ||
| * @return URL query string | ||
| */ | ||
| default String toUrlQueryString() { | ||
| return toUrlQueryString(null); | ||
| } | ||
| {{/supportUrlQuery}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{! Hook for libraries that need extra members on the generated oneOf interface; see libraries/native. }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| openapi: 3.0.3 | ||
| info: | ||
| title: oneOf without discriminator | ||
| description: > | ||
| oneOf of two object schemas without a discriminator. The variants are told apart by their | ||
| (disjoint) sets of properties, which is what useDeductionForOneOfInterfaces relies on. | ||
| version: 1.0.0 | ||
| paths: | ||
| /author: | ||
| get: | ||
| operationId: getAuthor | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Author' | ||
| post: | ||
| operationId: createAuthor | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Author' | ||
| responses: | ||
| '204': | ||
| description: created | ||
| components: | ||
| schemas: | ||
| Author: | ||
| oneOf: | ||
| - $ref: '#/components/schemas/ServiceAuthor' | ||
| - $ref: '#/components/schemas/UserAuthor' | ||
| ServiceAuthor: | ||
| type: object | ||
| required: | ||
| - subject | ||
| properties: | ||
| subject: | ||
| type: string | ||
| UserAuthor: | ||
| type: object | ||
| required: | ||
| - id | ||
| - domainId | ||
| properties: | ||
| id: | ||
| type: string | ||
| domainId: | ||
| type: string |
| 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 oneOf without discriminator | ||
| 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,36 @@ | ||
| .github/workflows/maven.yml | ||
| .gitignore | ||
| .travis.yml | ||
| README.md | ||
| api/openapi.yaml | ||
| build.gradle | ||
| build.sbt | ||
| docs/Author.md | ||
| docs/DefaultApi.md | ||
| docs/ServiceAuthor.md | ||
| docs/UserAuthor.md | ||
| 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/ApiException.java | ||
| src/main/java/org/openapitools/client/ApiResponse.java | ||
| src/main/java/org/openapitools/client/Configuration.java | ||
| src/main/java/org/openapitools/client/JSON.java | ||
| src/main/java/org/openapitools/client/Pair.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/api/DefaultApi.java | ||
| src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java | ||
| src/main/java/org/openapitools/client/model/Author.java | ||
| src/main/java/org/openapitools/client/model/ServiceAuthor.java | ||
| src/main/java/org/openapitools/client/model/UserAuthor.java |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.28.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # | ||
| # Generated by: https://openapi-generator.tech | ||
| # | ||
| language: java | ||
| jdk: | ||
| - oraclejdk11 | ||
| before_install: | ||
| # ensure gradlew has proper permission | ||
| - chmod a+x ./gradlew | ||
| script: | ||
| # test using maven | ||
| - mvn test | ||
| # uncomment below to test using gradle | ||
| # - gradle test | ||
| # uncomment below to test using sbt | ||
| # - sbt test |
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: This matrix entry never exercises the sample's Gradle build because the workflow checks for
./gradlewat repository root. Gate the step withhashFiles(format('{0}/gradlew', matrix.sample))instead.Prompt for AI agents