Skip to content

DiscriminatorNode access on undefined propertyΒ #1026

Open
@pmarschik

Description

@pmarschik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreviewing πŸ‘€Undergoing manual audit to determine if issue should still be active

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions