Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📝 Update code examples in docs for body, replace namecreate_item withupdate_item when appropriate#5913

Merged
tiangolo merged 2 commits intofastapi:masterfrom
OttoAndrey:master
Jan 9, 2024
Merged

📝 Update code examples in docs for body, replace namecreate_item withupdate_item when appropriate#5913
tiangolo merged 2 commits intofastapi:masterfrom
OttoAndrey:master

Conversation

@OttoAndrey
Copy link
Contributor

@OttoAndreyOttoAndrey commentedJan 22, 2023
edited
Loading

Hi! I did some improvements for code exmples;

  1. Renamed function because it isput endpoint and logicaly it should beupdate notcreate;
  2. Removed redundantif statement becauseq param in those examples are required. Or I can addNone to annotations;

@github-actions
Copy link
Contributor

📝 Docs preview for commitc9d3b22 at:https://63ccee9f0fb8da5c9c02fac2--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commitdc6946f at:https://63ccf0f8cf78ab6745a882e4--fastapi.netlify.app

Copy link

@r0b2g1tr0b2g1t left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good for me.

Copy link

@RyandaydevRyandaydev left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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?

qitpydev and hofrob reacted with thumbs up emoji
@OttoAndrey
Copy link
ContributorAuthor

OttoAndrey commentedJan 23, 2023
edited
Loading

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 thisq parameter in this articlehttps://fastapi.tiangolo.com/tutorial/query-params/#optional-parameters . And here it looks logical becauseq is optional and code example hasif condition for that parameter. For consisten I suggest addNone forq param inside annotations. After thisif statement make sense. And it will look like previous examples withq param:

@app.get("/items/{item_id}")asyncdefread_items(q:str|None,item_id:int=Path(title="The ID of the item to get")):results= {"item_id":item_id}ifq:results.update({"q":q})returnresults

Copy link

@RyandaydevRyandaydev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I understand the reasoning on this change. Also, the tests still pass.

@tiangolotiangolo changed the titleUpdate code examples in docs📝 Update code examples in docsMar 4, 2023
@tiangolotiangolo added the docsDocumentation about how to use FastAPI labelMar 4, 2023
@github-actions
Copy link
Contributor

📝 Docs preview for commit2bfa458 at:https://64697a4de93dbc10f72678bd--fastapi.netlify.app

@OttoAndrey
Copy link
ContributorAuthor

Ok. I removed controversial changes and left only renamed functions

@tiangolotiangolo changed the title📝 Update code examples in docs📝 Update code examples in docs for body, replace namecreate_item withupdate_item when appropriateJan 9, 2024
@tiangolo
Copy link
Member

Nice, makes sense, thank you@OttoAndrey! 🍰

And thanks everyone for the input! ☕

OttoAndrey reacted with heart emoji

@tiangolotiangoloenabled auto-merge (squash)January 9, 2024 14:24
@tiangolotiangolo merged commite9ffa20 intofastapi:masterJan 9, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@KludexKludexKludex approved these changes

+3 more reviewers

@mjpietersmjpietersmjpieters left review comments

@RyandaydevRyandaydevRyandaydev approved these changes

@r0b2g1tr0b2g1tr0b2g1t approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

docsDocumentation about how to use FastAPI

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@OttoAndrey@tiangolo@mjpieters@Ryandaydev@r0b2g1t@Kludex

Comments


[8]ページ先頭

©2009-2026 Movatter.jp