Forum Discussion

dinchand's avatar
dinchand
New Contributor
5 years ago

2 exact paths that produce different Media Types in the Specification

We have a current 2 GET endpoints with same path but produces different media type. How can I add them to the openAPI specification yaml ?

  • HKosova's avatar
    HKosova
    5 years ago

    That is supported in OpenAPI 3.0 only.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    In OpenAPI 2.0:

     

    swagger: "2.0"
    ...
    
    paths:
      /something:
        get:
          produces:
            - application/json
            - application/xml
          responses:
            200:
              description: OK
              schema:
                ...

     

     

    In OpenAPI 3.0:

     

    openapi: 3.0.0
    ...
    
    paths:
      /something:
        get:
          responses:
            '200':
              description: OK
              content:
                application/json:
                  schema:
                    ...
                application/xml:
                  schema:
                    ...

     

    • dinchand's avatar
      dinchand
      New Contributor

      HKosova Thanks for the reply. I forgot to mention that both responses also have different schemas. I see that we have the possibility in 3.0 but not in 2.0. Or do I miss something ?

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        That is supported in OpenAPI 3.0 only.