New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: merge compatible definitions in union types #722
base: next
Are you sure you want to change the base?
Commits on Mar 25, 2021
-
fix: Merge compatible definitions in union types
Most validation keywords apply to only one of the basic types, so a "string" type and an "array" type can share a definition without colliding as a ["string", "array"] type, as long as they don't have any incompatibilities with each other. Modify UnionTypeFormatter to collapse these disjoint types into a single definition, without using anyOf.
Configuration menu - View commit details
-
Copy full SHA for 246b65c - Browse repository at this point
Copy the full SHA 246b65cView commit details -
Update src/Utils/mergeDefinitions.ts
Change the array.flat() call to use spread notation, since both members are guaranteed to be arrays (unlike the types call, above). Thanks for the suggestion, @domoritz! Co-authored-by: Dominik Moritz <domoritz@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 6b0e19b - Browse repository at this point
Copy the full SHA 6b0e19bView commit details
Commits on Mar 26, 2021
-
Updating test snapshots; fixing reachability tests
The vega-lite test originally worked after updating the snapshot, but there was a broken reference that got mistakenly purged by removeUnreachable (which assumed that any definition would only ever have a single property that could hold references). Added a validation check to vega-lite.test to register the failure, updated addReachable to check all possible properties (unless $ref is set; the spec says that everything else gets ignored in that case).
Configuration menu - View commit details
-
Copy full SHA for 109b78e - Browse repository at this point
Copy the full SHA 109b78eView commit details
Commits on Mar 27, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 291ebf9 - Browse repository at this point
Copy the full SHA 291ebf9View commit details
Commits on Mar 28, 2021
-
Adding functional tests, mergeDefinitions tests
In addition to the raw schema tests which just check that nothing has changed since the last snapshot, this adds makeExemplar, which builds a raw value using the parsed BaseType representation of a TypeScript type tree. This way, tests can specify valid/invalid data to be verified using the Ajv validator in addition to raw schema output tests.
Configuration menu - View commit details
-
Copy full SHA for 30c22f7 - Browse repository at this point
Copy the full SHA 30c22f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 58f0dc9 - Browse repository at this point
Copy the full SHA 58f0dc9View commit details -
mergeDefinitions works on trivially-mergable types
In a few simple cases like (1 | number), mergeDefinitions will now correctly collapse two not-quite-disjoint type definitions together, by discarding the validation restrictions on the more-restricted type. This replaces the string-merging logic in UnionTypeFormatter, which was discarding annotations.
Configuration menu - View commit details
-
Copy full SHA for 79d1855 - Browse repository at this point
Copy the full SHA 79d1855View commit details