-
Why doesn´t FastAPI use python hints for returning types as well? This code is more intuitive @app.post("/items/")
async def create_item(item: Item) -> Item:
return item than this @app.post("/items/", response_model=Item)
async def create_item(item: Item):
return item |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Please do a search here first. Possible duplicate of #875. |
Beta Was this translation helpful? Give feedback.
-
And here as well: #620. I think many people are asking about it because it makes lots of sense. I actually see as the most common scenario to return the model itself as is, rather than a special "serialization model" with different fields. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help here @phy25 🍰 🙇♂️ Thanks @aklauza for coming back to close the issue 👍 |
Beta Was this translation helpful? Give feedback.
-
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs. |
Beta Was this translation helpful? Give feedback.
Please do a search here first. Possible duplicate of #875.