@@ -60,6 +60,7 @@ def __init__(self, deployments: list[Any], plugin_apis: list["PluginApi"]) -> No
6060 stream = plugin_api .stream ,
6161 direct_output = plugin_api .raw_response ,
6262 tags = plugin_api .tags ,
63+ description = plugin_api .description ,
6364 ** plugin_api .extend_kwargs ,
6465 )
6566
@@ -73,6 +74,7 @@ def register_route(
7374 stream : bool = False ,
7475 direct_output : bool = False ,
7576 tags : list [str ] | None = None ,
77+ description : str | None = None ,
7678 auth_keys : list [str ] | None = None ,
7779 include_in_schema : bool = True ,
7880 ** kwargs : Any ,
@@ -161,6 +163,7 @@ def _verify_api_key(request: Request, api_key: str | None = Depends(api_key_head
161163 response_class = StreamingResponse if stream else JSONResponse ,
162164 dependencies = dependencies ,
163165 include_in_schema = include_in_schema ,
166+ description = description ,
164167 ** kwargs ,
165168 )
166169 methods_str = "," .join (m .upper () for m in methods )
@@ -188,6 +191,9 @@ def add_api_route(
188191 endpoint : Callable [..., Any ],
189192 * ,
190193 methods : list [str ] | None = None ,
194+ tags : list [str ] | None = None ,
195+ description : str | None = None ,
196+ include_in_schema : bool = True ,
191197 ** kwargs : Any ,
192198 ) -> None :
193199 method_set : set [str ] = {m .upper () for m in methods } if methods else {"GET" }
@@ -201,4 +207,22 @@ def add_api_route(
201207 ):
202208 raise RuntimeError (f"Duplicate API route: { sorted (method_set )} { norm_path } " )
203209
204- app .add_api_route (path , endpoint , methods = list (method_set ), ** kwargs )
210+ app .add_api_route (
211+ path ,
212+ endpoint ,
213+ methods = list (method_set ), # type: ignore
214+ tags = tags , # type: ignore
215+ include_in_schema = include_in_schema ,
216+ ** kwargs ,
217+ )
218+
219+ if include_in_schema and tags :
220+ names = list ({tag ["name" ] for tag in app .state .tags_metadata_map })
221+ for tag in tags :
222+ if tag not in names :
223+ app .state .tags_metadata_map .append (
224+ {
225+ "name" : tag ,
226+ "description" : description ,
227+ },
228+ )
0 commit comments