Skip to content

Commit

Permalink
Add call to jsonable_encoder(dict) after converting dataclass to di…
Browse files Browse the repository at this point in the history
…ct in `jsonable_encoder`.
  • Loading branch information
himbeles committed Aug 2, 2021
1 parent cd26878 commit 121b3f1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fastapi/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ def jsonable_encoder(
sqlalchemy_safe=sqlalchemy_safe,
)
if dataclasses.is_dataclass(obj):
return dataclasses.asdict(obj)
obj_dict = dataclasses.asdict(obj)
return jsonable_encoder(
obj_dict,
exclude_none=exclude_none,
exclude_defaults=exclude_defaults,
custom_encoder=custom_encoder,
sqlalchemy_safe=sqlalchemy_safe,
)
if isinstance(obj, Enum):
return obj.value
if isinstance(obj, PurePath):
Expand Down

0 comments on commit 121b3f1

Please sign in to comment.