Skip to content

Commit 602cffb

Browse files
authored
[java][okhttp] Add CI tests for streaming (#10678)
* add ci tests for streaming * use spaces instead of tabs * update samples
1 parent fcef9fa commit 602cffb

Some content is hidden

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

43 files changed

+4477
-0
lines changed
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/others/java/okhttp-gson-streaming
3+
library: okhttp-gson
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/streaming.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/Java
6+
additionalProperties:
7+
artifactId: petstore-okhttp-gson
8+
hideGenerationTimestamp: "true"
9+
supportStreaming: true

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@
12701270
<module>samples/client/petstore/java/jersey1</module>
12711271
<module>samples/client/petstore/java/jersey2-java8</module>
12721272
<module>samples/openapi3/client/petstore/java/jersey2-java8</module>
1273+
<module>samples/client/others/java/okhttp-gson-streaming</module>
12731274
<module>samples/client/petstore/java/okhttp-gson</module>
12741275
<module>samples/client/petstore/java/retrofit2</module>
12751276
<module>samples/client/petstore/java/retrofit2rx2</module>
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+
.gitignore
2+
.travis.yml
3+
README.md
4+
api/openapi.yaml
5+
build.gradle
6+
build.sbt
7+
docs/PingApi.md
8+
docs/SomeObj.md
9+
git_push.sh
10+
gradle.properties
11+
gradle/wrapper/gradle-wrapper.jar
12+
gradle/wrapper/gradle-wrapper.properties
13+
gradlew
14+
gradlew.bat
15+
pom.xml
16+
settings.gradle
17+
src/main/AndroidManifest.xml
18+
src/main/java/org/openapitools/client/ApiCallback.java
19+
src/main/java/org/openapitools/client/ApiClient.java
20+
src/main/java/org/openapitools/client/ApiException.java
21+
src/main/java/org/openapitools/client/ApiResponse.java
22+
src/main/java/org/openapitools/client/Configuration.java
23+
src/main/java/org/openapitools/client/GzipRequestInterceptor.java
24+
src/main/java/org/openapitools/client/JSON.java
25+
src/main/java/org/openapitools/client/Pair.java
26+
src/main/java/org/openapitools/client/ProgressRequestBody.java
27+
src/main/java/org/openapitools/client/ProgressResponseBody.java
28+
src/main/java/org/openapitools/client/ServerConfiguration.java
29+
src/main/java/org/openapitools/client/ServerVariable.java
30+
src/main/java/org/openapitools/client/StringUtil.java
31+
src/main/java/org/openapitools/client/api/PingApi.java
32+
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
33+
src/main/java/org/openapitools/client/auth/Authentication.java
34+
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
35+
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
36+
src/main/java/org/openapitools/client/model/SomeObj.java
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.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: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# petstore-okhttp-gson
2+
3+
ping some object
4+
- API version: 1.0
5+
6+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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.7+
16+
2. Maven/Gradle
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>petstore-okhttp-gson</artifactId>
42+
<version>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+
compile "org.openapitools:petstore-okhttp-gson:1.0"
53+
```
54+
55+
### Others
56+
57+
At first generate the JAR by executing:
58+
59+
```shell
60+
mvn clean package
61+
```
62+
63+
Then manually install the following JARs:
64+
65+
* `target/petstore-okhttp-gson-1.0.jar`
66+
* `target/lib/*.jar`
67+
68+
## Getting Started
69+
70+
Please follow the [installation](#installation) instruction and execute the following Java code:
71+
72+
```java
73+
74+
// Import classes:
75+
import org.openapitools.client.ApiClient;
76+
import org.openapitools.client.ApiException;
77+
import org.openapitools.client.Configuration;
78+
import org.openapitools.client.models.*;
79+
import org.openapitools.client.api.PingApi;
80+
81+
public class Example {
82+
public static void main(String[] args) {
83+
ApiClient defaultClient = Configuration.getDefaultApiClient();
84+
defaultClient.setBasePath("http://localhost:8082");
85+
86+
PingApi apiInstance = new PingApi(defaultClient);
87+
SomeObj someObj = new SomeObj(); // SomeObj |
88+
try {
89+
SomeObj result = apiInstance.postPing(someObj);
90+
System.out.println(result);
91+
} catch (ApiException e) {
92+
System.err.println("Exception when calling PingApi#postPing");
93+
System.err.println("Status code: " + e.getCode());
94+
System.err.println("Reason: " + e.getResponseBody());
95+
System.err.println("Response headers: " + e.getResponseHeaders());
96+
e.printStackTrace();
97+
}
98+
}
99+
}
100+
101+
```
102+
103+
## Documentation for API Endpoints
104+
105+
All URIs are relative to *http://localhost:8082*
106+
107+
Class | Method | HTTP request | Description
108+
------------ | ------------- | ------------- | -------------
109+
*PingApi* | [**postPing**](docs/PingApi.md#postPing) | **POST** /ping |
110+
111+
112+
## Documentation for Models
113+
114+
- [SomeObj](docs/SomeObj.md)
115+
116+
117+
## Documentation for Authorization
118+
119+
All endpoints do not require authorization.
120+
Authentication schemes defined for the API:
121+
122+
## Recommendation
123+
124+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
125+
126+
## Author
127+
128+
129+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
openapi: 3.0.1
2+
info:
3+
title: ping some object
4+
version: "1.0"
5+
servers:
6+
- url: http://localhost:8082/
7+
paths:
8+
/ping:
9+
post:
10+
operationId: postPing
11+
requestBody:
12+
content:
13+
application/json:
14+
schema:
15+
$ref: '#/components/schemas/SomeObj'
16+
responses:
17+
"200":
18+
content:
19+
application/json:
20+
schema:
21+
$ref: '#/components/schemas/SomeObj'
22+
description: OK
23+
tags:
24+
- ping
25+
x-streaming: true
26+
x-contentType: application/json
27+
x-accepts: application/json
28+
components:
29+
schemas:
30+
SomeObj:
31+
example:
32+
name: name
33+
active: true
34+
$_type: SomeObjIdentifier
35+
id: 0
36+
type: type
37+
properties:
38+
$_type:
39+
default: SomeObjIdentifier
40+
enum:
41+
- SomeObjIdentifier
42+
type: string
43+
id:
44+
format: int64
45+
type: integer
46+
name:
47+
type: string
48+
active:
49+
type: boolean
50+
type:
51+
type: string
52+
type: object
53+

0 commit comments

Comments
 (0)