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

Object schema generated for Unit Kotlin type #2798

Open
orange-buffalo opened this issue Nov 30, 2024 · 1 comment
Open

Object schema generated for Unit Kotlin type #2798

orange-buffalo opened this issue Nov 30, 2024 · 1 comment

Comments

@orange-buffalo
Copy link

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.

@dineshkj13
Copy link

Yes this could break the client in other languages too, client would expect null response but now it expects {} which is not there in the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants