swagger-api / swagger-api/swagger-ui

oneOf rendering in path section doesn't work properly

Open
#8,128 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Windows 10
  • Browser: Microsoft Edge
  • Version: 103.0.1264.71
  • Method of installation: N/A
  • Swagger-UI version: https://editor.swagger.io/
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: component-test
  description: Components inside PATH section are not rendered properly
  version: 1.0.0
paths:
  /test/example:
    post:
      requestBody:
        content:
          application/json:
            schema:
              "$ref": '#/components/schemas/ListPerson'
      responses:
        '201':
          description: OK

components:
  schemas:
    ListPerson:
      type: object
      properties:
        elements:
          items:
            "$ref": '#/components/schemas/Person'
          type: array

    Person:
      type: object
      properties:
        name:
          description: name
          type: string
          readOnly: true
        age:
          format: int32
          description: age
          type: integer
          readOnly: true
      oneOf:
        - $ref: '#/components/schemas/Dog'
        - $ref: '#/components/schemas/Cat'
    Dog:
      type: object
      properties:
        name:
          description: name
          type: string
          readOnly: true
    Cat:
      type: object
      properties:
        name:
          description: name
          type: string
          readOnly: true
    
    

Swagger-UI configuration options:

  • Not available
Describe the bug you're encountering
To reproduce...

Steps to reproduce the behavior:

  1. Go to 'Path Schema section'
  2. Click on 'ListPerson then click on elements'
  3. See error: missing some properties in Person scheme
Expected behavior

Expected right request body to be shown with all the properties
Note: In the schema section at the bottom of the page the Person object is displayed correctly

Screenshots

image
image

Additional context or thoughts

Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in editor.swagger.io using the supplied OpenAPI 3.0 definition, then inspect the Path Schema section for ListPerson → elements and compare it with the correctly rendered Person schema below. Done means the request body shows all Person properties, including those involved in the oneOf schemas.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.