-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kotlin][jvm-retrofit2] fix missing import for models in query parame…
…ters (#18143) * add new kotlin client samples * update workflow * update samples * update * add kotlin echo api client * update * update * fix model import
- Loading branch information
Showing
126 changed files
with
7,380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
bin/configs/kotlin-model-prefix-type-mapping-echo-api.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/kotlin/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
generatorName: kotlin | ||
outputDir: samples/client/petstore/kotlin-model-prefix-type-mappings | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator-ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
47 changes: 47 additions & 0 deletions
47
samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/FILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
README.md | ||
build.gradle | ||
docs/AuthApi.md | ||
docs/Bird.md | ||
docs/BodyApi.md | ||
docs/Category.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/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/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/ApiTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.kt |
1 change: 1 addition & 0 deletions
1
samples/client/echo_api/kotlin-model-prefix-type-mappings/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.5.0-SNAPSHOT |
103 changes: 103 additions & 0 deletions
103
samples/client/echo_api/kotlin-model-prefix-type-mappings/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# 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* | [**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* | [**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* | [**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) | ||
|
||
|
||
<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.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.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] |
65 changes: 65 additions & 0 deletions
65
samples/client/echo_api/kotlin-model-prefix-type-mappings/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Oops, something went wrong.