Skip to content

Commit bebfdc1

Browse files
committed
add sample
1 parent 91956ba commit bebfdc1

34 files changed

Lines changed: 1446 additions & 0 deletions
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-multiplatform-allOff-discriminator
3+
library: multiplatform
4+
dateLibrary: kotlinx-datetime
5+
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism.yaml
6+
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
7+
additionalProperties:
8+
artifactId: kotlin-multiplatform-allOff-discriminator
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.openapi-generator-ignore
2+
README.md
3+
build.gradle.kts
4+
docs/Animal.md
5+
docs/Bird.md
6+
docs/BirdApi.md
7+
gradle/wrapper/gradle-wrapper.jar
8+
gradle/wrapper/gradle-wrapper.properties
9+
gradlew
10+
gradlew.bat
11+
settings.gradle.kts
12+
src/commonMain/kotlin/org/openapitools/client/apis/BirdApi.kt
13+
src/commonMain/kotlin/org/openapitools/client/auth/ApiKeyAuth.kt
14+
src/commonMain/kotlin/org/openapitools/client/auth/Authentication.kt
15+
src/commonMain/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
16+
src/commonMain/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
17+
src/commonMain/kotlin/org/openapitools/client/auth/OAuth.kt
18+
src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt
19+
src/commonMain/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
20+
src/commonMain/kotlin/org/openapitools/client/infrastructure/Base64ByteArray.kt
21+
src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt
22+
src/commonMain/kotlin/org/openapitools/client/infrastructure/HttpResponse.kt
23+
src/commonMain/kotlin/org/openapitools/client/infrastructure/OctetByteArray.kt
24+
src/commonMain/kotlin/org/openapitools/client/infrastructure/PartConfig.kt
25+
src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt
26+
src/commonMain/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt
27+
src/commonMain/kotlin/org/openapitools/client/models/Animal.kt
28+
src/commonMain/kotlin/org/openapitools/client/models/Bird.kt
29+
src/test/kotlin/org/openapitools/client/apis/BirdApiTest.kt
30+
src/test/kotlin/org/openapitools/client/models/AnimalTest.kt
31+
src/test/kotlin/org/openapitools/client/models/BirdTest.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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# org.openapitools.client - Kotlin client library for Example
2+
3+
An example
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
9+
- Package version:
10+
- Generator version: 7.15.0-SNAPSHOT
11+
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen
12+
For more information, please visit [https://example.org](https://example.org)
13+
14+
## Requires
15+
16+
* Kotlin 1.5.10
17+
18+
## Build
19+
20+
```
21+
./gradlew check assemble
22+
```
23+
24+
This runs all tests and packages the library.
25+
26+
## Features/Implementation Notes
27+
28+
* Supports JSON inputs/outputs, File inputs, and Form inputs.
29+
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
30+
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
31+
32+
33+
<a id="documentation-for-api-endpoints"></a>
34+
## Documentation for API Endpoints
35+
36+
All URIs are relative to *http://example.org*
37+
38+
| Class | Method | HTTP request | Description |
39+
| ------------ | ------------- | ------------- | ------------- |
40+
| *BirdApi* | [**getBird**](docs/BirdApi.md#getbird) | **GET** /v1/bird/{id} | |
41+
42+
43+
<a id="documentation-for-models"></a>
44+
## Documentation for Models
45+
46+
- [org.openapitools.client.models.Animal](docs/Animal.md)
47+
- [org.openapitools.client.models.Bird](docs/Bird.md)
48+
49+
50+
<a id="documentation-for-authorization"></a>
51+
## Documentation for Authorization
52+
53+
Endpoints do not require authorization.
54+
55+
56+
57+
## Author
58+
59+
contact@example.org
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
2+
3+
plugins {
4+
kotlin("multiplatform") version "2.1.21" // kotlin_version
5+
kotlin("plugin.serialization") version "2.1.21" // kotlin_version
6+
}
7+
8+
group = "org.openapitools"
9+
version = "1.0.0"
10+
11+
val kotlin_version = "2.1.21"
12+
val coroutines_version = "1.10.2"
13+
val serialization_version = "1.8.1"
14+
val ktor_version = "3.1.3"
15+
16+
repositories {
17+
mavenCentral()
18+
}
19+
20+
kotlin {
21+
jvm()
22+
iosX64()
23+
iosArm64()
24+
iosSimulatorArm64()
25+
js {
26+
browser()
27+
nodejs()
28+
}
29+
30+
sourceSets {
31+
commonMain {
32+
dependencies {
33+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
34+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version")
35+
36+
api("io.ktor:ktor-client-core:$ktor_version")
37+
api("io.ktor:ktor-client-serialization:$ktor_version")
38+
api("io.ktor:ktor-client-content-negotiation:$ktor_version")
39+
api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
40+
41+
api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2")
42+
}
43+
}
44+
45+
commonTest {
46+
dependencies {
47+
implementation(kotlin("test"))
48+
implementation("io.ktor:ktor-client-mock:$ktor_version")
49+
}
50+
}
51+
52+
jvmMain {
53+
dependencies {
54+
implementation(kotlin("stdlib-jdk7"))
55+
implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")
56+
}
57+
}
58+
59+
jvmTest {
60+
dependencies {
61+
implementation(kotlin("test-junit"))
62+
}
63+
}
64+
65+
iosMain {
66+
dependencies {
67+
api("io.ktor:ktor-client-ios:$ktor_version")
68+
}
69+
}
70+
71+
jsMain {
72+
dependencies {
73+
api("io.ktor:ktor-client-js:$ktor_version")
74+
}
75+
}
76+
}
77+
}
78+
79+
tasks {
80+
register("iosTest") {
81+
val device = project.findProperty("device")?.toString() ?: "iPhone 8"
82+
dependsOn("linkDebugTestIosX64")
83+
group = JavaBasePlugin.VERIFICATION_GROUP
84+
description = "Execute unit tests on ${device} simulator"
85+
doLast {
86+
val binary = kotlin.targets.getByName<KotlinNativeTarget>("iosX64").binaries.getTest("DEBUG")
87+
exec {
88+
commandLine("xcrun", "simctl", "spawn", device, binary.outputFile)
89+
}
90+
}
91+
}
92+
register("test") {
93+
dependsOn("allTests")
94+
}
95+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# Animal
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **id** | **kotlin.String** | | |
8+
| **optionalProperty** | **kotlin.Double** | | [optional] |
9+
10+
11+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Bird
3+
4+
## Properties
5+
| Name | Type | Description | Notes |
6+
| ------------ | ------------- | ------------- | ------------- |
7+
| **featherType** | **kotlin.String** | | |
8+
9+
10+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# BirdApi
2+
3+
All URIs are relative to *http://example.org*
4+
5+
| Method | HTTP request | Description |
6+
| ------------- | ------------- | ------------- |
7+
| [**getBird**](BirdApi.md#getBird) | **GET** /v1/bird/{id} | |
8+
9+
10+
<a id="getBird"></a>
11+
# **getBird**
12+
> Bird getBird(id)
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 = BirdApi()
23+
val id : kotlin.String = 38400000-8cf0-11bd-b23e-10b96e4ef00d // kotlin.String |
24+
try {
25+
val result : Bird = apiInstance.getBird(id)
26+
println(result)
27+
} catch (e: ClientException) {
28+
println("4xx response calling BirdApi#getBird")
29+
e.printStackTrace()
30+
} catch (e: ServerException) {
31+
println("5xx response calling BirdApi#getBird")
32+
e.printStackTrace()
33+
}
34+
```
35+
36+
### Parameters
37+
| Name | Type | Description | Notes |
38+
| ------------- | ------------- | ------------- | ------------- |
39+
| **id** | **kotlin.String**| | |
40+
41+
### Return type
42+
43+
[**Bird**](Bird.md)
44+
45+
### Authorization
46+
47+
No authorization required
48+
49+
### HTTP request headers
50+
51+
- **Content-Type**: Not defined
52+
- **Accept**: application/json
53+

0 commit comments

Comments
 (0)