Redocly/redoc

Response example name not displayed when "examples:" section only contains one item

Open

#2192 opened on Oct 20, 2022

View on GitHub
 (1 comment) (0 reactions) (0 assignees)TypeScript (21,877 stars) (2,272 forks)batch import
Type: Enhancementhelp wanted

Description

Describe the bug When an endpoint's response examples: section contains a single item, the name of that item doesn't appear above the JSON example code in the right content pane.

Expected behavior When an endpoint's response examples: section contains a single item, the name of that item appears above the JSON example code in the right content pane -- either in a dropdown box (as when the examples: section contains multiple items), or in some other fashion (e.g. label/text).

Minimal reproducible OpenAPI snippet(if possible)

paths:
  '/sites/{siteId}/users/{userId}/cart/clear':
    post:
      tags:
        - CartApi
      summary: Delete all items in a cart.
      description: <p><i>No comparable method currently exists in the monolith's codebase; this is new functionality.</i></p><p>Delete all quantities & properties of all products & services that were previously added to a shopping cart.</p>
      operationId: CartApi_DeleteAllItemsInCart
      parameters:
        - name: siteId
          in: path
          description: ID of the site to which the shopping cart is scoped.
          required: true
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
            format: int32
        - name: userId
          in: path
          description: ID of the user to whom the shopping cart is scoped.
          required: true
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
            format: int32
      responses:
        '200':
          description: <p>The API request was successfully processed; an object describing the empty cart is returned.</p>
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCartSummaryResponse'
              examples:
                All items in the shopping cart were deleted.:
                  value: {"cartGuid":"0fa1ef5f-5395-4679-901d-fd6c941f3460","cartItems":[]}
paths:
  '/sites/{siteId}/users/{userId}/cart/clear':
    post:
      tags:
        - CartApi
      summary: Delete all items in a cart.
      description: <p><i>No comparable method currently exists in the monolith's codebase; this is new functionality.</i></p><p>Delete all quantities & properties of all products & services that were previously added to a shopping cart.</p>
      operationId: CartApi_DeleteAllItemsInCart
      parameters:
        - name: siteId
          in: path
          description: ID of the site to which the shopping cart is scoped.
          required: true
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
            format: int32
        - name: userId
          in: path
          description: ID of the user to whom the shopping cart is scoped.
          required: true
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
            format: int32
      responses:
        '200':
          description: <p>The API request was successfully processed; an object describing the empty cart is returned.</p>
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCartSummaryResponse'
              examples:
                All items in the shopping cart were deleted.:
                  value: {"cartGuid":"0fa1ef5f-5395-4679-901d-fd6c941f3460","cartItems":[]}
                DUMMY:
                  value: {"cartGuid":"0fa1ef5f-5395-4679-901d-fd6c941f3460","cartItems":[]}

Screenshots

image

image

Additional context Add any other context about the problem here.

Contributor guide