-
-
Notifications
You must be signed in to change notification settings - Fork 528
Use of OneOf
type causing upcasting to any
#1019
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
Comments
It seems the root issue here is the |
I'm not sure if it's worth the tradeoff, but I patched openapi-typescript to use union | instead of the OneOf generic type to handle this in a project of mine. It seems like the cost of this issue might outweigh the value of being strict about excess properties. |
You raise a good point—if this isn’t working as-is, a union would give better results. Funny enough the reason for the But that said, in practice, these are used very differently in schemas. And even if So anyways, I’ll investigate whether or not the |
Crude and horrible workaround: pass a const transform = (schema, metadata) => {
// Workaround for https://github.com/drwpow/openapi-typescript/issues/1019
if ("oneOf" in schema && schema.oneOf.length > 5) {
schema.anyOf = schema.oneOf
delete schema.oneOf
}
} |
Description
The
OneOf
function hits a call stack limit on larger unions (>8 entities).openapi-typescript
6.1.0
19.1.0
4.9.4
macOS 13
Reproduction
Visit this sandbox
Expected result
OneOf
type handles larger arguments without issueActual result
OneOf
type exceeds call stack limit after an array of size 8.Checklist
Notes
I've done the following as a workaround, although I suspect this will lead to type inaccuracies.
The text was updated successfully, but these errors were encountered: