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

✨ Support Python internal description on Pydantic model's docstring#3032

Merged
tiangolo merged 3 commits intofastapi:masterfrom
Kludex:feat/comment-on-pydantic-models
Sep 2, 2022
Merged

✨ Support Python internal description on Pydantic model's docstring#3032
tiangolo merged 3 commits intofastapi:masterfrom
Kludex:feat/comment-on-pydantic-models

Conversation

@Kludex
Copy link
Member

@KludexKludex commentedApr 1, 2021
edited
Loading

Problem

Currently, on FastAPI endpoint functions we can document for OpenAPI description/Swagger and for internal Python purposes:

fromfastapiimportFastAPIfrompydanticimportBaseModelapp=FastAPI()@app.get("/")defuseful():"""My description.\f    Internal documentation.    """    ...

On Swagger we'll have:
image

When documenting models, it doesn't have the same behavior:

fromenumimportEnumfromfastapiimportFastAPIclassBanana(str,Enum):"""My description.\f    Internal documentation.    """HAHA="haha"HOHO="hoho"app=FastAPI()@app.get("/")defuseful(banana:Banana):    ...

On Swagger, we'll have:
image

Solution

The proposedtwo lines of code on this PR, makes it possible to have the same behavior as the endpoint description:
image

It follows the same idea as:https://github.com/tiangolo/fastapi/blob/10397ddc30ef9bb26e9247f04fe20ce3045081c4/fastapi/routing.py#L350

Related issues

Questions & Alternatives

killswitch-GUI and hmoravec reacted with hooray emoji
@Kludex
Copy link
MemberAuthor

Kludex commentedApr 1, 2021
edited
Loading

Do you guys have an opinion on this?@PrettyWood@samuelcolvin

@github-actions
Copy link
Contributor

📝 Docs preview for commit00da79c at:https://606608e5d9c9b620c64fe21f--fastapi.netlify.app

@codecov
Copy link

codecovbot commentedApr 1, 2021
edited
Loading

Codecov Report

Merging#3032 (00becde) intomaster (b1d0f1e) willnot change coverage.
The diff coverage is100.00%.

@@            Coverage Diff            @@##            master     #3032   +/-   ##=========================================  Coverage   100.00%   100.00%           =========================================  Files          538       538             Lines        13870     13872    +2     =========================================+ Hits         13870     13872    +2
Impacted FilesCoverage Δ
fastapi/utils.py100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell ushow you rate us. Have a feature suggestion?Share it here.

@github-actions
Copy link
Contributor

📝 Docs preview for commit1c93179 at:https://60660aa9f6c5301f7f6c8b97--fastapi.netlify.app

@KludexKludex changed the title✨ Support Python internal description on Pydantic model's docstrings✨ Support Python internal description on Pydantic model's docstringApr 1, 2021
@killswitch-GUI
Copy link

Just bumping.

@killswitch-GUI
Copy link

@Kludex Think this one will make it in?

@Kludex
Copy link
MemberAuthor

I don't know. 😗

@github-actions
Copy link
Contributor

📝 Docs preview for commit00becde at:https://6311f9a78e0d811162b5915a--fastapi.netlify.app

@tiangolotiangolo changed the title✨ Support Python internal description on Pydantic model's docstring✨ Support Python internal description on Pydantic model's docstringSep 2, 2022
@tiangolo
Copy link
Member

Awesome, thanks@Kludex! 🍰

Kludex reacted with thumbs up emoji

@tiangolotiangolo merged commit30b3905 intofastapi:masterSep 2, 2022
@killswitch-GUI
Copy link

@tiangolo and@Kludex thanks for helping fix this! The team will be thankful!

@KludexKludex deleted the feat/comment-on-pydantic-models branchSeptember 2, 2022 12:45
@Kludex
Copy link
MemberAuthor

Kludex commentedSep 2, 2022
edited
Loading

@tiangolo Even if coverage didn't drop, Kludex forgot to add a test case for this, jfyk.

@tiangolo
Copy link
Member

Thanks! We can probably add a test in another PR.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@Kludex@killswitch-GUI@tiangolo

Comments


[8]ページ先頭

©2009-2026 Movatter.jp