r/FastAPI • • Nov 12 '21

Question How to distinguish the parameters between the subdependencies of the same type?

I have defined the following dependencies:

class RelativeDeltaParams(BaseModel):
    years: int = 0
    months: int = 0
    weeks: int = 0
    days: int = 0

class DateBuffer(BaseModel):
    backward: RelativeDeltaParams = Depends(RelativeDeltaParams)
    forward: RelativeDeltaParams = Depends(RelativeDeltaParams)

Is it possible to distinguish between backward.years and forward.years?

0 Upvotes

2 comments sorted by

1

u/MakuZo Nov 13 '21

Only by checking to which attribute they belong

1

u/[deleted] Nov 13 '21

Can you elaborate?