6
6
from fastapi import FastAPI
7
7
from pluggy import PluginManager
8
8
from starlette .routing import Mount
9
+ from rich .console import Console
10
+ from rich .table import Table
9
11
10
12
from fps import hooks
11
13
from fps .config import Config , FPSConfig , create_default_plugin_model
@@ -271,6 +273,29 @@ def _load_routers(app: FastAPI) -> None:
271
273
logger .info ("No plugin API router to load" )
272
274
273
275
276
+ def show_endpoints (app : FastAPI ):
277
+ table = Table (title = "API Summary" )
278
+ table .add_column ("Path" , justify = "left" , style = "cyan" , no_wrap = True )
279
+ table .add_column ("Methods" , justify = "right" , style = "green" )
280
+ table .add_column ("Plugin" , style = "magenta" )
281
+
282
+
283
+ openapi = app .openapi ()
284
+ for k , v in openapi ["paths" ].items ():
285
+ path = k
286
+ methods = ", " .join ([method .upper () for method in v .keys ()])
287
+ plugin = ", " .join ({tag for i in v .values () for tag in i ["tags" ]})
288
+ table .add_row (path , methods , plugin )
289
+
290
+ console = Console ()
291
+ with console .capture () as capture :
292
+ console .print ()
293
+ console .print (table )
294
+
295
+ str_output = capture .get ()
296
+ logger .info (str_output )
297
+
298
+
274
299
def create_app ():
275
300
276
301
logging .getLogger ("fps" )
@@ -286,4 +311,6 @@ def create_app():
286
311
287
312
Config .check_not_used_sections ()
288
313
314
+ show_endpoints (app )
315
+
289
316
return app
0 commit comments