New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declaring specific class as response_model in FastAPI produces RecursionError #580
Comments
Can you check with an older release i.e. 0.10.24? Want to know if this is something new |
It also occurs on 0.10.24. Thank you for the fast response! |
Thanks for checking, can you also post a sample payload you are using to call this API endpoint, will be easier to test. See that you are using python 3.10 which is not yet fully supported, which database and driver are you using? |
I am using sqlite ( Example payload{
"title":"Some test question",
"description":"A description",
"questions":[
{
"question":"Is ClassQuiz cool?",
"answers":[
{
"right":true,
"answer":"Yes"
},
{
"right":false,
"answer":"No"
}
]
},
{
"question":"Do you like open source?",
"answers":[
{
"right":true,
"answer":"Yes"
},
{
"right":false,
"answer":"No"
},
{
"right":false,
"answer":"Maybe"
}
]
}
]
} My route@router.post("/create")
async def create_quiz_lol(quiz_input: QuizInput, user: User = Depends(get_current_user)):
quiz = Quiz(**quiz_input.dict(), user_id=user.id)
return await quiz.save() |
Hmmm, from what I've seen, if you set |
I don't know, but it displays the return model in the openapi schema, so that's enough for me. |
Fixed in 0.11.0 - please update and check. |
Yes, the RecursionError is gone, but now, I get the following ValueError: [TypeError("'ModelField' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')] |
Can you provide some code behind this? Cause i used your code for a test case that passes so need something more to reproduce. |
Oh, I should have added that this error only occurs if you try to access the |
Describe the bug
I get a RecursionError if the
Quiz
from below is set as theresponse_model
in a FasAPI route-decorator.Like this:
Versions (please complete the following information):
ormar
0.10.25pydantic
1.9.0FastAPI
0.74.1The text was updated successfully, but these errors were encountered: