-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[java][microprofile] Extend support for useOneOfInterfaces to the microprofile library when Jackson serialisation is enabled #24190
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
Open
Ignacio-Vidal
wants to merge
1
commit into
OpenAPITools:master
Choose a base branch
from
Ignacio-Vidal:mp-client-oneof-interface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| generatorName: java | ||
| outputDir: samples/client/petstore/java/microprofile-oneof-interface | ||
| library: microprofile | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/java/oneof_interface_petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/Java | ||
| additionalProperties: | ||
| serializationLibrary: jackson | ||
| artifactId: microprofile-oneof-interface | ||
| useOneOfInterfaces: "true" | ||
| microprofileRestClientVersion: "3.0" | ||
| hideGenerationTimestamp: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
modules/openapi-generator/src/test/resources/3_0/java/oneof_interface_petstore.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| openapi: 3.0.3 | ||
| info: | ||
| title: oneOf interface petstore | ||
| description: > | ||
| A minimal, self-consistent oneOf-interface spec for the Java (microprofile) client generator. | ||
| The oneOf container and the shared base both declare the discriminator property so the interface | ||
| getter resolves to the enum type. Children inherit the base via allOf and only implement the | ||
| generated interface. | ||
| version: 1.0.0 | ||
| paths: | ||
| /pets: | ||
| post: | ||
| operationId: createPet | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/PetRequest' | ||
| responses: | ||
| '200': | ||
| description: created | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/PetRequest' | ||
| components: | ||
| schemas: | ||
| PetType: | ||
| type: string | ||
| enum: | ||
| - CAT | ||
| - DOG | ||
| description: Discriminator value identifying the type of pet | ||
|
|
||
| PetRequest: | ||
| type: object | ||
| properties: | ||
| petType: | ||
| $ref: '#/components/schemas/PetType' | ||
| oneOf: | ||
| - $ref: '#/components/schemas/CatRequest' | ||
| - $ref: '#/components/schemas/DogRequest' | ||
| discriminator: | ||
| propertyName: petType | ||
| mapping: | ||
| CAT: '#/components/schemas/CatRequest' | ||
| DOG: '#/components/schemas/DogRequest' | ||
|
|
||
| PetBase: | ||
| type: object | ||
| required: | ||
| - petType | ||
| - name | ||
| properties: | ||
| petType: | ||
| $ref: '#/components/schemas/PetType' | ||
| name: | ||
| type: string | ||
|
|
||
| CatRequest: | ||
| allOf: | ||
| - $ref: '#/components/schemas/PetBase' | ||
| - type: object | ||
| required: | ||
| - indoor | ||
| properties: | ||
| indoor: | ||
| type: boolean | ||
|
|
||
| DogRequest: | ||
| allOf: | ||
| - $ref: '#/components/schemas/PetBase' | ||
| - type: object | ||
| required: | ||
| - trained | ||
| properties: | ||
| trained: | ||
| type: boolean |
23 changes: 23 additions & 0 deletions
23
samples/client/petstore/java/microprofile-oneof-interface/.openapi-generator-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
19 changes: 19 additions & 0 deletions
19
samples/client/petstore/java/microprofile-oneof-interface/.openapi-generator/FILES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| README.md | ||
| docs/CatRequest.md | ||
| docs/DefaultApi.md | ||
| docs/DogRequest.md | ||
| docs/PetBase.md | ||
| docs/PetRequest.md | ||
| docs/PetType.md | ||
| pom.xml | ||
| 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/api/ApiException.java | ||
| src/main/java/org/openapitools/client/api/ApiExceptionMapper.java | ||
| src/main/java/org/openapitools/client/api/DefaultApi.java | ||
| src/main/java/org/openapitools/client/model/CatRequest.java | ||
| src/main/java/org/openapitools/client/model/DogRequest.java | ||
| src/main/java/org/openapitools/client/model/PetBase.java | ||
| src/main/java/org/openapitools/client/model/PetRequest.java | ||
| src/main/java/org/openapitools/client/model/PetType.java |
1 change: 1 addition & 0 deletions
1
samples/client/petstore/java/microprofile-oneof-interface/.openapi-generator/VERSION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.24.0-SNAPSHOT |
10 changes: 10 additions & 0 deletions
10
samples/client/petstore/java/microprofile-oneof-interface/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # oneOf interface petstore - MicroProfile Rest Client & MicroProfile Server | ||
|
|
||
| A minimal, self-consistent oneOf-interface spec for the Java (microprofile) client generator. The oneOf container and the shared base both declare the discriminator property so the interface getter resolves to the enum type. Children inherit the base via allOf and only implement the generated interface. | ||
|
|
||
|
|
||
| ## Overview | ||
| This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
| [MicroProfile Rest Client](https://github.com/eclipse/microprofile-rest-client) is a type-safe way of calling | ||
| REST services. The generated client contains an interface which acts as the client, you can inject it into dependent classes. | ||
|
|
19 changes: 19 additions & 0 deletions
19
samples/client/petstore/java/microprofile-oneof-interface/docs/CatRequest.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
|
|
||
| # CatRequest | ||
|
|
||
|
|
||
| ## Properties | ||
|
|
||
| | Name | Type | Description | Notes | | ||
| |------------ | ------------- | ------------- | -------------| | ||
| |**petType** | **PetType** | | | | ||
| |**name** | **String** | | | | ||
| |**indoor** | **Boolean** | | | | ||
|
|
||
|
|
||
| ## Implemented Interfaces | ||
|
|
||
| * PetRequest | ||
|
|
||
|
|
73 changes: 73 additions & 0 deletions
73
samples/client/petstore/java/microprofile-oneof-interface/docs/DefaultApi.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # DefaultApi | ||
|
|
||
| All URIs are relative to *http://localhost* | ||
|
|
||
| | Method | HTTP request | Description | | ||
| |------------- | ------------- | -------------| | ||
| | [**createPet**](DefaultApi.md#createPet) | **POST** /pets | | | ||
|
|
||
|
|
||
|
|
||
| ## createPet | ||
|
|
||
| > PetRequest createPet(petRequest) | ||
|
|
||
|
|
||
|
|
||
| ### Example | ||
|
|
||
| ```java | ||
| // Import classes: | ||
| import org.openapitools.client.ApiClient; | ||
| import org.openapitools.client.ApiException; | ||
| import org.openapitools.client.Configuration; | ||
| import org.openapitools.client.models.*; | ||
| import org.openapitools.client.api.DefaultApi; | ||
|
|
||
| public class Example { | ||
| public static void main(String[] args) { | ||
| ApiClient defaultClient = Configuration.getDefaultApiClient(); | ||
| defaultClient.setBasePath("http://localhost"); | ||
|
|
||
| DefaultApi apiInstance = new DefaultApi(defaultClient); | ||
| PetRequest petRequest = new PetRequest(); // PetRequest | | ||
| try { | ||
| PetRequest result = apiInstance.createPet(petRequest); | ||
| System.out.println(result); | ||
| } catch (ApiException e) { | ||
| System.err.println("Exception when calling DefaultApi#createPet"); | ||
| System.err.println("Status code: " + e.getCode()); | ||
| System.err.println("Reason: " + e.getResponseBody()); | ||
| System.err.println("Response headers: " + e.getResponseHeaders()); | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
|
|
||
| | Name | Type | Description | Notes | | ||
| |------------- | ------------- | ------------- | -------------| | ||
| | **petRequest** | [**PetRequest**](PetRequest.md)| | | | ||
|
|
||
| ### Return type | ||
|
|
||
| [**PetRequest**](PetRequest.md) | ||
|
|
||
| ### Authorization | ||
|
|
||
| No authorization required | ||
|
|
||
| ### HTTP request headers | ||
|
|
||
| - **Content-Type**: application/json | ||
| - **Accept**: application/json | ||
|
|
||
|
|
||
| ### HTTP response details | ||
| | Status code | Description | Response headers | | ||
| |-------------|-------------|------------------| | ||
| | **200** | created | - | | ||
|
|
19 changes: 19 additions & 0 deletions
19
samples/client/petstore/java/microprofile-oneof-interface/docs/DogRequest.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
|
|
||
| # DogRequest | ||
|
|
||
|
|
||
| ## Properties | ||
|
|
||
| | Name | Type | Description | Notes | | ||
| |------------ | ------------- | ------------- | -------------| | ||
| |**petType** | **PetType** | | | | ||
| |**name** | **String** | | | | ||
| |**trained** | **Boolean** | | | | ||
|
|
||
|
|
||
| ## Implemented Interfaces | ||
|
|
||
| * PetRequest | ||
|
|
||
|
|
14 changes: 14 additions & 0 deletions
14
samples/client/petstore/java/microprofile-oneof-interface/docs/PetBase.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
|
|
||
|
|
||
| # PetBase | ||
|
|
||
|
|
||
| ## Properties | ||
|
|
||
| | Name | Type | Description | Notes | | ||
| |------------ | ------------- | ------------- | -------------| | ||
| |**petType** | **PetType** | | | | ||
| |**name** | **String** | | | | ||
|
|
||
|
|
||
|
|
10 changes: 10 additions & 0 deletions
10
samples/client/petstore/java/microprofile-oneof-interface/docs/PetRequest.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
|
|
||
| # Interface PetRequest | ||
|
|
||
| ## Implementing Classes | ||
|
|
||
| * CatRequest | ||
| * DogRequest | ||
|
|
||
|
|
13 changes: 13 additions & 0 deletions
13
samples/client/petstore/java/microprofile-oneof-interface/docs/PetType.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
|
|
||
|
|
||
| # PetType | ||
|
|
||
| ## Enum | ||
|
|
||
|
|
||
| * `CAT` (value: `"CAT"`) | ||
|
|
||
| * `DOG` (value: `"DOG"`) | ||
|
|
||
|
|
||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
please add the new output folder to the gihtub workflow for java client in https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-java-client-jdk11.yaml