-
Notifications
You must be signed in to change notification settings - Fork 24
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
Handle "type" being an array of strings in JSON schema converter #423
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ def make_nullable(self) -> UnionType: | |
type_copy = RecapTypeClass(**attrs, **extra_attrs) | ||
return UnionType([NullType(), type_copy], **union_attrs) | ||
|
||
def is_nullable(self) -> bool: | ||
""" | ||
Returns True if the type is nullable. | ||
:return: True if the type is nullable. | ||
""" | ||
|
||
return isinstance(self, UnionType) and NullType() in self.types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic needs to be tweaked slightly. I believe the right solution is to search self.types for an |
||
|
||
def validate(self) -> None: | ||
# Default to valid type | ||
pass | ||
|
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.
Nit: Maybe a comment here to explain why you're setting
default
even though it's already set inmake_nullable
. It's the right logic, since is_nullable doesn't guarantee a default of none is set, but it's worth noting since it's subtle.