Skip to content

Schema inferred from function's return signature. #1042

@cgarciae

Description

@cgarciae

Hey @tiangolo! I've been wondering why FastAPI doesn't use the function's return -> signature instead of the response_model argument? I think it would be a bit more natural to express the return schema like this:

@router.post("/")
def create_worker(
    params: CreateWorker, auth_token: str = Depends(shared.get_authorization)
) -> CreateWorkerResponse:
    # code
    return CreateWorkerResponse(...)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions