Skip to content

show referenced schema name instead of "Items" for array items with OAS 3.1.x UI #10794

Description

@adrianodpdiaz

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Example
  version: 1.0.0
paths:
  /users:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
components:
  schemas:
    User:
      type: object
      description: A user of the system.
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
      required: [id, name]
    UserList:
      type: object
      description: A list of User instances.
      properties:
        results:
          type: integer
        users:
          type: array
          items:
            $ref: '#/components/schemas/User'
      required: [results, users]

Is your feature request related to a problem?

In OpenAPI 3.1, when a schema has an array property whose items points to a $ref, the model viewer renders the generic label Items for that sub-schema entry instead of the referenced schema name. This hides the object contained in the array.

Image

In OpenAPI 3.0, the same structure correctly displays the referenced schema name (e.g. User) instead of Items.

Image

Describe the solution you'd like

When rendering an array property in the OAS 3.1 model viewer, if the items schema was resolved from a $ref to a named component (#/components/schemas/{Name}), use that schema name as the label instead of the hardcoded Items. The Items label should remain as fallback for anonymous schemas.

This brings OAS 3.1 behaviour in line with OAS 3.0 for this case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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