Skip to content

Swagger UI doesn't render responses if OpenAPI extension is present #2349

@alexandre-baron

Description

@alexandre-baron

When creating a simple Quarkus application with these extensions :

  • io.quarkus:quarkus-smallrye-openapi
  • io.quarkus:quarkus-resteasy-jackson

And just updating the ExampleResource by adding an @Extension and an @APIResponse like this :

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Extension(name = "x-tenant", value = "acme")
    @APIResponses(
        APIResponse(responseCode = "200", description = "The hello message"),
        APIResponse(responseCode = "500", description = "Internal server error")
    )
    fun hello() = "Hello RESTEasy"

It produces this OpenAPI specification :

{
  "openapi" : "3.1.0",
  "paths" : {
    "/hello" : {
      "get" : {
        "responses" : {
          "200" : {
            "description" : "The hello message",
            "content" : {
              "text/plain" : {
                "schema" : {
                  "type" : "string"
                }
              }
            },
            "x-tenant" : "acme"
          },
          "500" : {
            "description" : "Internal server error",
            "x-tenant" : "acme"
          },
          "x-tenant" : "acme"
        },
        "x-tenant" : "acme",
        "summary" : "Hello",
        "tags" : [ "Example Resource" ]
      }
    }
  },
  "info" : {
    "title" : "prout-quarkus API",
    "version" : "1.0-SNAPSHOT"
  }
}

And this OpenAPI specification produces an error message 😱 Could not render responses_Responses, see the console. in the Swagger-UI.

The problem seems to be that Swagger-UI doesn't accept OpenAPI extension in Responses object. Whereas OpenAPI specification allow them (cf. OpenAPI documentation).

By removing the "x-tenant": "acme" in responses object like the following example, the Swagger-UI can display the responses part.

        "responses" : {
          "200" : {
            "description" : "The hello message",
            "content" : {
              "text/plain" : {
                "schema" : {
                  "type" : "string"
                }
              }
            },
            "x-tenant" : "acme"
          },
          "500" : {
            "description" : "Internal server error",
            "x-tenant" : "acme"
          }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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