Skip to content

fix: handle discriminator subschemas that only inherit via allOf without own properties #1133

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

amalv
Copy link
Contributor

@amalv amalv commented Apr 25, 2025

Description

This PR addresses an issue where the OpenAPI spec defines a discriminator with a subschema that only inherits all fields from the parent (using allOf) and does not define any new properties. Previously, this pattern would cause a runtime error in the Docusaurus OpenAPI plugin due to an attempt to access properties of an undefined object.

See #1132 for more background.

Motivation and Context

OpenAPI allows for discriminator mappings where a child schema inherits all properties from its parent via allOf and does not introduce any new properties. This is a valid and common pattern for modeling inheritance. Prior to this fix, such schemas would cause the documentation build or runtime to fail with a TypeError. This PR adds a safeguard to ensure the code handles these cases gracefully, allowing the documentation to render correctly for all valid OpenAPI discriminator patterns.

How Has This Been Tested?

  • Added a minimal test case in demo/examples/tests/discriminator.yaml under /discriminator-empty-subschema that uses a parent schema with a discriminator and a child schema that only inherits via allOf.
  • Verified that the documentation renders without errors and the schema is displayed as expected.

@amalv amalv changed the title fix: add discriminator empty subschema and safeguard check in Discrim… fix: handle discriminator subschemas that only inherit via allOf without own properties Apr 25, 2025
Copy link

Visit the preview URL for this PR (updated for commit 18d299e):

https://docusaurus-openapi-36b86--pr1133-jp27mkz0.web.app

(expires Sun, 25 May 2025 14:45:34 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata sserrata merged commit ac5ff63 into PaloAltoNetworks:main Apr 25, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants