-
Notifications
You must be signed in to change notification settings - Fork 5
fix: improve handling of allOf / anyOf / oneOf #410
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
Conversation
|
|
||
| type IRTypeIntersection = {type: "type-intersection"; types: IRType[]} | ||
| type IRTypeUnion = {type: "type-union"; types: IRType[]} | ||
| type IRTypeOther = string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually will probably aim to leave the typescript types (and schema code) in a "non-stringy" representation all the way through to the emit phase.
This will be particularly important for contextual alterations (eg; readonly / writeonly modifiers)
|
|
||
| // TODO: https://github.com/hapijs/joi/issues/3057 | ||
| it.skip("can intersect unions", async () => { | ||
| it("can intersect unions", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was somewhat forced to fix this, as integration tests started outputting intersected unions due to the richer anyOf / oneOf / allOf support.
The "fix" is rather hacky, but seems to work well enough
| }) | ||
| }) | ||
|
|
||
| async function getActualFromModel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plan to later properly flesh out a set of test cases using in-line IRModel's directly, for cases where $ref isn't required.
| } | ||
|
|
||
| export interface IRModelObject extends IRModelBase { | ||
| allOf: MaybeIRModel[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after this change, it's only the input normalization that has to deal with things being an object, composition or both at once.
intersectionandunion, making handling of compositions in schema/type builder easier to reason aboutoneOfis being treated as equivalent toanyOffor nowallOf/intersectionwhen an object schema is part of a composite, fixing previous information lossoneOf/anyOfto support "looking up" property definitions from the parent objectafter this change it appears
EmptyObjectis no-longer emitted by any of the integration-tests - which is generally a good sign