✨ Add description parameter to all the security scheme classes, e.g. APIKeyQuery(name="key", description="A very cool API key")#1757
Conversation
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.
|
|
📝 Docs preview for commit 466ddff 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 commit c55a195 at: https://610282e611c6c0ad2ef9978a--fastapi.netlify.app |
|
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 <[email protected]> Co-authored-by: Sebastián Ramírez <[email protected]>
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: