mokkabonna / json-schema-merge-allof

Simplify your schema by combining allOf
97 stars 23 forks source link

Merging examples #22

Open ottomata opened 4 years ago

ottomata commented 4 years ago

Hiya, I'm not sure if this should be in json-schema-merge-allof or just left up to me to write a custom resolver.

When merging JSONSchemas, I think we can assume that any examples of each of the to-be-merged schemas should also be merged. Since JSONSchema examples is an array, we need to merge each corresponding examples array element in each of the to-be-merged schemas. When encountering arrays, the default behavior seems to be to concatenate them, but examples should have each element merged.

I wrote a custom resolver for examples here: https://github.com/wikimedia/jsonschema-tools/pull/14/files but I could alternatively submit a PR to make this the default behavior for examples if that would make sense to you.

Feel free to decline this issue if you'd rather not change the behavior.