Skip to content

[Kotlin][Spring] Response code 200 generated for default responses #17445

@cureaid

Description

@cureaid

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

For default responses, a response code of 200 is generated but should be a response code of default.
When there is a response with code 200 in the spec before the default response, then the default response "overrides" the one with the code 200 in the Swagger UI, i.e. the real 200 response description is invisible in the Swagger UI.

openapi-generator version

7.2.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: example
  version: 0.0.1
paths:
  /pet:
    post:
      responses:
        'default':
          description: foo
          content:
            application/xml:
              schema:
                type: object
Generation Details
docker run --rm -v "${PWD}/output:/output" -v "${PWD}/openapi.yaml:/openapi.yaml" openapitools/openapi-generator-cli generate -i /openapi.yaml -g kotlin-spring -o /output
Steps to reproduce

see above

Actual output
class PetApiController() {

    @Operation(
        summary = "",
        operationId = "petPost",
        description = """""",
        responses = [
            ApiResponse(responseCode = "200", description = "foo", content = [Content(schema = Schema(implementation = kotlin.Any::class))]) ]
    )
Expected output
class PetApiController() {

    @Operation(
        summary = "",
        operationId = "petPost",
        description = """""",
        responses = [
            ApiResponse(responseCode = "default", description = "foo", content = [Content(schema = Schema(implementation = kotlin.Any::class))]) ]
    )
Related issues/PRs
Suggest a fix

Should maybe be done similar to the PR referenced in #14394 .

There is also suspicious code in

.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions