Skip to content

fix: dedupe properties when allOf override redefines nested array items (#1218)#1457

Merged
sserrata merged 2 commits into
mainfrom
fix/1218-duplicate-properties-allof-oneof
May 6, 2026
Merged

fix: dedupe properties when allOf override redefines nested array items (#1218)#1457
sserrata merged 2 commits into
mainfrom
fix/1218-duplicate-properties-allof-oneof

Conversation

@sserrata
Copy link
Copy Markdown
Member

@sserrata sserrata commented May 6, 2026

Summary

  • Fixes Schema extends array item results in duplicate properties #1218 — when an allOf branch overrides a nested array's items with oneOf, shared base properties were rendered twice (once at the array-item level, once inside each oneOf branch).
  • Adds foldSiblingsIntoBranches() in createSchema.ts that mirrors Redoc's SchemaModel.initOneOf: when sibling fields appear alongside oneOf/anyOf, fold them into each branch via allOf-merge so each branch is self-contained, then render only the branches.
  • Applied at three combo-render sites: items.allOf merge path, top-level oneOf+properties path, and top-level allOf merge path.

Behavior change

Existing schemas that combine oneOf/anyOf with sibling properties (via allOf or directly) will now render the sibling properties inside each branch tab instead of separately below the tabs. This is the semantically correct interpretation (the constraints apply to every variant) and matches Redoc's output. 9 existing snapshots updated to reflect this — see the __snapshots__ diff.

Test plan

  • New unit regression test: should not duplicate shared item properties when items.allOf combines base + oneOf (#1218)
  • All 32 createSchema.test.ts cases pass
  • New demo fixture at demo/examples/tests/allOf.yaml/allof-array-items-oneof-override (GeoJSON-style FeatureCollectionBase/PointFeature/PolygonFeature/CustomFeatureCollection) generates cleanly via yarn workspace demo gen-api-docs tests
  • Visually verify the new fixture page in the demo via yarn start
  • Spot-check existing pages that exercise allOf + oneOf + shared properties (e.g., discriminator examples, allof-multiple-oneof)

🤖 Generated with Claude Code

…ms (#1218)

When an `allOf` branch overrides a nested array's `items` with `oneOf`, the
merged schema ends up with both `properties` (from the original items) and
`oneOf` (from the override) as siblings. The renderer was emitting both,
duplicating the shared properties.

Fix mirrors Redoc's `SchemaModel.initOneOf` behavior: when sibling fields
appear alongside `oneOf`/`anyOf`, fold them into each branch via allOf-merge
so each branch is self-contained, then render only the branches.

Applied at three combo-render sites in createSchema.ts: items.allOf merge
path, top-level oneOf+properties path, and top-level allOf merge path.

Adds a regression unit test and a `/allof-array-items-oneof-override` demo
fixture under demo/examples/tests/allOf.yaml for manual verification.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Size Change: +7.92 kB (+0.35%)

Total Size: 2.29 MB

📦 View Changed
Filename Size Change
demo/.docusaurus/globalData.json 73.4 kB +1.09 kB (+1.51%)
demo/.docusaurus/registry.js 106 kB +1.59 kB (+1.52%)
demo/.docusaurus/routes.js 100 kB +1.49 kB (+1.5%)
demo/.docusaurus/routesChunkNames.json 41.7 kB +626 B (+1.52%)
demo/build/assets/js/main.********.js 675 kB +2.84 kB (+0.42%)
demo/build/assets/js/runtime~main.********.js 24.4 kB +283 B (+1.17%)
ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 16.4 kB
demo/.docusaurus/i18n.json 372 B
demo/.docusaurus/site-metadata.json 1.58 kB
demo/build/assets/css/styles.********.css 173 kB
demo/build/index.html 99.5 kB
demo/build/petstore/add-pet/index.html 30 kB
demo/build/petstore/create-user/index.html 24.7 kB
demo/build/petstore/create-users-with-array-input/index.html 24.8 kB
demo/build/petstore/create-users-with-list-input/index.html 24.8 kB
demo/build/petstore/delete-order/index.html 24.5 kB
demo/build/petstore/delete-pet/index.html 24.8 kB
demo/build/petstore/delete-user/index.html 25 kB
demo/build/petstore/find-pets-by-status/index.html 25.5 kB
demo/build/petstore/find-pets-by-tags/index.html 26.1 kB
demo/build/petstore/get-inventory/index.html 23.8 kB
demo/build/petstore/get-order-by-id/index.html 24.8 kB
demo/build/petstore/get-pet-by-id/index.html 25.6 kB
demo/build/petstore/get-user-by-name/index.html 25.1 kB
demo/build/petstore/login-user/index.html 25.6 kB
demo/build/petstore/logout-user/index.html 24.4 kB
demo/build/petstore/new-pet/index.html 25 kB
demo/build/petstore/pet/index.html 23.2 kB
demo/build/petstore/place-order/index.html 24 kB
demo/build/petstore/schemas/apiresponse/index.html 25.2 kB
demo/build/petstore/schemas/cat/index.html 39 kB
demo/build/petstore/schemas/category/index.html 26.3 kB
demo/build/petstore/schemas/dog/index.html 39.3 kB
demo/build/petstore/schemas/honeybee/index.html 39.3 kB
demo/build/petstore/schemas/id/index.html 23.4 kB
demo/build/petstore/schemas/order/index.html 27.3 kB
demo/build/petstore/schemas/pet/index.html 38.8 kB
demo/build/petstore/schemas/tag/index.html 24.7 kB
demo/build/petstore/schemas/user/index.html 40.7 kB
demo/build/petstore/store/index.html 22.2 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 30.9 kB
demo/build/petstore/swagger-petstore-yaml/index.html 30.9 kB
demo/build/petstore/update-pet-with-form/index.html 25 kB
demo/build/petstore/update-pet/index.html 25.4 kB
demo/build/petstore/update-user/index.html 25 kB
demo/build/petstore/upload-file/index.html 24.8 kB
demo/build/petstore/user/index.html 22.9 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

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

https://docusaurus-openapi-36b86--pr1457-b2vww6hm.web.app

(expires Wed, 13 May 2026 14:40:46 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

The plugin's compile-time fix only covered the createSchema.ts paths.
The runtime theme component (Schema/index.tsx) has the same combo-render
pattern at four sites: Items, renderChildren, and two SchemaNode allOf
branches. Apply the same foldSiblingsIntoBranches helper consistently.
@sserrata sserrata merged commit c33fb91 into main May 6, 2026
13 of 14 checks passed
@sserrata sserrata deleted the fix/1218-duplicate-properties-allof-oneof branch May 6, 2026 15:10
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.

Schema extends array item results in duplicate properties

1 participant