Skip to content

Commit 7830618

Browse files
committed
Add sample demonstrating useOneOfPojo option
- Added bin/configs/java-jersey3-oneOf-pojo.yaml config with useOneOfPojo: true - Generated samples/client/petstore/java/jersey3-oneOf-pojo/ - Demonstrates how useOneOfPojo=true generates real POJO classes instead of wrapper models
1 parent 09ed65d commit 7830618

47 files changed

Lines changed: 4415 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generatorName: java
2+
outputDir: samples/client/petstore/java/jersey3-oneOf-pojo
3+
library: jersey3
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_additionalProperties.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
hideGenerationTimestamp: true
8+
useOneOfPojo: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
#
4+
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
5+
6+
name: Java CI with Maven
7+
8+
on:
9+
push:
10+
branches: [ main, master ]
11+
pull_request:
12+
branches: [ main, master ]
13+
14+
jobs:
15+
build:
16+
name: Build dummy
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
java: [ 17, 21 ]
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up JDK
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: ${{ matrix.java }}
27+
distribution: 'temurin'
28+
cache: maven
29+
- name: Build with Maven
30+
run: mvn -B package --no-transfer-progress --file pom.xml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.class
2+
3+
# Mobile Tools for Java (J2ME)
4+
.mtj.tmp/
5+
6+
# Package Files #
7+
*.jar
8+
*.war
9+
*.ear
10+
11+
# exclude jar for gradle wrapper
12+
!gradle/wrapper/*.jar
13+
14+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
15+
hs_err_pid*
16+
17+
# build files
18+
**/target
19+
target
20+
.gradle
21+
build
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.github/workflows/maven.yml
2+
.gitignore
3+
.openapi-generator-ignore
4+
.travis.yml
5+
README.md
6+
api/openapi.yaml
7+
build.gradle
8+
build.sbt
9+
docs/DefaultApi.md
10+
docs/PostRequest.md
11+
docs/SchemaA.md
12+
git_push.sh
13+
gradle.properties
14+
gradle/wrapper/gradle-wrapper.jar
15+
gradle/wrapper/gradle-wrapper.properties
16+
gradlew
17+
gradlew.bat
18+
pom.xml
19+
settings.gradle
20+
src/main/AndroidManifest.xml
21+
src/main/java/org/openapitools/client/ApiClient.java
22+
src/main/java/org/openapitools/client/ApiException.java
23+
src/main/java/org/openapitools/client/ApiResponse.java
24+
src/main/java/org/openapitools/client/Configuration.java
25+
src/main/java/org/openapitools/client/JSON.java
26+
src/main/java/org/openapitools/client/JavaTimeFormatter.java
27+
src/main/java/org/openapitools/client/Pair.java
28+
src/main/java/org/openapitools/client/RFC3339DateFormat.java
29+
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
30+
src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java
31+
src/main/java/org/openapitools/client/ServerConfiguration.java
32+
src/main/java/org/openapitools/client/ServerVariable.java
33+
src/main/java/org/openapitools/client/StringUtil.java
34+
src/main/java/org/openapitools/client/api/DefaultApi.java
35+
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
36+
src/main/java/org/openapitools/client/auth/Authentication.java
37+
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
38+
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
39+
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
40+
src/main/java/org/openapitools/client/model/PostRequest.java
41+
src/main/java/org/openapitools/client/model/SchemaA.java
42+
src/test/java/org/openapitools/client/api/DefaultApiTest.java
43+
src/test/java/org/openapitools/client/model/PostRequestTest.java
44+
src/test/java/org/openapitools/client/model/SchemaATest.java
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.22.0-SNAPSHOT
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Generated by OpenAPI Generator: https://openapi-generator.tech
3+
#
4+
# Ref: https://docs.travis-ci.com/user/languages/java/
5+
#
6+
language: java
7+
jdk:
8+
- openjdk12
9+
- openjdk11
10+
- openjdk10
11+
- openjdk9
12+
- openjdk8
13+
before_install:
14+
# ensure gradlew has proper permission
15+
- chmod a+x ./gradlew
16+
script:
17+
# test using maven
18+
#- mvn test
19+
# test using gradle
20+
- gradle test
21+
# test using sbt
22+
# - sbt test
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# openapi-java-client
2+
3+
dummy
4+
5+
- API version: 1.0.0
6+
7+
- Generator version: 7.22.0-SNAPSHOT
8+
9+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
10+
11+
12+
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
13+
14+
## Requirements
15+
16+
Building the API client library requires:
17+
18+
1. Java 1.8+
19+
2. Maven/Gradle
20+
21+
## Installation
22+
23+
To install the API client library to your local Maven repository, simply execute:
24+
25+
```shell
26+
mvn clean install
27+
```
28+
29+
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
30+
31+
```shell
32+
mvn clean deploy
33+
```
34+
35+
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
36+
37+
### Maven users
38+
39+
Add this dependency to your project's POM:
40+
41+
```xml
42+
<dependency>
43+
<groupId>org.openapitools</groupId>
44+
<artifactId>openapi-java-client</artifactId>
45+
<version>1.0.0</version>
46+
<scope>compile</scope>
47+
</dependency>
48+
```
49+
50+
### Gradle users
51+
52+
Add this dependency to your project's build file:
53+
54+
```groovy
55+
repositories {
56+
mavenCentral() // Needed if the 'openapi-java-client' jar has been published to maven central.
57+
mavenLocal() // Needed if the 'openapi-java-client' jar has been published to the local maven repo.
58+
}
59+
60+
dependencies {
61+
implementation "org.openapitools:openapi-java-client:1.0.0"
62+
}
63+
```
64+
65+
### Others
66+
67+
At first generate the JAR by executing:
68+
69+
```shell
70+
mvn clean package
71+
```
72+
73+
Then manually install the following JARs:
74+
75+
- `target/openapi-java-client-1.0.0.jar`
76+
- `target/lib/*.jar`
77+
78+
## Getting Started
79+
80+
Please follow the [installation](#installation) instruction and execute the following Java code:
81+
82+
```java
83+
84+
import org.openapitools.client.*;
85+
import org.openapitools.client.auth.*;
86+
import org.openapitools.client.model.*;
87+
import org.openapitools.client.api.DefaultApi;
88+
89+
public class DefaultApiExample {
90+
91+
public static void main(String[] args) {
92+
ApiClient defaultClient = Configuration.getDefaultApiClient();
93+
defaultClient.setBasePath("http://localhost");
94+
95+
DefaultApi apiInstance = new DefaultApi(defaultClient);
96+
PostRequest postRequest = new PostRequest(); // PostRequest |
97+
try {
98+
apiInstance.rootPost(postRequest);
99+
} catch (ApiException e) {
100+
System.err.println("Exception when calling DefaultApi#rootPost");
101+
System.err.println("Status code: " + e.getCode());
102+
System.err.println("Reason: " + e.getResponseBody());
103+
System.err.println("Response headers: " + e.getResponseHeaders());
104+
e.printStackTrace();
105+
}
106+
}
107+
}
108+
109+
```
110+
111+
## Documentation for API Endpoints
112+
113+
All URIs are relative to *http://localhost*
114+
115+
Class | Method | HTTP request | Description
116+
------------ | ------------- | ------------- | -------------
117+
*DefaultApi* | [**rootPost**](docs/DefaultApi.md#rootPost) | **POST** / |
118+
119+
120+
## Documentation for Models
121+
122+
- [PostRequest](docs/PostRequest.md)
123+
- [SchemaA](docs/SchemaA.md)
124+
125+
126+
<a id="documentation-for-authorization"></a>
127+
## Documentation for Authorization
128+
129+
Endpoints do not require authorization.
130+
131+
132+
## Recommendation
133+
134+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
135+
136+
## Author
137+
138+
139+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
openapi: 3.0.3
2+
info:
3+
title: dummy
4+
version: 1.0.0
5+
servers:
6+
- url: /
7+
paths:
8+
/:
9+
post:
10+
requestBody:
11+
content:
12+
application/json:
13+
schema:
14+
$ref: "#/components/schemas/__post_request"
15+
responses:
16+
"200":
17+
description: OK
18+
x-content-type: application/json
19+
x-accepts:
20+
- application/json
21+
components:
22+
schemas:
23+
schemaA:
24+
properties:
25+
propA:
26+
type: string
27+
type: object
28+
__post_request:
29+
oneOf:
30+
- $ref: "#/components/schemas/schemaA"
31+
- additionalProperties: true
32+
properties: {}
33+
type: object
34+

0 commit comments

Comments
 (0)