Skip to content

Commit

Permalink
add kotlin echo api client
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Mar 20, 2024
1 parent be1e31a commit 26b211a
Show file tree
Hide file tree
Showing 73 changed files with 4,313 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/samples-kotlin-echo-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
sample:
# clients
- samples/client/echo_api/kotlin-jvm-spring-3-restclient
- samples/client/echo_api/kotlin-model-prefix-type-mappings
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
15 changes: 15 additions & 0 deletions bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
generatorName: kotlin
outputDir: samples/client/echo_api/kotlin-model-prefix-type-mappings
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
typeMappings:
java.io.File: RequestBody
modelNamePrefix: Api
additionalProperties:
artifactId: kotlin-client-prefix-mapping
useCoroutines: true
library: jvm-retrofit2
enumPropertyNaming: UPPERCASE
serializationLibrary: gson
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF=false
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
README.md
build.gradle
docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
docs/DataQuery.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
docs/QueryApi.md
docs/StringEnumRef.md
docs/Tag.md
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
settings.gradle
src/main/kotlin/org/openapitools/client/apis/AuthApi.kt
src/main/kotlin/org/openapitools/client/apis/BodyApi.kt
src/main/kotlin/org/openapitools/client/apis/FormApi.kt
src/main/kotlin/org/openapitools/client/apis/HeaderApi.kt
src/main/kotlin/org/openapitools/client/apis/PathApi.kt
src/main/kotlin/org/openapitools/client/apis/QueryApi.kt
src/main/kotlin/org/openapitools/client/auth/HttpBasicAuth.kt
src/main/kotlin/org/openapitools/client/auth/HttpBearerAuth.kt
src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt
src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/CollectionFormats.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
src/main/kotlin/org/openapitools/client/infrastructure/ResponseExt.kt
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
src/main/kotlin/org/openapitools/client/models/ApiBird.kt
src/main/kotlin/org/openapitools/client/models/ApiCategory.kt
src/main/kotlin/org/openapitools/client/models/ApiDataQuery.kt
src/main/kotlin/org/openapitools/client/models/ApiDefaultValue.kt
src/main/kotlin/org/openapitools/client/models/ApiNumberPropertiesOnly.kt
src/main/kotlin/org/openapitools/client/models/ApiPet.kt
src/main/kotlin/org/openapitools/client/models/ApiQuery.kt
src/main/kotlin/org/openapitools/client/models/ApiStringEnumRef.kt
src/main/kotlin/org/openapitools/client/models/ApiTag.kt
src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.kt
src/main/kotlin/org/openapitools/client/models/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.5.0-SNAPSHOT
111 changes: 111 additions & 0 deletions samples/client/echo_api/kotlin-model-prefix-type-mappings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# org.openapitools.client - Kotlin client library for Echo Server API

Echo Server API

## Overview
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.

- API version: 0.1.0
- Package version:
- Generator version: 7.5.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen

## Requires

* Kotlin 1.7.21
* Gradle 7.5

## Build

First, create the gradle wrapper script:

```
gradle wrapper
```

Then, run:

```
./gradlew check assemble
```

This runs all tests and packages the library.

## Features/Implementation Notes

* Supports JSON inputs/outputs, File inputs, and Form inputs.
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.

<a id="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints

All URIs are relative to *http://localhost:3000*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testauthhttpbasic) | **POST** auth/http/basic | To test HTTP basic authentication
*AuthApi* | [**testAuthHttpBearer**](docs/AuthApi.md#testauthhttpbearer) | **POST** auth/http/bearer | To test HTTP bearer authentication
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testbinarygif) | **POST** binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testbodyapplicationoctetstreambinary) | **POST** body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testbodymultipartformdataarrayofbinary) | **POST** body/application/octetstream/array_of_binary | Test array of binary in multipart mime
*BodyApi* | [**testBodyMultipartFormdataSingleBinary**](docs/BodyApi.md#testbodymultipartformdatasinglebinary) | **POST** body/application/octetstream/single_binary | Test single binary in multipart mime
*BodyApi* | [**testEchoBodyAllOfPet**](docs/BodyApi.md#testechobodyallofpet) | **POST** echo/body/allOf/Pet | Test body parameter(s)
*BodyApi* | [**testEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testechobodyfreeformobjectresponsestring) | **POST** echo/body/FreeFormObject/response_string | Test free form object
*BodyApi* | [**testEchoBodyPet**](docs/BodyApi.md#testechobodypet) | **POST** echo/body/Pet | Test body parameter(s)
*BodyApi* | [**testEchoBodyPetResponseString**](docs/BodyApi.md#testechobodypetresponsestring) | **POST** echo/body/Pet/response_string | Test empty response body
*BodyApi* | [**testEchoBodyStringEnum**](docs/BodyApi.md#testechobodystringenum) | **POST** echo/body/string_enum | Test string enum response body
*BodyApi* | [**testEchoBodyTagResponseString**](docs/BodyApi.md#testechobodytagresponsestring) | **POST** echo/body/Tag/response_string | Test empty json (request body)
*FormApi* | [**testFormIntegerBooleanString**](docs/FormApi.md#testformintegerbooleanstring) | **POST** form/integer/boolean/string | Test form parameter(s)
*FormApi* | [**testFormOneof**](docs/FormApi.md#testformoneof) | **POST** form/oneof | Test form parameter(s) for oneOf schema
*HeaderApi* | [**testHeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#testheaderintegerbooleanstringenums) | **GET** header/integer/boolean/string/enums | Test header parameter(s)
*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)
*QueryApi* | [**testEnumRefString**](docs/QueryApi.md#testenumrefstring) | **GET** query/enum_ref_string | Test query parameter(s)
*QueryApi* | [**testQueryDatetimeDateString**](docs/QueryApi.md#testquerydatetimedatestring) | **GET** query/datetime/date/string | Test query parameter(s)
*QueryApi* | [**testQueryIntegerBooleanString**](docs/QueryApi.md#testqueryintegerbooleanstring) | **GET** query/integer/boolean/string | Test query parameter(s)
*QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobject) | **GET** query/style_deepObject/explode_true/object | Test query parameter(s)
*QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobjectallof) | **GET** query/style_deepObject/explode_true/object/allOf | Test query parameter(s)
*QueryApi* | [**testQueryStyleFormExplodeFalseArrayInteger**](docs/QueryApi.md#testquerystyleformexplodefalsearrayinteger) | **GET** query/style_form/explode_false/array_integer | Test query parameter(s)
*QueryApi* | [**testQueryStyleFormExplodeFalseArrayString**](docs/QueryApi.md#testquerystyleformexplodefalsearraystring) | **GET** query/style_form/explode_false/array_string | Test query parameter(s)
*QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testquerystyleformexplodetruearraystring) | **GET** query/style_form/explode_true/array_string | Test query parameter(s)
*QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testquerystyleformexplodetrueobject) | **GET** query/style_form/explode_true/object | Test query parameter(s)
*QueryApi* | [**testQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#testquerystyleformexplodetrueobjectallof) | **GET** query/style_form/explode_true/object/allOf | Test query parameter(s)


<a id="documentation-for-models"></a>
## Documentation for Models

- [org.openapitools.client.models.ApiBird](docs/ApiBird.md)
- [org.openapitools.client.models.ApiCategory](docs/ApiCategory.md)
- [org.openapitools.client.models.ApiDataQuery](docs/ApiDataQuery.md)
- [org.openapitools.client.models.ApiDefaultValue](docs/ApiDefaultValue.md)
- [org.openapitools.client.models.ApiNumberPropertiesOnly](docs/ApiNumberPropertiesOnly.md)
- [org.openapitools.client.models.ApiPet](docs/ApiPet.md)
- [org.openapitools.client.models.ApiQuery](docs/ApiQuery.md)
- [org.openapitools.client.models.ApiStringEnumRef](docs/ApiStringEnumRef.md)
- [org.openapitools.client.models.ApiTag](docs/ApiTag.md)
- [org.openapitools.client.models.ApiTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/ApiTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
- [org.openapitools.client.models.ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)


<a id="documentation-for-authorization"></a>
## Documentation for Authorization


Authentication schemes defined for the API:
<a id="http_auth"></a>
### http_auth

- **Type**: HTTP basic authentication

<a id="http_bearer_auth"></a>
### http_bearer_auth

- **Type**: HTTP Bearer Token authentication



## Author

[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
group 'org.openapitools'
version '1.0.0'

wrapper {
gradleVersion = '7.5'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

buildscript {
ext.kotlin_version = '1.8.10'
ext.retrofitVersion = '2.9.0'
ext.spotless_version = "6.13.0"

repositories {
maven { url "https://repo1.maven.org/maven2" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotless_version"
}
}

apply plugin: 'kotlin'
apply plugin: 'maven-publish'
apply plugin: 'com.diffplug.spotless'

repositories {
maven { url "https://repo1.maven.org/maven2" }
}

// Use spotless plugin to automatically format code, remove unused import, etc
// To apply changes directly to the file, run `gradlew spotlessApply`
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
// comment out below to run spotless as part of the `check` task
enforceCheck false

format 'misc', {
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
target '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // Takes an integer argument if you don't like 4
endWithNewline()
}
kotlin {
ktfmt()
}
}

test {
useJUnitPlatform()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "com.google.code.gson:gson:2.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# AuthApi

All URIs are relative to *http://localhost:3000*

Method | HTTP request | Description
------------- | ------------- | -------------
[**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** auth/http/basic | To test HTTP basic authentication
[**testAuthHttpBearer**](AuthApi.md#testAuthHttpBearer) | **POST** auth/http/bearer | To test HTTP bearer authentication



To test HTTP basic authentication

To test HTTP basic authentication

### Example
```kotlin
// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
apiClient.setCredentials("USERNAME", "PASSWORD")
val webService = apiClient.createWebservice(AuthApi::class.java)

launch(Dispatchers.IO) {
val result : kotlin.String = webService.testAuthHttpBasic()
}
```

### Parameters
This endpoint does not need any parameter.

### Return type

**kotlin.String**

### Authorization


Configure http_auth:
ApiClient().setCredentials("USERNAME", "PASSWORD")

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: text/plain


To test HTTP bearer authentication

To test HTTP bearer authentication

### Example
```kotlin
// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
apiClient.setBearerToken("TOKEN")
val webService = apiClient.createWebservice(AuthApi::class.java)

launch(Dispatchers.IO) {
val result : kotlin.String = webService.testAuthHttpBearer()
}
```

### Parameters
This endpoint does not need any parameter.

### Return type

**kotlin.String**

### Authorization


Configure http_bearer_auth:
ApiClient().setBearerToken("TOKEN")

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: text/plain

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# ApiBird

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**propertySize** | **kotlin.String** | | [optional]
**color** | **kotlin.String** | | [optional]



Loading

0 comments on commit 26b211a

Please sign in to comment.