📝 Update code examples in docs for body, replace name create_item with update_item when appropriate#5913
Conversation
|
📝 Docs preview for commit c9d3b22 at: https://63ccee9f0fb8da5c9c02fac2--fastapi.netlify.app |
|
📝 Docs preview for commit dc6946f at: https://63ccf0f8cf78ab6745a882e4--fastapi.netlify.app |
There was a problem hiding this comment.
Tests pass.
The changes listed as "1" are good changes.
I understand the suggestion for "2", however I suggest not making those changes because that code is repeated in multiple places throughout the tutorials. As I understand the tutorials, they build on each other somewhat, and they focus on specific items in each section. It seems to me that making these changes in a few places adds inconsistencies that the learner has to investigate as they change. It may be more useful to keep it consistent even if the example isn't optimal?
@Ryandaydev First time when learner see this @app.get("/items/{item_id}")
async def read_items(q: str | None, item_id: int = Path(title="The ID of the item to get")):
results = {"item_id": item_id}
if q:
results.update({"q": q})
return results |
Ryandaydev
left a comment
There was a problem hiding this comment.
I understand the reasoning on this change. Also, the tests still pass.
|
📝 Docs preview for commit 2bfa458 at: https://64697a4de93dbc10f72678bd--fastapi.netlify.app |
|
Ok. I removed controversial changes and left only renamed functions |
create_item with update_item when appropriate
|
Nice, makes sense, thank you @OttoAndrey! 🍰 And thanks everyone for the input! ☕ |
Hi! I did some improvements for code exmples;
putendpoint and logicaly it should beupdatenotcreate;Removed redundantifstatement becauseqparam in those examples are required. Or I can addNoneto annotations;