swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.67k stars 8.97k forks source link

Swagger UI does not render content types other than application/json for POST operations. #7858

Closed menakaj closed 2 years ago

menakaj commented 2 years ago

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

post:
      requestBody:
        content:
          application/fhir+json:
            schema:
              type: object
              properties:
                name:
                  type: string
          text/plain:
            schema:
              type: string
        required: true
      responses:
        '200':
          description: OK
      security:
        - default: []

Swagger-UI configuration options:

SwaggerUI({
  // your config options here
})
?yourQueryStringConfig

Describe the bug you're encountering

When using other content types for POST request body, they are shown as application/json. If multiple content types are provided, it's only rendering the json type.

To reproduce...

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Screenshots

Screenshot 2022-02-22 at 12 45 48

This is rendering correctly for PUT operations.

Screenshot 2022-02-22 at 12 52 19

Additional context or thoughts

menakaj commented 2 years ago

We were able to identify the issue and fix it. The cause was due to some changes that are being done to the actual swagger content.

Closing the issue since this is not an issue in the SwaggerUI library.