Skip to content

Schema display with OAS 3.1.x degrades to just objects #5534

@p-bakker

Description

@p-bakker

Paste the yaml below into the editor on https://editor-next.swagger.io/ and look at the request body schema. It'll look like this:

Image

Now modify the schema to use OAS 3.1.0 and look at the request body schema again: it'll have lost all the 'type' names and everything has become objects:

Image
openapi: 3.0.0
info:
  title: Simple API
  version: 1.0.0
  description: A simple API with a PATCH endpoint using anyOf payload

paths:
  /users/{id}:
    patch:
      summary: Update user
      description: Update a user with either basic info or profile data
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserUpdate'
      responses:
        '200':
          description: User updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User updated successfully
        '400':
          description: Bad request
        '404':
          description: User not found

components:
  schemas:
    UserUpdate:
      anyOf:
        - $ref: '#/components/schemas/BasicInfo'
        - $ref: '#/components/schemas/ProfileData'
    
    BasicInfo:
      type: object
      properties:
        name:
          type: string
          example: John Doe
        email:
          type: string
          format: email
          example: john.doe@example.com
      required:
        - name
    
    ProfileData:
      type: object
      properties:
        bio:
          type: string
          example: Software developer with 5 years of experience
        location:
          type: string
          example: New York, NY
        website:
          type: string
          format: uri
          example: https://johndoe.dev
      required:
        - bio

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