Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Hello,
I came across a strange behaviour while progamming an app.
I managed to reproduce it starting from this example code in the doc : https://fastapi.tiangolo.com/tutorial/path-params/#predefined-values
I've just added a dependancy that uses the parameter.
But once done, the type checking no longer worked for the

model_nameparameter.In the doc, the field was no longer displayed as a select input but a standard text input.
I tried a few things to figure out and finally found that adding the type hint in the dependancy function solved the problem, ensuring validation and displaying a select field in the doc.

Is there an explanation to this ? Does the dependancy injection override the type checking by "catching" the parameter directly ?
I couldn't find any technical detail about this behaviour and I would like to be sure to understand it so that I'll be sure not misusing it.
Thank you
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.70.0
Python Version
3.9.5
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions