Skip to content
Discussion options

You must be logged in to vote

... filter the dict yourself , in your code

@router.post("/register")
async def register(user:dict = Body(...)):
    print(user["user"])

you could also do a model ( pydantic ) for an input validation of the json

you can close your issue , thank you

Well, even if there has been no perfect method, I find a somewhat elegant way to solve.

add a optional param that cannot be captured to the function and the param user will be accepted as I want

@router.post("/register")
async def register(user:dict = Body(...),_:Optional[str] = Body("")):
    "the code"

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tiangolo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
Converted from issue

This discussion was converted from issue #2927 on February 27, 2023 23:19.