Skip to content

BUG: One Of / Any Of expanders are not rendered if level greater than schema-expand-level in schema-tree #421

@jurijzahn8019

Description

@jurijzahn8019

Hi there, i discovered this misbehavior

given schema:

openapi: 3.0.3
info:
  title: Test
  description: test
  version: 1.0.0
servers:
  - url: 'http://localhost:9000'
    description: Local server
paths:
  /test:
    get:
      parameters:
        - name: env
          in: path
          schema:
            type: string
            enum: [prod, dev]
            default: production
          example: qa
      responses:
        '200':
          description: 'ok'
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      theFoo:
                        allOf:
                        - type: object
                        - anyOf:
                          - type: object
                            properties:
                              foo:
                                type: string
                          - type: object
                            properties:
                              bar: 
                                type: number
    

and markup:

<rapi-doc 
    id = "thedoc" 
    spec-url="./specs/temp.yaml"
    allow-server-selection = "false"
    show-header = "false"
    show-info	= "true"
    theme = "light"
    allow-try = "true"
    sort-endpoints-by = "summary"
    allow-api-list-style-selection = "false"
    regular-font = 'Open Sans'
    schema-style = 'tree'
    render-style = 'focused'
    default-schema-tab = "model"
    schema-expand-level="1"
  ></rapi-doc>

Settings schema-expand-level="1" and schema-style = 'tree' ends up in this:

image

In Schema Table everything works.

I have fixed this by changing

https://github.com/mrin9/RapiDoc/blob/master/src/components/schema-tree.js#L133

// From
if (data['::type'] === 'object') {

// To
if (data['::type'] === 'object' || (typeof data['::type'] === "string"  && data['::type'].startsWith("xxx-of"))) {

however i do not know whether it is correct solution.
I would be happy to see this fixed

kind regards
and thank you for a great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions