Bug: OpenAPI error: type object '<MyInputModel>' has no attribute '__parameters__' #3651
Open
1 of 4 tasks
Labels
Bug 🐛
This is something that is not working as expected
OpenAPI
This is related to our OpenAPI schema
Triage Required 🏥
This requires triage
Description
Hello, I come to you with an annoying little bug which cannot reproduce. 🤷
When trying to browse to
http://127.0.0.1:8080/schema
I get this wonderful error:The cause seems to be a generic class (see
MyInputModel
in MCVE). When debugging into the litestar code that model does indeed not have a__parameters__
attribute. If I understand this and this correctly,__parameters__
might not always exist. Read: "Note that generics with ParamSpec may not have correct parameters after substitution in some cases because they are intended primarily for static type checking."Unfortunately, I cannot reproduce this (the model in the MCVE has the same structure, but always has
__parameters__
when I test it). Nonetheless, it seems thatget_type_hints_with_generics_resolved
should account for that.My non-reproducible example model works, if I replace line 263 in
litestar/utils/typing.py
:I assume it is not as straight forward as that, as
__type_params__
seems not to be available before python 3.12 PEP 695. But I am no expert so, maybe it is. ;)Cheers
URL to code causing the issue
No response
MCVE
Steps to reproduce
Screenshots
No response
Logs
No response
Litestar Version
2.10.0
Platform
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: