Fix ClassCastException when allOf array changes to type array

Merged
KA
3mo ago
+97-6

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.