Skip to content

[BUG] Generated Kotlin client do not work with Spring Boot 4 #22411

@rupert-jung-mw

Description

@rupert-jung-mw
Description

Generator creates code like this:

 protected inline fun <reified I : Any, reified T: Any?> request(requestConfig: RequestConfig<I>): ResponseEntity<T> {
        return prepare(defaults(requestConfig))
            .retrieve()
            .toEntity(object : ParameterizedTypeReference<T>() {})
 }

This code das not compile anymore in Spring Web 7 (used by Spring Boot 3):

None of the following candidates is applicable:
fun <T : Any> toEntity(bodyType: Class<T>): ResponseEntity<T>
fun <T : Any> toEntity(bodyType: ParameterizedTypeReference<T>): ResponseEntity<T>`
Propsed solution

It should be enough to change the outer bounds from Any? to Any like this:

    protected inline fun <reified I : Any, reified T: Any> request(requestConfig: RequestConfig<I>): ResponseEntity<T> {
        return prepare(defaults(requestConfig))
            .retrieve()
            .toEntity(object : ParameterizedTypeReference<T>() {})
    }
openapi-generator version

7.17.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions