mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-23 02:15:26 -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:
1 parent
3651b8a30f
commit
a071ddf3cd
7 files changed
+153
-3
No files matched your search
@@ -317,12 +317,13 @@ def get_openapi(
|
||||
openapi_version: str = "3.0.2",
|
||||
description: str = None,
|
||||
routes: Sequence[BaseRoute],
|
||||
openapi_prefix: str = ""
|
||||
openapi_prefix: str = "",
|
||||
tags: Optional[List[Dict[str, Any]]] = None
|
||||
) -> Dict:
|
||||
info = {"title": title, "version": version}
|
||||
if description:
|
||||
info["description"] = description
|
||||
output = {"openapi": openapi_version, "info": info}
|
||||
output: Dict[str, Any] = {"openapi": openapi_version, "info": info}
|
||||
components: Dict[str, Dict] = {}
|
||||
paths: Dict[str, Dict] = {}
|
||||
flat_models = get_flat_models_from_routes(routes)
|
||||
@@ -352,4 +353,6 @@ def get_openapi(
|
||||
if components:
|
||||
output["components"] = components
|
||||
output["paths"] = paths
|
||||
if tags:
|
||||
output["tags"] = tags
|
||||
return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True)
|
||||
Reference in new issue
Block a user