Skip to content

[Bug]: kotlin inline classes produce weird field names #5007

@jlous

Description

@jlous

Description of the problem/issue

Generating open-api for kotlin code using jakarta, eg. using swagger-maven-plugin-jakarta:

  • When a field type is a kotlin inline class, the field name is mangled in the generated open-api spec.

The class in question (inline of String) works fine with Jackson, but Swagger does not understand it.

Affected Version

2.2.36
Confirmed in 2.2.22
Probably been there forever

Steps to Reproduce

  • In a Spring Boot app using Jakarta/Jersey (might not be relevant, but that is where it was observed):
@JvmInline
value class BankRegistryNumber(val asString: String) {
    override fun toString(): String = asString
}

class TestRequest(
    val customer: String,
    val bank: BankRegistryNumber,
)

@Controller
@Path("/test")
class TestResource() {
    
    @POST
    @Path("/test")
    fun test(
        @RequestBody req: TestRequest,
    ): Response {
        return accepted().build()
    }
}
  • Generate open-api, e.g. using swagger-maven-plugin-jakarta

Expected Behavior

shema for TestRequest is

{
  "customer": "string",
  "bank": "string"
}

Actual Behavior

shema for TestRequest is

{
  "customer": "string",
  "bank-4FVcRo8": "string"
}

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions