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

✨ Adddescription parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")#1757

Merged
tiangolo merged 8 commits intofastapi:masterfrom
hylkepostma:master
Jul 29, 2021
Merged

✨ Adddescription parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")#1757
tiangolo merged 8 commits intofastapi:masterfrom
hylkepostma:master

Conversation

@hylkepostma
Copy link
Contributor

My suggestion is to add a description parameter to the__init__ methods ofAPIKeyQuery(SecurityBase):,APIKeyHeader(SecurityBase): andAPIKeyCookie(SecurityBase): and use it to initialize theAPIKey object. This allows for a description in thesecuritySchemes objects of theopenapi.json and therefore in the Swagger and Redoc documentation.

class SecurityBase(BaseModel): already has an attributedescription: Optional[str] = None.
class APIKey(SecurityBase): inherits from SecurityBase.

The classesAPIKeyQuery(SecurityBase):,APIKeyHeader(SecurityBase): andAPIKeyCookie(SecurityBase): initialize anAPIKey object in their__init__ method. They initialize it with some kwargs and thename parameter, but currently without a description parameter.

Example: usingAPIKeyQuery(name="X-Auth-Key", auto_error=False, description="My description") would look likt this in Redoc:
image w:400

@codecov
Copy link

codecovbot commentedJul 21, 2020
edited
Loading

Codecov Report

Merging#1757 (c55a195) intomaster (9121fcc) willnot change coverage.
The diff coverage is100.00%.

Impacted file tree graph

@@            Coverage Diff             @@##            master     #1757    +/-   ##==========================================  Coverage   100.00%   100.00%            ==========================================  Files          390       401    +11       Lines         9747     10080   +333     ==========================================+ Hits          9747     10080   +333
Impacted FilesCoverage Δ
fastapi/security/api_key.py100.00% <100.00%> (ø)
fastapi/security/http.py100.00% <100.00%> (ø)
fastapi/security/oauth2.py100.00% <100.00%> (ø)
fastapi/security/open_id_connect_url.py100.00% <100.00%> (ø)
tests/test_security_api_key_cookie_description.py100.00% <100.00%> (ø)
tests/test_security_api_key_header_description.py100.00% <100.00%> (ø)
tests/test_security_api_key_query_description.py100.00% <100.00%> (ø)
tests/test_security_http_base_description.py100.00% <100.00%> (ø)
...ests/test_security_http_basic_realm_description.py100.00% <100.00%> (ø)
tests/test_security_http_bearer_description.py100.00% <100.00%> (ø)
... and16 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update9121fcc...c55a195. Read thecomment docs.

@github-actions
Copy link
Contributor

📝 Docs preview for commit466ddff at:https://5f32a7229003b29d44a1ebab--fastapi.netlify.app

@tiangolotiangolo changed the titleAdd description parameter to all APIKey* classes✨ Adddescription parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")Jul 29, 2021
@github-actions
Copy link
Contributor

📝 Docs preview for commitc55a195 at:https://610282e611c6c0ad2ef9978a--fastapi.netlify.app

@tiangolo
Copy link
Member

tiangolo commentedJul 29, 2021
edited
Loading

Thanks@hylkepostma! ☕

And thanks @nimctl for the review. 🤓

I updated it to include thedescription in all the security scheme classes and added tests for them all.

Thanks for your contribution! 🚀 🍰

This will be available later today in FastAPI version0.68.0 🔖 🎉

hylkepostma reacted with hooray emoji

@tiangolotiangolo merged commit3b2e891 intofastapi:masterJul 29, 2021
solomein-sv pushed a commit to solomein-sv/fastapi that referenced this pull requestJul 30, 2021
…. `APIKeyQuery(name="key", description="A very cool API key")` (fastapi#1757)Co-authored-by: Hylke Postma <h.postma@docuwork.nl>Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@blkst8blkst8blkst8 left review comments

Reviewers whose approvals may not affect merge requirements

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

@hylkepostma@tiangolo@blkst8

Comments


[8]ページ先頭

©2009-2026 Movatter.jp