Skip to content

Commit 886e4a6

Browse files
authored
[kotlin] Test array integer (enum) with kotlin client generator (#22336)
* add tests for array of enum * update
1 parent 57d304f commit 886e4a6

35 files changed

+1514
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- samples/client/petstore/kotlin-threetenbp
4545
- samples/client/petstore/kotlin-kotlinx-datetime
4646
- samples/client/petstore/kotlin-uppercase-enum
47+
- samples/client/petstore/kotlin-array-integer-enum
4748
- samples/client/petstore/kotlin-default-values-jvm-okhttp4
4849
- samples/client/petstore/kotlin-default-values-jvm-retrofit2
4950
- samples/client/petstore/kotlin-default-values-jvm-volley
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generatorName: kotlin
2+
outputDir: samples/client/petstore/kotlin-array-integer-enum
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/issue15204-int-array-enum.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
5+
additionalProperties:
6+
artifactId: kotlin-array-integer-enum
7+
serializableModel: "true"
8+
dateLibrary: java8
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
README.md
2+
build.gradle
3+
docs/DefaultApi.md
4+
docs/ModelWithIntArrayEnum.md
5+
gradle/wrapper/gradle-wrapper.jar
6+
gradle/wrapper/gradle-wrapper.properties
7+
gradlew
8+
gradlew.bat
9+
settings.gradle
10+
src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
11+
src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
12+
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
13+
src/main/kotlin/org/openapitools/client/infrastructure/ApiResponse.kt
14+
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
15+
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
16+
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
17+
src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt
18+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
19+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
20+
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
21+
src/main/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
22+
src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
23+
src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
24+
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
25+
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
26+
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
27+
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
28+
src/main/kotlin/org/openapitools/client/models/ModelWithIntArrayEnum.kt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.18.0-SNAPSHOT
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# org.openapitools.client - Kotlin client library for Issue 15204 Int Array Enum
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: latest
9+
- Package version:
10+
- Generator version: 7.18.0-SNAPSHOT
11+
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen
12+
13+
## Requires
14+
15+
* Kotlin 2.2.20
16+
* Gradle 8.14
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* | [**operation**](docs/DefaultApi.md#operation) | **GET** / | |
49+
50+
51+
<a id="documentation-for-models"></a>
52+
## Documentation for Models
53+
54+
- [org.openapitools.client.models.ModelWithIntArrayEnum](docs/ModelWithIntArrayEnum.md)
55+
56+
57+
<a id="documentation-for-authorization"></a>
58+
## Documentation for Authorization
59+
60+
Endpoints do not require authorization.
61+
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.14.3'
6+
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
7+
}
8+
9+
buildscript {
10+
ext.kotlin_version = '2.2.20'
11+
ext.spotless_version = "7.2.1"
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.2"
59+
implementation "com.squareup.moshi:moshi-adapters:1.15.2"
60+
implementation "com.squareup.okhttp3:okhttp:5.1.0"
61+
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
62+
}
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+
| [**operation**](DefaultApi.md#operation) | **GET** / | |
8+
9+
10+
<a id="operation"></a>
11+
# **operation**
12+
> ModelWithIntArrayEnum operation()
13+
14+
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 : ModelWithIntArrayEnum = apiInstance.operation()
25+
println(result)
26+
} catch (e: ClientException) {
27+
println("4xx response calling DefaultApi#operation")
28+
e.printStackTrace()
29+
} catch (e: ServerException) {
30+
println("5xx response calling DefaultApi#operation")
31+
e.printStackTrace()
32+
}
33+
```
34+
35+
### Parameters
36+
This endpoint does not need any parameter.
37+
38+
### Return type
39+
40+
[**ModelWithIntArrayEnum**](ModelWithIntArrayEnum.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+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# ModelWithIntArrayEnum
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **daysOfWeek** | [**inline**](#kotlin.collections.List&lt;DaysOfWeek&gt;) | | |
8+
9+
10+
<a id="kotlin.collections.List<DaysOfWeek>"></a>
11+
## Enum: daysOfWeek
12+
| Name | Value |
13+
| ---- | ----- |
14+
| daysOfWeek | 0, 1, 2, 3, 4, 5, 6 |
15+
16+
17+
Binary file not shown.

0 commit comments

Comments
 (0)