getsentry / json-schema-diff

Diff changes between JSON schemas
https://docs.rs/json-schema-diff/
15 stars 2 forks source link

do not clone Schema, clone only when the inner struct is Bool #34

Closed 6293 closed 1 year ago

6293 commented 1 year ago

follow-up for https://github.com/getsentry/json-schema-diff/pull/32#discussion_r1196514057

Previously DiffWalker::diff would receive SchemaObject instead of Schema. When we want to call the method recursively, however, this interface forces us to clone the schema, as the type for child schemas (subschemas, properties and array items) is Schema, not SchemaObject. Cloning should be performed only on boolean schema, because it is ok to clone boolean schema which is small, but not SchemaObject because the object could be huge depending on the user input.