Skip to content

Displayed example not updated sometimes when switching between media types #5460

Description

@hkosova

This issue is related to OAS3 examples support.

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: any
  • Method of installation: https://editor.swagger.io
  • Swagger-UI version: 3.23.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.2
info:
  title: test
  version: 0.0.0
paths:
  /foo:
    post:
      requestBody:
        description: A JSON object, XML object, or text string containing foo data
        required: true
        content:
          application/json:
            schema:
              type: object
            examples:
              foo_json:
                value:
                  foo: bar
              bar_json:
                value:
                  bar: foo
          text/plain:
            schema:
              type: string
              example: Hello, world!
          application/xml:
            schema:
              type: object
            examples:
              foo_xml:
                value: <foo>bar</foo>
              bar_xml:
                value: <bar>foo</bar>
      responses:
        201:
          description: Created

Describe the bug you're encountering

In certain cases, switching between media types does not update the displayed "Example Value".

Steps to reproduce

  1. Go to https://editor.swagger.io and paste the spec above.
  2. Expand the operation.
  3. From the "Examples" list, select "bar_json".
  4. From the media types list, select "application/xml".
    => The "Examples" list is updated to contain "foo_xml" and "bar_xml" but the displayed "Example Value" is not updated.
  5. From the media types list, select "text/plain".
    => "Example Value" still contains the JSON example. Should display "Hello, world!".

Screenshots

Screenshot for step 4:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions