Skip to content

Commit b0f96e5

Browse files
naokiwakatawakata_sansan
authored andcommitted
add sample and CI config for non-discriminator oneOf/anyOf with kotlinx_serialization
1 parent a3babc8 commit b0f96e5

78 files changed

Lines changed: 4975 additions & 0 deletions

File tree

Some content is hidden

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
- samples/client/others/kotlin-integer-enum
7171
- samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
7272
- samples/client/others/kotlin-oneOf-discriminator-kotlinx-serialization
73+
- samples/client/others/kotlin-oneOf-anyOf-kotlinx-serialization
7374
steps:
7475
- uses: actions/checkout@v5
7576
- uses: actions/setup-java@v5
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
generatorName: kotlin
2+
outputDir: samples/client/others/kotlin-oneOf-anyOf-kotlinx-serialization
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
5+
additionalProperties:
6+
artifactId: kotlin-oneOf-anyOf-kotlinx-serialization
7+
serializableModel: "false"
8+
dateLibrary: java8
9+
library: jvm-retrofit2
10+
enumUnknownDefaultCase: true
11+
serializationLibrary: kotlinx_serialization
12+
generateOneOfAnyOfWrappers: true
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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
.openapi-generator-ignore
2+
README.md
3+
build.gradle
4+
docs/Annotation.md
5+
docs/AnyOfUserOrPet.md
6+
docs/AnyOfUserOrPetOrArrayString.md
7+
docs/ApiResponse.md
8+
docs/Category.md
9+
docs/FakeApi.md
10+
docs/Order.md
11+
docs/Pet.md
12+
docs/PetApi.md
13+
docs/StoreApi.md
14+
docs/Tag.md
15+
docs/User.md
16+
docs/UserApi.md
17+
docs/UserOrPet.md
18+
docs/UserOrPetOrArrayString.md
19+
gradle/wrapper/gradle-wrapper.jar
20+
gradle/wrapper/gradle-wrapper.properties
21+
gradlew
22+
gradlew.bat
23+
proguard-rules.pro
24+
settings.gradle
25+
src/main/kotlin/org/openapitools/client/apis/FakeApi.kt
26+
src/main/kotlin/org/openapitools/client/apis/PetApi.kt
27+
src/main/kotlin/org/openapitools/client/apis/StoreApi.kt
28+
src/main/kotlin/org/openapitools/client/apis/UserApi.kt
29+
src/main/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
30+
src/main/kotlin/org/openapitools/client/auth/OAuth.kt
31+
src/main/kotlin/org/openapitools/client/auth/OAuthFlow.kt
32+
src/main/kotlin/org/openapitools/client/auth/OAuthOkHttpClient.kt
33+
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
34+
src/main/kotlin/org/openapitools/client/infrastructure/AtomicBooleanAdapter.kt
35+
src/main/kotlin/org/openapitools/client/infrastructure/AtomicIntegerAdapter.kt
36+
src/main/kotlin/org/openapitools/client/infrastructure/AtomicLongAdapter.kt
37+
src/main/kotlin/org/openapitools/client/infrastructure/BigDecimalAdapter.kt
38+
src/main/kotlin/org/openapitools/client/infrastructure/BigIntegerAdapter.kt
39+
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
40+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
41+
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
42+
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
43+
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
44+
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
45+
src/main/kotlin/org/openapitools/client/infrastructure/StringBuilderAdapter.kt
46+
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
47+
src/main/kotlin/org/openapitools/client/infrastructure/URLAdapter.kt
48+
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
49+
src/main/kotlin/org/openapitools/client/models/Annotation.kt
50+
src/main/kotlin/org/openapitools/client/models/AnyOfUserOrPet.kt
51+
src/main/kotlin/org/openapitools/client/models/AnyOfUserOrPetOrArrayString.kt
52+
src/main/kotlin/org/openapitools/client/models/Category.kt
53+
src/main/kotlin/org/openapitools/client/models/ModelApiResponse.kt
54+
src/main/kotlin/org/openapitools/client/models/Order.kt
55+
src/main/kotlin/org/openapitools/client/models/Pet.kt
56+
src/main/kotlin/org/openapitools/client/models/Tag.kt
57+
src/main/kotlin/org/openapitools/client/models/User.kt
58+
src/main/kotlin/org/openapitools/client/models/UserOrPet.kt
59+
src/main/kotlin/org/openapitools/client/models/UserOrPetOrArrayString.kt
60+
src/test/kotlin/org/openapitools/client/apis/FakeApiTest.kt
61+
src/test/kotlin/org/openapitools/client/apis/PetApiTest.kt
62+
src/test/kotlin/org/openapitools/client/apis/StoreApiTest.kt
63+
src/test/kotlin/org/openapitools/client/apis/UserApiTest.kt
64+
src/test/kotlin/org/openapitools/client/models/AnnotationTest.kt
65+
src/test/kotlin/org/openapitools/client/models/AnyOfUserOrPetOrArrayStringTest.kt
66+
src/test/kotlin/org/openapitools/client/models/AnyOfUserOrPetTest.kt
67+
src/test/kotlin/org/openapitools/client/models/ApiResponseTest.kt
68+
src/test/kotlin/org/openapitools/client/models/CategoryTest.kt
69+
src/test/kotlin/org/openapitools/client/models/OrderTest.kt
70+
src/test/kotlin/org/openapitools/client/models/PetTest.kt
71+
src/test/kotlin/org/openapitools/client/models/TagTest.kt
72+
src/test/kotlin/org/openapitools/client/models/UserOrPetOrArrayStringTest.kt
73+
src/test/kotlin/org/openapitools/client/models/UserOrPetTest.kt
74+
src/test/kotlin/org/openapitools/client/models/UserTest.kt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.21.0-SNAPSHOT
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# org.openapitools.client - Kotlin client library for OpenAPI Petstore
2+
3+
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
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: 1.0.0
9+
- Package version:
10+
- Generator version: 7.21.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://petstore.swagger.io/v2*
45+
46+
| Class | Method | HTTP request | Description |
47+
| ------------ | ------------- | ------------- | ------------- |
48+
| *FakeApi* | [**annotations**](docs/FakeApi.md#annotations) | **POST** fake/annotations | annotate |
49+
| *FakeApi* | [**updatePetWithFormNumber**](docs/FakeApi.md#updatepetwithformnumber) | **PUT** fake/annotations | Updates a pet in the store with form data (number) |
50+
| *PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** pet | Add a new pet to the store |
51+
| *PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** pet/{petId} | Deletes a pet |
52+
| *PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** pet/findByStatus | Finds Pets by status |
53+
| *PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** pet/findByTags | Finds Pets by tags |
54+
| *PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** pet/{petId} | Find pet by ID |
55+
| *PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** pet | Update an existing pet |
56+
| *PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** pet/{petId} | Updates a pet in the store with form data |
57+
| *PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** pet/{petId}/uploadImage | uploads an image |
58+
| *StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** store/order/{orderId} | Delete purchase order by ID |
59+
| *StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** store/inventory | Returns pet inventories by status |
60+
| *StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** store/order/{orderId} | Find purchase order by ID |
61+
| *StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** store/order | Place an order for a pet |
62+
| *UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** user | Create user |
63+
| *UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** user/createWithArray | Creates list of users with given input array |
64+
| *UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** user/createWithList | Creates list of users with given input array |
65+
| *UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** user/{username} | Delete user |
66+
| *UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** user/{username} | Get user by user name |
67+
| *UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** user/login | Logs user into the system |
68+
| *UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** user/logout | Logs out current logged in user session |
69+
| *UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** user/{username} | Updated user |
70+
71+
72+
<a id="documentation-for-models"></a>
73+
## Documentation for Models
74+
75+
- [org.openapitools.client.models.Annotation](docs/Annotation.md)
76+
- [org.openapitools.client.models.AnyOfUserOrPet](docs/AnyOfUserOrPet.md)
77+
- [org.openapitools.client.models.AnyOfUserOrPetOrArrayString](docs/AnyOfUserOrPetOrArrayString.md)
78+
- [org.openapitools.client.models.Category](docs/Category.md)
79+
- [org.openapitools.client.models.ModelApiResponse](docs/ModelApiResponse.md)
80+
- [org.openapitools.client.models.Order](docs/Order.md)
81+
- [org.openapitools.client.models.Pet](docs/Pet.md)
82+
- [org.openapitools.client.models.Tag](docs/Tag.md)
83+
- [org.openapitools.client.models.User](docs/User.md)
84+
- [org.openapitools.client.models.UserOrPet](docs/UserOrPet.md)
85+
- [org.openapitools.client.models.UserOrPetOrArrayString](docs/UserOrPetOrArrayString.md)
86+
87+
88+
<a id="documentation-for-authorization"></a>
89+
## Documentation for Authorization
90+
91+
92+
Authentication schemes defined for the API:
93+
<a id="petstore_auth"></a>
94+
### petstore_auth
95+
96+
- **Type**: OAuth
97+
- **Flow**: implicit
98+
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
99+
- **Scopes**:
100+
- write:pets: modify pets in your account
101+
- read:pets: read your pets
102+
103+
<a id="api_key"></a>
104+
### api_key
105+
106+
- **Type**: API key
107+
- **API key parameter name**: api_key
108+
- **Location**: HTTP header
109+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.retrofitVersion = '3.0.0'
12+
ext.spotless_version = "7.2.1"
13+
14+
repositories {
15+
maven { url "https://repo1.maven.org/maven2" }
16+
}
17+
dependencies {
18+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
19+
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
20+
classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
21+
}
22+
}
23+
24+
apply plugin: 'kotlin'
25+
apply plugin: 'kotlinx-serialization'
26+
apply plugin: 'maven-publish'
27+
apply plugin: 'com.diffplug.spotless'
28+
29+
repositories {
30+
maven { url "https://repo1.maven.org/maven2" }
31+
}
32+
33+
// Use spotless plugin to automatically format code, remove unused import, etc
34+
// To apply changes directly to the file, run `gradlew spotlessApply`
35+
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
36+
spotless {
37+
// comment out below to run spotless as part of the `check` task
38+
enforceCheck false
39+
40+
format 'misc', {
41+
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
42+
target '.gitignore'
43+
44+
// define the steps to apply to those files
45+
trimTrailingWhitespace()
46+
indentWithSpaces() // Takes an integer argument if you don't like 4
47+
endWithNewline()
48+
}
49+
kotlin {
50+
ktfmt()
51+
}
52+
}
53+
54+
test {
55+
useJUnitPlatform()
56+
}
57+
58+
dependencies {
59+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
60+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0"
61+
implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
62+
implementation "com.squareup.okhttp3:logging-interceptor:5.1.0"
63+
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
64+
implementation "com.squareup.retrofit2:converter-kotlinx-serialization:$retrofitVersion"
65+
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
66+
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
67+
}
68+
69+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
70+
kotlinOptions {
71+
freeCompilerArgs += "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi"
72+
}
73+
}
74+
75+
java {
76+
withSourcesJar()
77+
}
78+
79+
publishing {
80+
publications {
81+
maven(MavenPublication) {
82+
groupId = 'org.openapitools'
83+
artifactId = 'kotlin-oneOf-anyOf-kotlinx-serialization'
84+
version = '1.0.0'
85+
from components.java
86+
}
87+
}
88+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Annotation
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **id** | [**java.util.UUID**](java.util.UUID.md) | | [optional] |
8+
9+
10+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# AnyOfUserOrPet
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **username** | **kotlin.String** | | |
8+
| **name** | **kotlin.String** | | |
9+
| **photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | | |
10+
| **id** | **kotlin.Long** | | [optional] |
11+
| **firstName** | **kotlin.String** | | [optional] |
12+
| **lastName** | **kotlin.String** | | [optional] |
13+
| **email** | **kotlin.String** | | [optional] |
14+
| **password** | **kotlin.String** | | [optional] |
15+
| **phone** | **kotlin.String** | | [optional] |
16+
| **userStatus** | **kotlin.Int** | User Status | [optional] |
17+
| **category** | [**Category**](Category.md) | | [optional] |
18+
| **tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional] |
19+
| **status** | [**inline**](#Status) | pet status in the store | [optional] |
20+
21+
22+
<a id="Status"></a>
23+
## Enum: status
24+
| Name | Value |
25+
| ---- | ----- |
26+
| status | available, pending, sold |
27+
28+
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# AnyOfUserOrPetOrArrayString
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **username** | **kotlin.String** | | |
8+
| **name** | **kotlin.String** | | |
9+
| **photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | | |
10+
| **id** | **kotlin.Long** | | [optional] |
11+
| **firstName** | **kotlin.String** | | [optional] |
12+
| **lastName** | **kotlin.String** | | [optional] |
13+
| **email** | **kotlin.String** | | [optional] |
14+
| **password** | **kotlin.String** | | [optional] |
15+
| **phone** | **kotlin.String** | | [optional] |
16+
| **userStatus** | **kotlin.Int** | User Status | [optional] |
17+
| **category** | [**Category**](Category.md) | | [optional] |
18+
| **tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional] |
19+
| **status** | [**inline**](#Status) | pet status in the store | [optional] |
20+
21+
22+
<a id="Status"></a>
23+
## Enum: status
24+
| Name | Value |
25+
| ---- | ----- |
26+
| status | available, pending, sold |
27+
28+
29+

0 commit comments

Comments
 (0)