-
Notifications
You must be signed in to change notification settings - Fork 0
feat: nullable in OAS 3.0 is equivalent to union with null type in 3.1 #42
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
...rces/openapi-3_0-to-3_1/could-compare-overridden-description-via-reference-object/after.json
Show resolved
Hide resolved
test/oas-30-to-31.test.ts
Outdated
| }) | ||
|
|
||
| describe('Comparison nullable and null type', () => { | ||
| test('could compare nullable to anyOf', () => { |
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.
'nullable is equivalent to anyOf with null type'
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.
done
# Conflicts: # package.json
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.
Comments about types are just recommendations
src/openapi/openapi3.schema.ts
Outdated
| ) | ||
|
|
||
| const inputOrigins = valueWithoutNullable[originsFlag] as Record<PropertyKey, unknown> | undefined | ||
| const nullTypeOrigins = nullTypeObject[originsFlag] as Record<PropertyKey, unknown> | undefined ?? {} |
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.
it's better to check type explicitly with isObject
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.
done
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.
it's not necessary to cast type if you checked it explicitly. If it doesn't work, maybe you have to extract it to fixed const before checking.
It increases code size, but it is more type safe
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.
The only 1 recommendation is left about removing casting after type check. It is already type safe, but a little bit ugly
No description provided.