You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through the documentation on this it mentions how to exclude the fields from a collection of nested model. However, it needs an update where it mentions how to exclude fields if someone uses a collection of nested union models.
For e.g.
# Assuming correct imports are in place@dataclassclassAddress:
street: strcity: strcountry: str@dataclassclassPerson:
name: strage: intemail: straddress: Addresschildren: list['Person'|None]
# The DTO will change like:classReadDTO(DataclassDTO[Person]):
config=DTOConfig(exclude={"email", "address.street", "children.0.0.email", "children.0.0.address"})
# We need to provide two zeroes instead of one.
Now there is a line in the document which states
Given a generic type, with an arbitrary number of type parameters (e.g., GenericType[Type0, Type1, ..., TypeN]), we use the index of the type parameter to indicate which type the exclusion should refer to. For example, a.0.b, excludes the b field from the first type parameter of a, a.1.b excludes the b field from the second type parameter of a, and so on.
However, it is not very clear and an example in the document might help.
Working without union (as per example)
Union introduced
Union introduced (add extra zero to exclude)
Important
Order of union matters too and therefore key must be changed based on the order.
The text was updated successfully, but these errors were encountered:
Summary
I was going through the documentation on this it mentions how to exclude the fields from a collection of nested model. However, it needs an update where it mentions how to exclude fields if someone uses a collection of nested union models.
For e.g.
Now there is a line in the document which states
Given a generic type, with an arbitrary number of type parameters (e.g., GenericType[Type0, Type1, ..., TypeN]), we use the index of the type parameter to indicate which type the exclusion should refer to. For example, a.0.b, excludes the b field from the first type parameter of a, a.1.b excludes the b field from the second type parameter of a, and so on.
However, it is not very clear and an example in the document might help.
Working without union (as per example)
Union introduced
Union introduced (add extra zero to exclude)
Important
Order of union matters too and therefore key must be changed based on the order.
The text was updated successfully, but these errors were encountered: