Skip to content

Commit 7abc6d9

Browse files
committed
add tests for kotlin client with integer enum
1 parent d5de13a commit 7abc6d9

Some content is hidden

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

42 files changed

+1728
-0
lines changed

.github/workflows/samples-kotlin-client.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
- samples/client/petstore/kotlin-name-parameter-mappings
6767
- samples/client/others/kotlin-jvm-okhttp-parameter-tests
6868
- samples/client/others/kotlin-jvm-okhttp-path-comments
69+
- samples/client/others/kotlin-integer-enum
6970
- samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
7071
steps:
7172
- uses: actions/checkout@v5
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
generatorName: kotlin
2+
outputDir: samples/client/others/kotlin-integer-enum
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/pr_21746.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
5+
additionalProperties:
6+
artifactId: kotlin-integer-enum
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: Demo
4+
version: v1
5+
6+
components:
7+
schemas:
8+
Code:
9+
type: integer
10+
enum:
11+
- 0
12+
- 1
13+
StringCode:
14+
type: string
15+
enum:
16+
- hello
17+
- world
18+
19+
paths:
20+
/do:
21+
get:
22+
summary: Do something
23+
responses:
24+
200:
25+
description: Successful response
26+
content:
27+
application/json:
28+
schema:
29+
type: object
30+
required:
31+
- code
32+
properties:
33+
code:
34+
$ref: '#/components/schemas/Code'
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
README.md
2+
build.gradle
3+
docs/Code.md
4+
docs/DefaultApi.md
5+
docs/DoGet200Response.md
6+
docs/StringCode.md
7+
gradle/wrapper/gradle-wrapper.jar
8+
gradle/wrapper/gradle-wrapper.properties
9+
gradlew
10+
gradlew.bat
11+
settings.gradle
12+
src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
13+
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
14+
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
15+
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
16+
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
17+
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
18+
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
19+
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
20+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
21+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
22+
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
23+
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
24+
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
25+
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
26+
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
27+
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
28+
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
29+
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
30+
src/main/kotlin/org/openapitools/client/models/Code.kt
31+
src/main/kotlin/org/openapitools/client/models/DoGet200Response.kt
32+
src/main/kotlin/org/openapitools/client/models/StringCode.kt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.15.0-SNAPSHOT
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# org.openapitools.client - Kotlin client library for Demo
2+
3+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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: v1
9+
- Package version:
10+
- Generator version: 7.15.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*
45+
46+
| Class | Method | HTTP request | Description |
47+
| ------------ | ------------- | ------------- | ------------- |
48+
| *DefaultApi* | [**doGet**](docs/DefaultApi.md#doget) | **GET** /do | Do something |
49+
50+
51+
<a id="documentation-for-models"></a>
52+
## Documentation for Models
53+
54+
- [org.openapitools.client.models.Code](docs/Code.md)
55+
- [org.openapitools.client.models.DoGet200Response](docs/DoGet200Response.md)
56+
- [org.openapitools.client.models.StringCode](docs/StringCode.md)
57+
58+
59+
<a id="documentation-for-authorization"></a>
60+
## Documentation for Authorization
61+
62+
Endpoints do not require authorization.
63+
Lines changed: 62 additions & 0 deletions
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+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# Code
3+
4+
## Enum
5+
6+
7+
* `_0` (value: `0`)
8+
9+
* `_1` (value: `1`)
10+
11+
12+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# DefaultApi
2+
3+
All URIs are relative to *http://localhost*
4+
5+
| Method | HTTP request | Description |
6+
| ------------- | ------------- | ------------- |
7+
| [**doGet**](DefaultApi.md#doGet) | **GET** /do | Do something |
8+
9+
10+
<a id="doGet"></a>
11+
# **doGet**
12+
> DoGet200Response doGet()
13+
14+
Do something
15+
16+
### Example
17+
```kotlin
18+
// Import classes:
19+
//import org.openapitools.client.infrastructure.*
20+
//import org.openapitools.client.models.*
21+
22+
val apiInstance = DefaultApi()
23+
try {
24+
val result : DoGet200Response = apiInstance.doGet()
25+
println(result)
26+
} catch (e: ClientException) {
27+
println("4xx response calling DefaultApi#doGet")
28+
e.printStackTrace()
29+
} catch (e: ServerException) {
30+
println("5xx response calling DefaultApi#doGet")
31+
e.printStackTrace()
32+
}
33+
```
34+
35+
### Parameters
36+
This endpoint does not need any parameter.
37+
38+
### Return type
39+
40+
[**DoGet200Response**](DoGet200Response.md)
41+
42+
### Authorization
43+
44+
No authorization required
45+
46+
### HTTP request headers
47+
48+
- **Content-Type**: Not defined
49+
- **Accept**: application/json
50+

0 commit comments

Comments
 (0)