Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kotlin][client] fix warning #18560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/configs/kotlin-jvm-spring-3-webclient-echo-api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: kotlin
outputDir: samples/client/echo_api/kotlin-jvm-spring-3-webclient
library: jvm-spring-restclient
library: jvm-spring-webclient
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {{packageName}}.infrastructure.*
@Deprecated(message = "This operation is deprecated.")
{{/isDeprecated}}
fun {{operationId}}({{#allParams}}{{{paramName}}}: {{#isEnum}}{{#isContainer}}kotlin.collections.List<{{enumName}}{{operationIdCamelCase}}>{{/isContainer}}{{^isContainer}}{{enumName}}{{operationIdCamelCase}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}?{{#defaultValue}} = {{>param_default_value}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}): {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
val result = {{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}} = {{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}})
{{#returnType}}val result = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{{paramName}}} = {{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}})
{{#returnType}}
return result.body!!
{{/returnType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ wrapper {
buildscript {
ext.kotlin_version = '1.8.10'
ext.spring_boot_version = "3.2.4"
ext.reactor_version = "3.6.4"
// 6.13.0 is the latest stable release that supports JDK8
ext.spotless_version = "6.13.0"

Expand Down Expand Up @@ -59,11 +60,13 @@ kotlin {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.0"
implementation "org.springframework.boot:spring-boot-starter-web:$spring_boot_version"
implementation "org.springframework.boot:spring-boot-starter-webflux:$spring_boot_version"
implementation "io.projectreactor:reactor-core:$reactor_version"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,37 @@ package org.openapitools.client.apis

import com.fasterxml.jackson.annotation.JsonProperty

import org.springframework.web.client.RestClient
import org.springframework.web.client.RestClientResponseException

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.WebClientResponseException
import org.springframework.http.codec.json.Jackson2JsonDecoder
import org.springframework.http.codec.json.Jackson2JsonEncoder
import org.springframework.http.ResponseEntity
import org.springframework.http.MediaType

import reactor.core.publisher.Mono
import org.springframework.util.LinkedMultiValueMap

import org.openapitools.client.infrastructure.*

class AuthApi(client: RestClient) : ApiClient(client) {
class AuthApi(client: WebClient) : ApiClient(client) {

constructor(baseUrl: String) : this(RestClient.builder()
constructor(baseUrl: String) : this(WebClient.builder()
.baseUrl(baseUrl)
.messageConverters { it.add(MappingJackson2HttpMessageConverter()) }
.codecs {
it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
it.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
}
.build()
)


@Throws(RestClientResponseException::class)
fun testAuthHttpBasic(): kotlin.String {
val result = testAuthHttpBasicWithHttpInfo()
return result.body!!
@Throws(WebClientResponseException::class)
fun testAuthHttpBasic(): Mono<kotlin.String> {
return testAuthHttpBasicWithHttpInfo()
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testAuthHttpBasicWithHttpInfo(): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testAuthHttpBasicWithHttpInfo(): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testAuthHttpBasicRequestConfig()
return request<Unit, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -71,14 +75,14 @@ class AuthApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testAuthHttpBearer(): kotlin.String {
val result = testAuthHttpBearerWithHttpInfo()
return result.body!!
@Throws(WebClientResponseException::class)
fun testAuthHttpBearer(): Mono<kotlin.String> {
return testAuthHttpBearerWithHttpInfo()
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testAuthHttpBearerWithHttpInfo(): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testAuthHttpBearerWithHttpInfo(): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testAuthHttpBearerRequestConfig()
return request<Unit, kotlin.String>(
localVariableConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,39 @@ package org.openapitools.client.apis

import com.fasterxml.jackson.annotation.JsonProperty

import org.springframework.web.client.RestClient
import org.springframework.web.client.RestClientResponseException

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.WebClientResponseException
import org.springframework.http.codec.json.Jackson2JsonDecoder
import org.springframework.http.codec.json.Jackson2JsonEncoder
import org.springframework.http.ResponseEntity
import org.springframework.http.MediaType

import reactor.core.publisher.Mono
import org.springframework.util.LinkedMultiValueMap

import org.openapitools.client.models.Pet
import org.openapitools.client.models.Tag
import org.openapitools.client.infrastructure.*

class BodyApi(client: RestClient) : ApiClient(client) {
class BodyApi(client: WebClient) : ApiClient(client) {

constructor(baseUrl: String) : this(RestClient.builder()
constructor(baseUrl: String) : this(WebClient.builder()
.baseUrl(baseUrl)
.messageConverters { it.add(MappingJackson2HttpMessageConverter()) }
.codecs {
it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
it.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
}
.build()
)


@Throws(RestClientResponseException::class)
fun testBinaryGif(): java.io.File {
val result = testBinaryGifWithHttpInfo()
return result.body!!
@Throws(WebClientResponseException::class)
fun testBinaryGif(): Mono<java.io.File> {
return testBinaryGifWithHttpInfo()
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testBinaryGifWithHttpInfo(): ResponseEntity<java.io.File> {
@Throws(WebClientResponseException::class)
fun testBinaryGifWithHttpInfo(): Mono<ResponseEntity<java.io.File>> {
val localVariableConfig = testBinaryGifRequestConfig()
return request<Unit, java.io.File>(
localVariableConfig
Expand Down Expand Up @@ -73,14 +77,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testBodyApplicationOctetstreamBinary(body: java.io.File? = null): kotlin.String {
val result = testBodyApplicationOctetstreamBinaryWithHttpInfo(body = body)
return result.body!!
@Throws(WebClientResponseException::class)
fun testBodyApplicationOctetstreamBinary(body: java.io.File? = null): Mono<kotlin.String> {
return testBodyApplicationOctetstreamBinaryWithHttpInfo(body = body)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testBodyApplicationOctetstreamBinaryWithHttpInfo(body: java.io.File? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testBodyApplicationOctetstreamBinaryWithHttpInfo(body: java.io.File? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testBodyApplicationOctetstreamBinaryRequestConfig(body = body)
return request<java.io.File, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -109,14 +113,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testBodyMultipartFormdataArrayOfBinary(files: kotlin.collections.List<java.io.File>): kotlin.String {
val result = testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files = files)
return result.body!!
@Throws(WebClientResponseException::class)
fun testBodyMultipartFormdataArrayOfBinary(files: kotlin.collections.List<java.io.File>): Mono<kotlin.String> {
return testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files = files)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files: kotlin.collections.List<java.io.File>): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files: kotlin.collections.List<java.io.File>): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testBodyMultipartFormdataArrayOfBinaryRequestConfig(files = files)
return request<Map<String, PartConfig<*>>, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -145,14 +149,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testBodyMultipartFormdataSingleBinary(myFile: java.io.File? = null): kotlin.String {
val result = testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile = myFile)
return result.body!!
@Throws(WebClientResponseException::class)
fun testBodyMultipartFormdataSingleBinary(myFile: java.io.File? = null): Mono<kotlin.String> {
return testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile = myFile)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile: java.io.File? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testBodyMultipartFormdataSingleBinaryWithHttpInfo(myFile: java.io.File? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testBodyMultipartFormdataSingleBinaryRequestConfig(myFile = myFile)
return request<Map<String, PartConfig<*>>, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -181,14 +185,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testEchoBodyFreeFormObjectResponseString(body: kotlin.Any? = null): kotlin.String {
val result = testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body = body)
return result.body!!
@Throws(WebClientResponseException::class)
fun testEchoBodyFreeFormObjectResponseString(body: kotlin.Any? = null): Mono<kotlin.String> {
return testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body = body)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body: kotlin.Any? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testEchoBodyFreeFormObjectResponseStringWithHttpInfo(body: kotlin.Any? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testEchoBodyFreeFormObjectResponseStringRequestConfig(body = body)
return request<kotlin.Any, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -217,14 +221,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testEchoBodyPet(pet: Pet? = null): Pet {
val result = testEchoBodyPetWithHttpInfo(pet = pet)
return result.body!!
@Throws(WebClientResponseException::class)
fun testEchoBodyPet(pet: Pet? = null): Mono<Pet> {
return testEchoBodyPetWithHttpInfo(pet = pet)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testEchoBodyPetWithHttpInfo(pet: Pet? = null): ResponseEntity<Pet> {
@Throws(WebClientResponseException::class)
fun testEchoBodyPetWithHttpInfo(pet: Pet? = null): Mono<ResponseEntity<Pet>> {
val localVariableConfig = testEchoBodyPetRequestConfig(pet = pet)
return request<Pet, Pet>(
localVariableConfig
Expand Down Expand Up @@ -253,14 +257,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testEchoBodyPetResponseString(pet: Pet? = null): kotlin.String {
val result = testEchoBodyPetResponseStringWithHttpInfo(pet = pet)
return result.body!!
@Throws(WebClientResponseException::class)
fun testEchoBodyPetResponseString(pet: Pet? = null): Mono<kotlin.String> {
return testEchoBodyPetResponseStringWithHttpInfo(pet = pet)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testEchoBodyPetResponseStringWithHttpInfo(pet: Pet? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testEchoBodyPetResponseStringWithHttpInfo(pet: Pet? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testEchoBodyPetResponseStringRequestConfig(pet = pet)
return request<Pet, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -289,14 +293,14 @@ class BodyApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testEchoBodyTagResponseString(tag: Tag? = null): kotlin.String {
val result = testEchoBodyTagResponseStringWithHttpInfo(tag = tag)
return result.body!!
@Throws(WebClientResponseException::class)
fun testEchoBodyTagResponseString(tag: Tag? = null): Mono<kotlin.String> {
return testEchoBodyTagResponseStringWithHttpInfo(tag = tag)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testEchoBodyTagResponseStringWithHttpInfo(tag: Tag? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testEchoBodyTagResponseStringWithHttpInfo(tag: Tag? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testEchoBodyTagResponseStringRequestConfig(tag = tag)
return request<Tag, kotlin.String>(
localVariableConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,37 @@ package org.openapitools.client.apis

import com.fasterxml.jackson.annotation.JsonProperty

import org.springframework.web.client.RestClient
import org.springframework.web.client.RestClientResponseException

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.WebClientResponseException
import org.springframework.http.codec.json.Jackson2JsonDecoder
import org.springframework.http.codec.json.Jackson2JsonEncoder
import org.springframework.http.ResponseEntity
import org.springframework.http.MediaType

import reactor.core.publisher.Mono
import org.springframework.util.LinkedMultiValueMap

import org.openapitools.client.infrastructure.*

class FormApi(client: RestClient) : ApiClient(client) {
class FormApi(client: WebClient) : ApiClient(client) {

constructor(baseUrl: String) : this(RestClient.builder()
constructor(baseUrl: String) : this(WebClient.builder()
.baseUrl(baseUrl)
.messageConverters { it.add(MappingJackson2HttpMessageConverter()) }
.codecs {
it.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
it.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(Serializer.jacksonObjectMapper, MediaType.APPLICATION_JSON))
}
.build()
)


@Throws(RestClientResponseException::class)
fun testFormIntegerBooleanString(integerForm: kotlin.Int? = null, booleanForm: kotlin.Boolean? = null, stringForm: kotlin.String? = null): kotlin.String {
val result = testFormIntegerBooleanStringWithHttpInfo(integerForm = integerForm, booleanForm = booleanForm, stringForm = stringForm)
return result.body!!
@Throws(WebClientResponseException::class)
fun testFormIntegerBooleanString(integerForm: kotlin.Int? = null, booleanForm: kotlin.Boolean? = null, stringForm: kotlin.String? = null): Mono<kotlin.String> {
return testFormIntegerBooleanStringWithHttpInfo(integerForm = integerForm, booleanForm = booleanForm, stringForm = stringForm)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testFormIntegerBooleanStringWithHttpInfo(integerForm: kotlin.Int? = null, booleanForm: kotlin.Boolean? = null, stringForm: kotlin.String? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testFormIntegerBooleanStringWithHttpInfo(integerForm: kotlin.Int? = null, booleanForm: kotlin.Boolean? = null, stringForm: kotlin.String? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testFormIntegerBooleanStringRequestConfig(integerForm = integerForm, booleanForm = booleanForm, stringForm = stringForm)
return request<Map<String, PartConfig<*>>, kotlin.String>(
localVariableConfig
Expand Down Expand Up @@ -74,14 +78,14 @@ class FormApi(client: RestClient) : ApiClient(client) {
}


@Throws(RestClientResponseException::class)
fun testFormOneof(form1: kotlin.String? = null, form2: kotlin.Int? = null, form3: kotlin.String? = null, form4: kotlin.Boolean? = null, id: kotlin.Long? = null, name: kotlin.String? = null): kotlin.String {
val result = testFormOneofWithHttpInfo(form1 = form1, form2 = form2, form3 = form3, form4 = form4, id = id, name = name)
return result.body!!
@Throws(WebClientResponseException::class)
fun testFormOneof(form1: kotlin.String? = null, form2: kotlin.Int? = null, form3: kotlin.String? = null, form4: kotlin.Boolean? = null, id: kotlin.Long? = null, name: kotlin.String? = null): Mono<kotlin.String> {
return testFormOneofWithHttpInfo(form1 = form1, form2 = form2, form3 = form3, form4 = form4, id = id, name = name)
.map { it.body }
}

@Throws(RestClientResponseException::class)
fun testFormOneofWithHttpInfo(form1: kotlin.String? = null, form2: kotlin.Int? = null, form3: kotlin.String? = null, form4: kotlin.Boolean? = null, id: kotlin.Long? = null, name: kotlin.String? = null): ResponseEntity<kotlin.String> {
@Throws(WebClientResponseException::class)
fun testFormOneofWithHttpInfo(form1: kotlin.String? = null, form2: kotlin.Int? = null, form3: kotlin.String? = null, form4: kotlin.Boolean? = null, id: kotlin.Long? = null, name: kotlin.String? = null): Mono<ResponseEntity<kotlin.String>> {
val localVariableConfig = testFormOneofRequestConfig(form1 = form1, form2 = form2, form3 = form3, form4 = form4, id = id, name = name)
return request<Map<String, PartConfig<*>>, kotlin.String>(
localVariableConfig
Expand Down
Loading
Loading