-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DiscriminatorNode access on undefined property #1026
Comments
PR this was introduced in #1009 We're seeing the same issue as our schema is missing the BaseNested:
type: object
discriminator:
propertyName: type
# properties: <---- Missing this properties value here
# type:
# type: string
oneOf:
- $ref: "#/components/schemas/NestedTypeA"
- $ref: "#/components/schemas/NestedTypeB"
Related lines docusaurus-openapi-docs/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx Line 320 in 1bd7b94
docusaurus-openapi-docs/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx Lines 353 to 356 in 1bd7b94
I attempted to make some changes to account for the missing schema.properties value. It's only used to resolve the schema type, which assumed would be possible to grab from the resolved mappings that the
I've had to just change the schema with a generic object definition such as
@sserrata any chances you could share some knowledge around here? Come to think of it, surely the schemaName will always be an object if we're using a discriminator? |
Hi @omonk, thanks for help with debugging. This one was a bit tricky but I settled on a fix that I believe should work. I appreciate if you can help test using the latest canary release. Thanks! |
For my usecase the issue persists with 4.3.0, I've worked around it for now by changing my schema: # ...
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"
InnerClassTypeA:
type: object
properties:
specificFieldA:
type: string
InnerClassTypeB:
type: object
properties:
specificFieldB:
type: string i.e. I've removed the inheritance on the |
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
Context
The relevant part of redacted OAS looks like this:
The text was updated successfully, but these errors were encountered: