PaloAltoNetworks / PaloAltoNetworks/docusaurus-openapi-docs

DiscriminatorNode access on undefined property

Open
#1,026 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug reviewing :eyes:
Dominant language
TypeScript
Stars
1.1k
Forks
315
Avg merge
7d 5h
Merged PRs (30d)
7

Description

Describe the bug

With version 4.2.0 OAS discriminator was changed and now results in "This page crashed": TypeError: undefined is not an object (evaluating 'subProperties[discriminator.propertyName]') errors.

Rolling back to 4.1.0 fixes the issue but shows "circular(InnerClassTypeA)".

Your Environment

  • Version used: 4.2.0

Context

The relevant part of redacted OAS looks like this:

# ...
components:
  schemas:
    OuterClass:
      type: object
      properties:
        _TYPE:
          type: string
          enum:
            - type1
            - type2
        sharedProperty:
          type: string
     discriminator:
       propertyName: _TYPE
       mapping:
         type1: "#components/schemas/OuterClassType1"
         type2: "#components/schemas/OuterClassType2"
    OuterClassType1:
      allOf:
        - $ref: "#components/schemas/OuterClass"
        - type: object
          properties:
            # property named the same but different concrete schema per discriminated property
            innerClass:
              $ref: "#components/schemas/InnerClassTypeA"
    OuterClassType2:
      allOf:
        - $ref: "#components/schemas/OuterClass"
        - type: object
          properties:
            # property named the same but different concrete schema per discriminated property
            innerClass:
              $ref: "#components/schemas/InnerClassTypeB"
    # never used directly but only "inherited" from with allOf
    InnerClass:
      type: object
      properties:
        _TYPE:
          type: string
          enum:
            - typeA
            - typeB
        sharedProperty:
          type: string
     discriminator:
       propertyName: _TYPE
       mapping:
         type1: "#components/schemas/InnerClassTypeA"
         type2: "#components/schemas/InnerClassTypeB"
    InnerClassTypeA:
      allOf:
        - $ref: "#components/schemas/InnerClass"
        - type: object
          properties:
            specificFieldA:
              type: string
    InnerClassTypeB:
      allOf:
        - $ref: "#components/schemas/InnerClass"
        - type: object
          properties:
            specificFieldB:
              type: string

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 crash using the redacted OAS schema in the issue and compare the discriminator behavior between versions 4.1.0 and 4.2.0. No files or tests are named, so first trace the schema rendering path that accesses subProperties; done means the supplied nested allOf/discriminator case renders without the undefined-property error.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.