Skip to content

Commit

Permalink
fix condition for typed_default (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
koxudaxi committed Jun 19, 2020
1 parent 6630985 commit 2cc4d0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datamodel_code_generator/parser/jsonschema.py
Expand Up @@ -122,7 +122,7 @@ def validate_items(cls, values: Any) -> Any:

@property
def typed_default(self) -> Union[str, bool, Dict[Any, Any], None]:
if self.default and self.type:
if self.default is not None and self.type:
type_ = self.type[0] if isinstance(self.type, list) else self.type
return self._get_typed_default(type_, self.default)
return None
Expand Down
2 changes: 2 additions & 0 deletions tests/parser/test_jsonschema.py
Expand Up @@ -192,7 +192,9 @@ def test_parse_one_of_object(source_obj, generated_classes):
'type_,default,expected',
[
('string', 'abc', "'abc'"),
('string', '', "''"),
('number', 123, 123),
('number', 0, 0),
('boolean', 'true', True),
('boolean', 'false', False),
('null', 'null', None),
Expand Down

0 comments on commit 2cc4d0d

Please sign in to comment.