Skip to content

Commit

Permalink
Fix parsing ref on root model (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
koxudaxi authored Feb 18, 2021
1 parent cf200fa commit 4e04f11
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions datamodel_code_generator/parser/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def is_object(self) -> bool:
and not self.allOf
and not self.oneOf
and not self.anyOf
and not self.ref
)

@cached_property
Expand Down Expand Up @@ -747,14 +748,14 @@ def parse_root_type(
path: List[str],
additional_properties: Optional[JsonSchemaObject] = None,
) -> DataType:
if obj.type:
if obj.ref:
data_type = self.get_ref_data_type(obj.ref)
elif obj.type:
data_type: DataType = self.get_data_type(obj)
elif obj.anyOf:
data_type = self.parse_any_of(name, obj, [*path, name])
elif obj.oneOf:
data_type = self.parse_one_of(name, obj, [*path, name])
elif obj.ref:
data_type = self.get_ref_data_type(obj.ref)
else:
data_type = self.data_type_manager.get_data_type(Types.any)
if self.force_optional_for_required_fields:
Expand Down

0 comments on commit 4e04f11

Please sign in to comment.