Skip to content

Commit 9fec13a

Browse files
authored
[Kotlin][Tests]: Add test for kotlin-jvm-okhttp (OpenAPITools#20338)
* feat(issue-20231): add echo_api client for kotlin okhttp * build(issue-20231): sync files
1 parent b01c8be commit 9fec13a

File tree

77 files changed

+5702
-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.

77 files changed

+5702
-0
lines changed

Diff for: .github/workflows/samples-kotlin-echo-api.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
# clients
2020
- samples/client/echo_api/kotlin-jvm-spring-3-restclient
2121
- samples/client/echo_api/kotlin-model-prefix-type-mappings
22+
- samples/client/echo_api/kotlin-jvm-okhttp
2223
steps:
2324
- uses: actions/checkout@v4
2425
- uses: actions/setup-java@v4

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ samples/client/petstore/kotlin*/src/main/kotlin/test/
220220
samples/client/petstore/kotlin*/build/
221221
samples/server/others/kotlin-server/jaxrs-spec/build/
222222
samples/client/echo_api/kotlin-jvm-spring-3-restclient/build/
223+
samples/client/echo_api/kotlin-jvm-okhttp/build/
223224

224225
# haskell
225226
.stack-work

Diff for: bin/configs/kotlin-jvm-okhttp-echo-api.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generatorName: kotlin
2+
outputDir: samples/client/echo_api/kotlin-jvm-okhttp
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
5+
modelNamePrefix: Api
6+
additionalProperties:
7+
library: jvm-okhttp4
8+
artifactId: kotlin-jvm-okhttp-echo-api
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
README.md
2+
build.gradle
3+
docs/AuthApi.md
4+
docs/Bird.md
5+
docs/BodyApi.md
6+
docs/Category.md
7+
docs/DefaultValue.md
8+
docs/FormApi.md
9+
docs/HeaderApi.md
10+
docs/NumberPropertiesOnly.md
11+
docs/PathApi.md
12+
docs/Pet.md
13+
docs/Query.md
14+
docs/QueryApi.md
15+
docs/StringEnumRef.md
16+
docs/Tag.md
17+
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
18+
gradle/wrapper/gradle-wrapper.jar
19+
gradle/wrapper/gradle-wrapper.properties
20+
gradlew
21+
gradlew.bat
22+
settings.gradle
23+
src/main/kotlin/org/openapitools/client/apis/AuthApi.kt
24+
src/main/kotlin/org/openapitools/client/apis/BodyApi.kt
25+
src/main/kotlin/org/openapitools/client/apis/FormApi.kt
26+
src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt
27+
src/main/kotlin/org/openapitools/client/apis/PathApi.kt
28+
src/main/kotlin/org/openapitools/client/apis/QueryApi.kt
29+
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
30+
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
31+
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
32+
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
33+
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
34+
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
35+
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
36+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
37+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
38+
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
39+
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
40+
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
41+
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
42+
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
43+
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
44+
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
45+
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
46+
src/main/kotlin/org/openapitools/client/models/ApiBird.kt
47+
src/main/kotlin/org/openapitools/client/models/ApiCategory.kt
48+
src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt
49+
src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt
50+
src/main/kotlin/org/openapitools/client/models/ApiPet.kt
51+
src/main/kotlin/org/openapitools/client/models/ApiQuery.kt
52+
src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt
53+
src/main/kotlin/org/openapitools/client/models/ApiTag.kt
54+
src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.11.0-SNAPSHOT

Diff for: samples/client/echo_api/kotlin-jvm-okhttp/README.md

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# org.openapitools.client - Kotlin client library for Echo Server API
2+
3+
Echo Server API
4+
5+
## Overview
6+
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client.
7+
8+
- API version: 0.1.0
9+
- Package version:
10+
- Generator version: 7.11.0-SNAPSHOT
11+
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen
12+
13+
## Requires
14+
15+
* Kotlin 1.7.21
16+
* Gradle 7.5
17+
18+
## Build
19+
20+
First, create the gradle wrapper script:
21+
22+
```
23+
gradle wrapper
24+
```
25+
26+
Then, run:
27+
28+
```
29+
./gradlew check assemble
30+
```
31+
32+
This runs all tests and packages the library.
33+
34+
## Features/Implementation Notes
35+
36+
* Supports JSON inputs/outputs, File inputs, and Form inputs.
37+
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
38+
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
39+
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.
40+
41+
<a id="documentation-for-api-endpoints"></a>
42+
## Documentation for API Endpoints
43+
44+
All URIs are relative to *http://localhost:3000*
45+
46+
| Class | Method | HTTP request | Description |
47+
| ------------ | ------------- | ------------- | ------------- |
48+
| *AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testauthhttpbasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
49+
| *AuthApi* | [**testAuthHttpBearer**](docs/AuthApi.md#testauthhttpbearer) | **POST** /auth/http/bearer | To test HTTP bearer authentication |
50+
| *BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testbinarygif) | **POST** /binary/gif | Test binary (gif) response body |
51+
| *BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testbodyapplicationoctetstreambinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) |
52+
| *BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testbodymultipartformdataarrayofbinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime |
53+
| *BodyApi* | [**testBodyMultipartFormdataSingleBinary**](docs/BodyApi.md#testbodymultipartformdatasinglebinary) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime |
54+
| *BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testechobodyfreeformobjectresponsestring) | **POST** /echo/body/FreeFormObject/response_string | Test free form object |
55+
| *BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testechobodypet) | **POST** /echo/body/Pet | Test body parameter(s) |
56+
| *BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testechobodypetresponsestring) | **POST** /echo/body/Pet/response_string | Test empty response body |
57+
| *BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testechobodytagresponsestring) | **POST** /echo/body/Tag/response_string | Test empty json (request body) |
58+
| *FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testformintegerbooleanstring) | **POST** /form/integer/boolean/string | Test form parameter(s) |
59+
| *FormApi* | [**testFormOneof**](docs/FormApi.md#testformoneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema |
60+
| *HeaderApi* | [**testHeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#testheaderintegerbooleanstringenums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) |
61+
| *PathApi* | [**testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](docs/PathApi.md#testspathstringpathstringintegerpathintegerenumnonrefstringpathenumrefstringpath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) |
62+
| *QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testenumrefstring) | **GET** /query/enum_ref_string | Test query parameter(s) |
63+
| *QueryApi* | [**testQueryDatetimeDateString**](docs/QueryApi.md#testquerydatetimedatestring) | **GET** /query/datetime/date/string | Test query parameter(s) |
64+
| *QueryApi* | [**testQueryIntegerBooleanString**](docs/QueryApi.md#testqueryintegerbooleanstring) | **GET** /query/integer/boolean/string | Test query parameter(s) |
65+
| *QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s) |
66+
| *QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testquerystyleformexplodetruearraystring) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) |
67+
| *QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testquerystyleformexplodetrueobject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) |
68+
69+
70+
<a id="documentation-for-models"></a>
71+
## Documentation for Models
72+
73+
- [org.openapitools.client.models.ApiBird](docs/ApiBird.md)
74+
- [org.openapitools.client.models.ApiCategory](docs/ApiCategory.md)
75+
- [org.openapitools.client.models.ApiDefaultValue](docs/ApiDefaultValue.md)
76+
- [org.openapitools.client.models.ApiNumberPropertiesOnly](docs/ApiNumberPropertiesOnly.md)
77+
- [org.openapitools.client.models.ApiPet](docs/ApiPet.md)
78+
- [org.openapitools.client.models.ApiQuery](docs/ApiQuery.md)
79+
- [org.openapitools.client.models.ApiStringEnumRef](docs/ApiStringEnumRef.md)
80+
- [org.openapitools.client.models.ApiTag](docs/ApiTag.md)
81+
- [org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
82+
83+
84+
<a id="documentation-for-authorization"></a>
85+
## Documentation for Authorization
86+
87+
88+
Authentication schemes defined for the API:
89+
<a id="http_auth"></a>
90+
### http_auth
91+
92+
- **Type**: HTTP basic authentication
93+
94+
<a id="http_bearer_auth"></a>
95+
### http_bearer_auth
96+
97+
- **Type**: HTTP Bearer Token authentication
98+
99+
100+
101+
## Author
102+
103+
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
group 'org.openapitools'
2+
version '1.0.0'
3+
4+
wrapper {
5+
gradleVersion = '8.7'
6+
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
7+
}
8+
9+
buildscript {
10+
ext.kotlin_version = '1.9.23'
11+
ext.spotless_version = "6.25.0"
12+
13+
repositories {
14+
maven { url "https://repo1.maven.org/maven2" }
15+
}
16+
dependencies {
17+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18+
classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
19+
}
20+
}
21+
22+
apply plugin: 'kotlin'
23+
apply plugin: 'maven-publish'
24+
apply plugin: 'com.diffplug.spotless'
25+
26+
repositories {
27+
maven { url "https://repo1.maven.org/maven2" }
28+
}
29+
30+
// Use spotless plugin to automatically format code, remove unused import, etc
31+
// To apply changes directly to the file, run `gradlew spotlessApply`
32+
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
33+
spotless {
34+
// comment out below to run spotless as part of the `check` task
35+
enforceCheck false
36+
37+
format 'misc', {
38+
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
39+
target '.gitignore'
40+
41+
// define the steps to apply to those files
42+
trimTrailingWhitespace()
43+
indentWithSpaces() // Takes an integer argument if you don't like 4
44+
endWithNewline()
45+
}
46+
kotlin {
47+
ktfmt()
48+
}
49+
}
50+
51+
test {
52+
useJUnitPlatform()
53+
}
54+
55+
dependencies {
56+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
57+
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
58+
implementation "com.squareup.moshi:moshi-kotlin:1.15.1"
59+
implementation "com.squareup.moshi:moshi-adapters:1.15.1"
60+
implementation "com.squareup.okhttp3:okhttp:4.12.0"
61+
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
62+
}
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# AuthApi
2+
3+
All URIs are relative to *http://localhost:3000*
4+
5+
| Method | HTTP request | Description |
6+
| ------------- | ------------- | ------------- |
7+
| [**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
8+
| [**testAuthHttpBearer**](AuthApi.md#testAuthHttpBearer) | **POST** /auth/http/bearer | To test HTTP bearer authentication |
9+
10+
11+
<a id="testAuthHttpBasic"></a>
12+
# **testAuthHttpBasic**
13+
> kotlin.String testAuthHttpBasic()
14+
15+
To test HTTP basic authentication
16+
17+
To test HTTP basic authentication
18+
19+
### Example
20+
```kotlin
21+
// Import classes:
22+
//import org.openapitools.client.infrastructure.*
23+
//import org.openapitools.client.models.*
24+
25+
val apiInstance = AuthApi()
26+
try {
27+
val result : kotlin.String = apiInstance.testAuthHttpBasic()
28+
println(result)
29+
} catch (e: ClientException) {
30+
println("4xx response calling AuthApi#testAuthHttpBasic")
31+
e.printStackTrace()
32+
} catch (e: ServerException) {
33+
println("5xx response calling AuthApi#testAuthHttpBasic")
34+
e.printStackTrace()
35+
}
36+
```
37+
38+
### Parameters
39+
This endpoint does not need any parameter.
40+
41+
### Return type
42+
43+
**kotlin.String**
44+
45+
### Authorization
46+
47+
48+
Configure http_auth:
49+
ApiClient.username = ""
50+
ApiClient.password = ""
51+
52+
### HTTP request headers
53+
54+
- **Content-Type**: Not defined
55+
- **Accept**: text/plain
56+
57+
<a id="testAuthHttpBearer"></a>
58+
# **testAuthHttpBearer**
59+
> kotlin.String testAuthHttpBearer()
60+
61+
To test HTTP bearer authentication
62+
63+
To test HTTP bearer authentication
64+
65+
### Example
66+
```kotlin
67+
// Import classes:
68+
//import org.openapitools.client.infrastructure.*
69+
//import org.openapitools.client.models.*
70+
71+
val apiInstance = AuthApi()
72+
try {
73+
val result : kotlin.String = apiInstance.testAuthHttpBearer()
74+
println(result)
75+
} catch (e: ClientException) {
76+
println("4xx response calling AuthApi#testAuthHttpBearer")
77+
e.printStackTrace()
78+
} catch (e: ServerException) {
79+
println("5xx response calling AuthApi#testAuthHttpBearer")
80+
e.printStackTrace()
81+
}
82+
```
83+
84+
### Parameters
85+
This endpoint does not need any parameter.
86+
87+
### Return type
88+
89+
**kotlin.String**
90+
91+
### Authorization
92+
93+
94+
Configure http_bearer_auth:
95+
ApiClient.accessToken = ""
96+
97+
### HTTP request headers
98+
99+
- **Content-Type**: Not defined
100+
- **Accept**: text/plain
101+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# ApiBird
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **propertySize** | **kotlin.String** | | [optional] |
8+
| **color** | **kotlin.String** | | [optional] |
9+
10+
11+

0 commit comments

Comments
 (0)