Skip to content

List of value classes in Kotlin #2971

Closed
@detomarco

Description

@detomarco

Describe the bug

  • If you are reporting a bug, please help to speed up problem diagnosis by providing as
    much information as possible:
  • A clear and concise description of what the bug is: the title of an issue is not enough

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    3.4.4

  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi-starter-webmvc-ui

  • A clear and concise description of what you expected to happen.
    Springdoc handles list of Kotlin Value Classes as list of objects, while it should use the type defined inside the value class.
    In the example below, CarId is defined as wrapper of a UUID, so the openapi schema should consider carIds as list of uuids directly, instead of a list of CarId
    Not that this is only valid for lists, while it works as expected for non-list objects

  • Provide with a sample code (HelloController) or Test that reproduces the problem

@JvmInline
value class CarId(val value: UUID)

data class CarIdsDTO(
    val singleId: CardId,
    val ids: List<CarId>
)
  • What is the actual result using OpenAPI Description (yml or json)?
## Actual
    CarIdsDTO:
      type: object
      properties:
        singleId:
           type: array
           format: uuid
        ids:
          type: array
          items:
            $ref: "#/components/schemas/CarId"
     ...
    CarId:
      type: object
      properties:
        value:
          type: string
          format: uuid

  • What is the expected result using OpenAPI Description (yml or json)?
## Expected
    CarIdsDTO:
      type: object
      properties:
        singleId:
           type: array
           format: uuid
        ids:
          type: array
          items:
             type: string
             format: uuid

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions