swagger-api / swagger-api/swagger-ui

Models: Don't wrap anyOf, oneOf, allOf in curly brackets

Open
#4,088 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Q A
Bug or feature request? Feature (Enhancement)
Which Swagger/OpenAPI version? 3.0.x
Which Swagger-UI version? Docker: swaggerapi/swagger-editor@sha256:3b583ca9e0f22caae4d8cd16752dc3f98f86b13d722b6d7cda6e84adf204a35e
How did you install Swagger-UI? Docker
Which browser & version? Chrome Version 63.0.3239.132 (Official Build) (64-bit)
Which operating system? MacOS
Demonstration API definition
openapi: 3.0.0
info:
  title: Test API
  version: 0.0.1
servers:
  - url: 'localhost:3000/api'
    description: Local API URL.
paths:
  /test:
    get:
      requestBody:
        content:
          application/json:
            schema: {}

      responses:
        '200':
          description: OK
components:
  schemas:
    Sample:
      oneOf:
        - type: integer
        - type: boolean

    SampleObject:
      type: object
      properties:
        foo:
          type: integer
Expected Behavior

When rendering Models don't wrap anyOf, allOf, or oneOf in {}

Current Behavior

image
image

Context

Wrapping oneOf (etc) in { } is in conflict with using { } to represent an Object. It implies one of the models is embedded within an Object.

image

This is especially evident when the oneOf element is collapsed:
image

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

Start with the provided OpenAPI 3.0 YAML example and compare the current and expected Model rendering shown in the issue images. Trace the Model renderer responsible for oneOf, anyOf, and allOf; done means these combinators render without curly brackets while ordinary objects retain them.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.