Skip to content

Commit 7690545

Browse files
authored
add sample to test useGzipFeature in java native (#22361)
1 parent ecb1e9e commit 7690545

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4215
-0
lines changed

.github/workflows/samples-java-client-jdk11.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
- samples/client/petstore/java/native
6262
- samples/client/petstore/java/native-async
6363
- samples/client/petstore/java/native-jakarta
64+
- samples/client/petstore/java/native-useGzipFeature
6465
- samples/client/petstore/java/retrofit2
6566
- samples/client/petstore/java/retrofit2rx2
6667
- samples/client/petstore/java/retrofit2rx3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
generatorName: java
2+
outputDir: samples/client/petstore/java/native-useGzipFeature
3+
library: native
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
artifactId: petstore-native-useGzipFeature
8+
hideGenerationTimestamp: "true"
9+
useJakartaEe: "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 OpenAPI Petstore
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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.github/workflows/maven.yml
2+
.gitignore
3+
.travis.yml
4+
README.md
5+
api/openapi.yaml
6+
build.gradle
7+
build.sbt
8+
docs/Category.md
9+
docs/Pet.md
10+
docs/PetApi.md
11+
docs/Tag.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/Pair.java
27+
src/main/java/org/openapitools/client/RFC3339DateFormat.java
28+
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
29+
src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java
30+
src/main/java/org/openapitools/client/ServerConfiguration.java
31+
src/main/java/org/openapitools/client/ServerVariable.java
32+
src/main/java/org/openapitools/client/api/PetApi.java
33+
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
34+
src/main/java/org/openapitools/client/model/Category.java
35+
src/main/java/org/openapitools/client/model/Pet.java
36+
src/main/java/org/openapitools/client/model/Tag.java
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.18.0-SNAPSHOT
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Generated by: https://openapi-generator.tech
3+
#
4+
language: java
5+
jdk:
6+
- oraclejdk11
7+
before_install:
8+
# ensure gradlew has proper permission
9+
- chmod a+x ./gradlew
10+
script:
11+
# test using maven
12+
- mvn test
13+
# uncomment below to test using gradle
14+
# - gradle test
15+
# uncomment below to test using sbt
16+
# - sbt test
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# petstore-native-useGzipFeature
2+
3+
OpenAPI Petstore
4+
5+
- API version: 1.0.0
6+
7+
- Generator version: 7.18.0-SNAPSHOT
8+
9+
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
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 11+
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>petstore-native-useGzipFeature</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+
compile "org.openapitools:petstore-native-useGzipFeature:1.0.0"
56+
```
57+
58+
### Others
59+
60+
At first generate the JAR by executing:
61+
62+
```shell
63+
mvn clean package
64+
```
65+
66+
Then manually install the following JARs:
67+
68+
- `target/petstore-native-useGzipFeature-1.0.0.jar`
69+
- `target/lib/*.jar`
70+
71+
## Getting Started
72+
73+
Please follow the [installation](#installation) instruction and execute the following Java code:
74+
75+
```java
76+
77+
import org.openapitools.client.*;
78+
import org.openapitools.client.model.*;
79+
import org.openapitools.client.api.PetApi;
80+
81+
public class PetApiExample {
82+
83+
public static void main(String[] args) {
84+
ApiClient defaultClient = Configuration.getDefaultApiClient();
85+
// Configure clients using the `defaultClient` object, such as
86+
// overriding the host and port, timeout, etc.
87+
PetApi apiInstance = new PetApi(defaultClient);
88+
Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
89+
try {
90+
Pet result = apiInstance.addPet(pet);
91+
System.out.println(result);
92+
} catch (ApiException e) {
93+
System.err.println("Exception when calling PetApi#addPet");
94+
System.err.println("Status code: " + e.getCode());
95+
System.err.println("Reason: " + e.getResponseBody());
96+
System.err.println("Response headers: " + e.getResponseHeaders());
97+
e.printStackTrace();
98+
}
99+
}
100+
}
101+
102+
```
103+
104+
## Documentation for API Endpoints
105+
106+
All URIs are relative to *http://petstore.swagger.io/v2*
107+
108+
Class | Method | HTTP request | Description
109+
------------ | ------------- | ------------- | -------------
110+
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
111+
*PetApi* | [**addPetWithHttpInfo**](docs/PetApi.md#addPetWithHttpInfo) | **POST** /pet | Add a new pet to the store
112+
113+
114+
## Documentation for Models
115+
116+
- [Category](docs/Category.md)
117+
- [Pet](docs/Pet.md)
118+
- [Tag](docs/Tag.md)
119+
120+
121+
<a id="documentation-for-authorization"></a>
122+
## Documentation for Authorization
123+
124+
125+
Authentication schemes defined for the API:
126+
<a id="petstore_auth"></a>
127+
### petstore_auth
128+
129+
130+
- **Type**: OAuth
131+
- **Flow**: implicit
132+
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
133+
- **Scopes**:
134+
- write:pets: modify pets in your account
135+
- read:pets: read your pets
136+
137+
138+
## Recommendation
139+
140+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
141+
However, the instances of the api clients created from the `ApiClient` are thread-safe and can be re-used.
142+
143+
## Author
144+
145+
146+

0 commit comments

Comments
 (0)