Uploaded image for project: 'Quarkus'
  1. Quarkus
  2. QUARKUS-849

SmallRye OpenAPI generates incorrect content type when using Spring Web annotations

    XMLWordPrintable

Details

    • Hide

      Use both extensions together:

      • quarkus-smallrye-openapi
      • quarkus-spring-web

      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";
          }
      }
      

      Call OpenAPI endpoint /q/openapi.

      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
      
      Show
      Use both extensions together: quarkus-smallrye-openapi quarkus-spring-web 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" ; } } Call OpenAPI endpoint /q/openapi . 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
    • Undefined
    • +
    • ---

    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.

      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.

       

      Attachments

        Activity

          People

            pkruger@redhat.com Phillip Krüger
            rhn-support-jsmrcka Josef Smrcka (Inactive)
            Josef Smrcka Josef Smrcka (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: