Skip to content

Example generator still truncates nested schemas at level 8 (follow-up to #1160) #1171

Open

Description

@azaczek

#1160 fixed the schema table in 12.0.0, but the example generator schemaToSampleObj still stops at level > 8. Each allOf member counts as a level, so a field that is only 5 properties deep is silently missing from the generated example.

Minimal spec
openapi: 3.0.3
info: { title: repro, version: 1.0.0 }
paths:
  /root:
    get:
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Root' }
components:
  schemas:
    Root:
      type: object
      properties:
        a: { $ref: '#/components/schemas/A' }
    A:
      allOf:
        - type: object
          properties:
            b: { $ref: '#/components/schemas/B' }
    B:
      allOf:
        - type: object
          properties:
            c: { $ref: '#/components/schemas/C' }
    C:
      allOf:
        - type: object
          properties:
            d: { $ref: '#/components/schemas/D' }
    D:
      allOf:
        - type: object
          properties:
            e: { type: string, enum: [X, Y] }

Expected (as in 9.3.8; the schema table in 12.0.0 is already correct)

{
  "a": {
    "b": {
      "c": {
        "d": {
          "e": "X"
        }
      }
    }
  }
}

Actual (12.0.0)

{
  "a": {
    "b": {
      "c": {
        "d": {}
      }
    }
  }
}

Cause

schemaToSampleObj in packages/rapidoc/src/utils/schema-utils.js still has if (!schema || level > 8) return; and increments level for every allOf member. Applying the same depth handling as the schema table (#1160), or not counting allOf members as a level, would fix it.

Environment

RapiDoc 12.0.0 (official npm bundle), also reproduced in 11.0.1; correct in 9.3.8
render-style="focused" schema-style="table"
OpenAPI 3.0.3, validated against https://spec.openapis.org/oas/3.0/schema/2021-09-28

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

    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