Skip to content

Commit 9fae221

Browse files
authored
[Java][okhttp-gson] add echo client test (#14442)
* add echo api tests for java okhttp client * test okhttp gson echo client in jdk8 workflow * update samples
1 parent b1f8f97 commit 9fae221

File tree

68 files changed

+8787
-0
lines changed

Some content is hidden

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

68 files changed

+8787
-0
lines changed

.github/workflows/samples-java-client-echo-api-jdk8.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
paths:
66
- samples/client/echo_api/java/apache-httpclient/**
77
- samples/client/echo_api/java/feign-gson/**
8+
- samples/client/echo_api/java/okhttp-gson/**
89
pull_request:
910
paths:
1011
- samples/client/echo_api/java/apache-httpclient/**
1112
- samples/client/echo_api/java/feign-gson/**
13+
- samples/client/echo_api/java/okhttp-gson/**
1214
jobs:
1315
build:
1416
name: Build Java Client JDK8
@@ -20,6 +22,7 @@ jobs:
2022
# clients
2123
- samples/client/echo_api/java/apache-httpclient
2224
- samples/client/echo_api/java/feign-gson
25+
- samples/client/echo_api/java/okhttp-gson
2326
steps:
2427
- uses: actions/checkout@v3
2528
- uses: actions/setup-java@v3
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/echo_api/java/okhttp-gson
3+
#library: okhttp-gson
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
artifactId: echo-api-okhttp-gson
8+
hideGenerationTimestamp: "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 Echo Server API
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
java: [ '8' ]
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up JDK
24+
uses: actions/setup-java@v2
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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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/Bird.md
9+
docs/BirdAndCategory.md
10+
docs/BodyApi.md
11+
docs/Category.md
12+
docs/PathApi.md
13+
docs/Pet.md
14+
docs/QueryApi.md
15+
docs/Tag.md
16+
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
17+
git_push.sh
18+
gradle.properties
19+
gradle/wrapper/gradle-wrapper.jar
20+
gradle/wrapper/gradle-wrapper.properties
21+
gradlew
22+
gradlew.bat
23+
pom.xml
24+
settings.gradle
25+
src/main/AndroidManifest.xml
26+
src/main/java/org/openapitools/client/ApiCallback.java
27+
src/main/java/org/openapitools/client/ApiClient.java
28+
src/main/java/org/openapitools/client/ApiException.java
29+
src/main/java/org/openapitools/client/ApiResponse.java
30+
src/main/java/org/openapitools/client/Configuration.java
31+
src/main/java/org/openapitools/client/GzipRequestInterceptor.java
32+
src/main/java/org/openapitools/client/JSON.java
33+
src/main/java/org/openapitools/client/Pair.java
34+
src/main/java/org/openapitools/client/ProgressRequestBody.java
35+
src/main/java/org/openapitools/client/ProgressResponseBody.java
36+
src/main/java/org/openapitools/client/ServerConfiguration.java
37+
src/main/java/org/openapitools/client/ServerVariable.java
38+
src/main/java/org/openapitools/client/StringUtil.java
39+
src/main/java/org/openapitools/client/api/BodyApi.java
40+
src/main/java/org/openapitools/client/api/PathApi.java
41+
src/main/java/org/openapitools/client/api/QueryApi.java
42+
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
43+
src/main/java/org/openapitools/client/auth/Authentication.java
44+
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
45+
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
46+
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
47+
src/main/java/org/openapitools/client/model/Bird.java
48+
src/main/java/org/openapitools/client/model/BirdAndCategory.java
49+
src/main/java/org/openapitools/client/model/Category.java
50+
src/main/java/org/openapitools/client/model/Pet.java
51+
src/main/java/org/openapitools/client/model/Tag.java
52+
src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.3.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: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# echo-api-okhttp-gson
2+
3+
Echo Server API
4+
- API version: 0.1.0
5+
6+
Echo Server API
7+
8+
9+
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
10+
11+
12+
## Requirements
13+
14+
Building the API client library requires:
15+
1. Java 1.8+
16+
2. Maven (3.8.3+)/Gradle (7.2+)
17+
18+
## Installation
19+
20+
To install the API client library to your local Maven repository, simply execute:
21+
22+
```shell
23+
mvn clean install
24+
```
25+
26+
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
27+
28+
```shell
29+
mvn clean deploy
30+
```
31+
32+
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
33+
34+
### Maven users
35+
36+
Add this dependency to your project's POM:
37+
38+
```xml
39+
<dependency>
40+
<groupId>org.openapitools</groupId>
41+
<artifactId>echo-api-okhttp-gson</artifactId>
42+
<version>0.1.0</version>
43+
<scope>compile</scope>
44+
</dependency>
45+
```
46+
47+
### Gradle users
48+
49+
Add this dependency to your project's build file:
50+
51+
```groovy
52+
repositories {
53+
mavenCentral() // Needed if the 'echo-api-okhttp-gson' jar has been published to maven central.
54+
mavenLocal() // Needed if the 'echo-api-okhttp-gson' jar has been published to the local maven repo.
55+
}
56+
57+
dependencies {
58+
implementation "org.openapitools:echo-api-okhttp-gson:0.1.0"
59+
}
60+
```
61+
62+
### Others
63+
64+
At first generate the JAR by executing:
65+
66+
```shell
67+
mvn clean package
68+
```
69+
70+
Then manually install the following JARs:
71+
72+
* `target/echo-api-okhttp-gson-0.1.0.jar`
73+
* `target/lib/*.jar`
74+
75+
## Getting Started
76+
77+
Please follow the [installation](#installation) instruction and execute the following Java code:
78+
79+
```java
80+
81+
// Import classes:
82+
import org.openapitools.client.ApiClient;
83+
import org.openapitools.client.ApiException;
84+
import org.openapitools.client.Configuration;
85+
import org.openapitools.client.models.*;
86+
import org.openapitools.client.api.BodyApi;
87+
88+
public class Example {
89+
public static void main(String[] args) {
90+
ApiClient defaultClient = Configuration.getDefaultApiClient();
91+
defaultClient.setBasePath("http://localhost:3000");
92+
93+
BodyApi apiInstance = new BodyApi(defaultClient);
94+
Pet pet = new Pet(); // Pet | Pet object that needs to be added to the store
95+
try {
96+
Pet result = apiInstance.testEchoBodyPet(pet);
97+
System.out.println(result);
98+
} catch (ApiException e) {
99+
System.err.println("Exception when calling BodyApi#testEchoBodyPet");
100+
System.err.println("Status code: " + e.getCode());
101+
System.err.println("Reason: " + e.getResponseBody());
102+
System.err.println("Response headers: " + e.getResponseHeaders());
103+
e.printStackTrace();
104+
}
105+
}
106+
}
107+
108+
```
109+
110+
## Documentation for API Endpoints
111+
112+
All URIs are relative to *http://localhost:3000*
113+
114+
Class | Method | HTTP request | Description
115+
------------ | ------------- | ------------- | -------------
116+
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s)
117+
*PathApi* | [**testsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testsPathStringPathStringIntegerPathInteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s)
118+
*QueryApi* | [**testQueryIntegerBooleanString**](docs/QueryApi.md#testQueryIntegerBooleanString) | **GET** /query/integer/boolean/string | Test query parameter(s)
119+
*QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#testQueryStyleDeepObjectExplodeTrueObject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s)
120+
*QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s)
121+
*QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s)
122+
*QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s)
123+
124+
125+
## Documentation for Models
126+
127+
- [Bird](docs/Bird.md)
128+
- [BirdAndCategory](docs/BirdAndCategory.md)
129+
- [Category](docs/Category.md)
130+
- [Pet](docs/Pet.md)
131+
- [Tag](docs/Tag.md)
132+
- [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
133+
134+
135+
## Documentation for Authorization
136+
137+
All endpoints do not require authorization.
138+
Authentication schemes defined for the API:
139+
140+
## Recommendation
141+
142+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
143+
144+
## Author
145+
146+
team@openapitools.org
147+

0 commit comments

Comments
 (0)