quarkus: SmallRye OpenAPI generates incorrect content type when using Spring Web annotations

Bug description quarkus-smallrye-openapi extension does not generate correct content type based on Spring Web annotation provided by quarkus-spring-web extension when generating OpenAPI schema (calling /q/openapi endpoint).

Instead of picking up the content type specified by Spring annotation

@...Mapping(produces = <desired-content-type>)

it generates response content type application/json.

The content type of the application endpoint response itself is correct and unaffected by this bug.

Expected output

openapi: 3.0.3
info:
  title: Generated API
  version: "1.0"
paths:
  /greeting:
    get:
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string

Actual output

openapi: 3.0.3
info:
  title: Generated API
  version: "1.0"
paths:
  /greeting:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: string

To Reproduce

smallrye-openapi-spring-web-reproducer.zip

Steps to reproduce the behavior:

  1. Use both extensions together:
    • quarkus-smallrye-openapi
    • quarkus-spring-web
  2. Define endpoint using Spring annotations and specify response content type, e.g.
@RestController
@RequestMapping("/greeting")
public class GreetingController {

    @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE)
    public String hello() {
        return "Hello Spring";
    }
}
  1. Call OpenAPI endpoint /q/openapi.

Environment (please complete the following information):

  • java -version:
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
  • GraalVM version: 20.3.1
  • Quarkus version: 1.12.0.Final
  • Build tool: Apache Maven 3.6.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

The aforementioned test scenario is passing now on master. 😃

This is now fix in SmallRye. Once we have done a release and pull the new version into Quarkus this should be resolved.