lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.42k stars 489 forks source link

fix: Validate intersection with multiple unions #1501

Closed connor-g-swyftx closed 9 months ago

connor-g-swyftx commented 10 months ago

This fixes a bug in validation of intersections with multiple unions. If the intersection includes at least three unions, only the first schema per union is accepted. One of the unions must have an overlapping required property to hit this bug.

I have written a failing test in f4531619fa75064cd980fe4d5f6c1654da4c3186, and fixed it in f5f5fdb3ffc9630ec245f1e5b62b472b0377d0e0.

There has been similar work in the past on intersection validation in https://github.com/lukeautry/tsoa/pull/888.

All Submissions:

Closing issues

Put closes #XXXX (where XXXX is the issue number) in your comment to auto-close the issue that your PR fixes.

Test plan

I've written parameterized tests to cover all valid schema combinations, and parameterized tests for invalid inputs covering invalid dataypes, missing required properties, and excess properties.

WoH commented 9 months ago

Can you slap a return type onto buildContext (any/unknown is fine) to get the CI result? LGTM, but I want the CI to confirm

connor-g-swyftx commented 9 months ago

@WoH done, thanks