mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-04 23:23:38 -04:00
✨ Add support for tag metadata in OpenAPI (#1348)
* Allow to add OpenAPI tag descriptions * fix type hint * fix type hint 2 * refactor test to assure 100% coverage * 📝 Update tags metadata example * 📝 Update docs for tags metadata * ✅ Move tags metadata test to tutorial subdir * 🎨 Update format in applications * 🍱 Update docs UI image based on new example * 🎨 Apply formatting after solving conflicts Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
28
docs_src/metadata/tutorial004.py
Normal file
28
docs_src/metadata/tutorial004.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
tags_metadata = [
|
||||
{
|
||||
"name": "users",
|
||||
"description": "Operations with users. The **login** logic is also here.",
|
||||
},
|
||||
{
|
||||
"name": "items",
|
||||
"description": "Manage items. So _fancy_ they have their own docs.",
|
||||
"externalDocs": {
|
||||
"description": "Items external docs",
|
||||
"url": "https://fastapi.tiangolo.com/",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
app = FastAPI(openapi_tags=tags_metadata)
|
||||
|
||||
|
||||
@app.get("/users/", tags=["users"])
|
||||
async def get_users():
|
||||
return [{"name": "Harry"}, {"name": "Ron"}]
|
||||
|
||||
|
||||
@app.get("/items/", tags=["items"])
|
||||
async def get_items():
|
||||
return [{"name": "wand"}, {"name": "flying broom"}]
|
||||
Reference in New Issue
Block a user