Skip to content

Fix ClassCastException when allOf array changes to type array#916

Open
kamilkrzywanski wants to merge 2 commits into
OpenAPITools:masterfrom
kamilkrzywanski:fix/887-allof-array-classcastexception
Open

Fix ClassCastException when allOf array changes to type array#916
kamilkrzywanski wants to merge 2 commits into
OpenAPITools:masterfrom
kamilkrzywanski:fix/887-allof-array-classcastexception

Conversation

@kamilkrzywanski

@kamilkrzywanski kamilkrzywanski commented Jul 25, 2026

Copy link
Copy Markdown

Fixes #887

When a property changes from allOf wrapping an array schema to a direct type: array, the left side stays a ComposedSchema after resolution while the right side is an ArraySchema. Casting both to ArraySchema threw ClassCastException.

Changes:

  • copy items when merging composed schemas in addSchema
  • use Schema#getItems() in ArraySchemaDiffResult instead of casting
  • add regression test from the issue repro

Summary by cubic

Fixes a crash when diffing array schemas that change from an allOf-wrapped array to a direct type: array. Prevents ClassCastException and ensures the specs compare equal.

  • Bug Fixes
    • Copy items in addSchema when merging composed schemas.
    • Use Schema#getItems() in ArraySchemaDiffResult instead of casting.
    • Strengthen regression: assert no exception and that both specs are equal.

Written for commit 99b2f79. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread core/src/test/java/org/openapitools/openapidiff/core/Issue887Test.java Outdated
Assert the allOf-array and direct-array specs compare equal instead of
only checking isCompatible(), which is also true for no changes.
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.

ClassCastException when comparing schema changed from allOf to direct array type

1 participant