This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Validation Error when using response_model
and Dynamic Key type
#988
Labels
Describe the bug
Hi guys, seem that when using a Dynamic Key type of model with
response_model
will raiseValidationError
on the server side and returns500
Internal Server Error
to the client.I have the following example code, I believe I am using it correctly?
could this be relater to #911 ?
I also realize I can substitute
response_model=PetsByName
withresponse_model=Dict[str, str]
, but with the later I am not able to include anexample
inschema_extra
, is there other way to do so? many thanks!To Reproduce
Steps to reproduce the behavior with a minimum self-contained file.
Replace each part with your own scenario:
main.py
It returns a JSON with
Internal Server Error
.But I expected it to return
{'Otis': 'dog', 'Milo': 'cat'}
.Terminal output of the server:
Expected behavior
Add a clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
Additional context
SwaggerUI renders the
PetsByName
model along with the example correctly, no issue there.The text was updated successfully, but these errors were encountered: