-
-
Notifications
You must be signed in to change notification settings - Fork 481
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(openapi-typescript): handle nullable schemas #2059
base: main
Are you sure you want to change the base?
fix(openapi-typescript): handle nullable schemas #2059
Conversation
|
581e476
to
4339d72
Compare
Hello @drwpow , Once we resolve that I'll finalize the PR |
That’s my understanding. If you look at the OpenAPI 3.1 specification, you’ll often see typings like this: |
obj1: { | ||
type: "object", | ||
nullable: true, | ||
$ref: "#/components/schemas/obj1Ref", |
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.
As discussed, this is simply an invalid type. We shouldn’t be testing this. To combine obj1Ref
and these properties, it must be within allOf
or anyOf
. We can also simply remove this test if it’s the only one failing (haven’t looked a the failure logs yet)
Changes
Allow all types except UNKNOWN to be nullable.
Fixes #1821 and #1940 .
How to Review
I re-applied #1959 (it didn't move for a while)
I added tests for the new syntax (
oneOf: [SchemaFoo, { type: "null" }]
).I also wanted to add test for both syntax, mainly for our use case.
Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript)