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"
}
}
When creating a simple Quarkus application with these extensions :
io.quarkus:quarkus-smallrye-openapiio.quarkus:quarkus-resteasy-jacksonAnd just updating the
ExampleResourceby adding an@Extensionand an@APIResponselike 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"inresponsesobject like the following example, the Swagger-UI can display the responses part.