Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.7k
✨ Adddescription parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")#1757
Conversation
codecovbot commentedJul 21, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #1757 +/- ##========================================== Coverage 100.00% 100.00% ========================================== Files 390 401 +11 Lines 9747 10080 +333 ==========================================+ Hits 9747 10080 +333
Continue to review full report at Codecov.
|
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
📝 Docs preview for commit466ddff at:https://5f32a7229003b29d44a1ebab--fastapi.netlify.app |
description parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")📝 Docs preview for commitc55a195 at:https://610282e611c6c0ad2ef9978a--fastapi.netlify.app |
tiangolo commentedJul 29, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks@hylkepostma! ☕ And thanks @nimctl for the review. 🤓 I updated it to include the Thanks for your contribution! 🚀 🍰 This will be available later today in FastAPI version |
…. `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>
My suggestion is to add a description parameter to the
__init__methods ofAPIKeyQuery(SecurityBase):,APIKeyHeader(SecurityBase):andAPIKeyCookie(SecurityBase):and use it to initialize theAPIKeyobject. This allows for a description in thesecuritySchemesobjects of theopenapi.jsonand therefore in the Swagger and Redoc documentation.class SecurityBase(BaseModel):already has an attributedescription: Optional[str] = None.class APIKey(SecurityBase):inherits from SecurityBase.The classes
APIKeyQuery(SecurityBase):,APIKeyHeader(SecurityBase):andAPIKeyCookie(SecurityBase):initialize anAPIKeyobject in their__init__method. They initialize it with some kwargs and thenameparameter, but currently without a description parameter.Example: using

APIKeyQuery(name="X-Auth-Key", auto_error=False, description="My description")would look likt this in Redoc: