Skip to content

Object schema generated for Unit Kotlin type #2798

Closed
@orange-buffalo

Description

@orange-buffalo

Describe the bug

With upgrade from 2.6.0 to 2.7.0 we experience unexpected changes to generated schema - Unit Kotlin return type appears in the schema.

To Reproduce

Consider Spring REST Controller method like this:

    @PostMapping("{token}/activate")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    suspend fun activateUser(
        @PathVariable token: String,
        @RequestBody @Valid request: UserActivationRequestDto
    ) {
 ...

In 2.6.0, the schema was generated correctly, in our opinion:

  /api/user-activation-tokens/{token}/activate:
    post:
      ...
      responses:
        "204":
          description: No Content

In 2.7.0, however, the extra type is generated:

  /api/user-activation-tokens/{token}/activate:
    post:
     ...
      responses:
        "204":
          description: No Content
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Unit"
...
components:
  schemas:
    Unit:
      type: object

Additional context
As a side note, we are using OpenApiGenerator to generate TypeScript client from the OpenAPI schema, and now the client code has method return types object instead of previous void.

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