✨ 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:
Thomas MaschlerandSebastián Ramírez authored and GitHub committed 2020-06-13 13:58:06 +02:00
1 parent 3651b8a30f
commit a071ddf3cd
7 files changed
+153 -3

No files matched your search

+5 -2
View File
@@ -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)