5
5
import pluggy
6
6
from fastapi import FastAPI
7
7
from pluggy import PluginManager
8
+ from rich .console import Console
9
+ from rich .table import Table
8
10
from starlette .routing import Mount
9
11
10
12
from fps import hooks
@@ -271,6 +273,28 @@ 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
+ openapi = app .openapi ()
283
+ for k , v in openapi ["paths" ].items ():
284
+ path = k
285
+ methods = ", " .join ([method .upper () for method in v .keys ()])
286
+ plugin = ", " .join ({tag for i in v .values () for tag in i ["tags" ]})
287
+ table .add_row (path , methods , plugin )
288
+
289
+ console = Console ()
290
+ with console .capture () as capture :
291
+ console .print ()
292
+ console .print (table )
293
+
294
+ str_output = capture .get ()
295
+ logger .info (str_output )
296
+
297
+
274
298
def create_app ():
275
299
276
300
logging .getLogger ("fps" )
@@ -286,4 +310,6 @@ def create_app():
286
310
287
311
Config .check_not_used_sections ()
288
312
313
+ show_endpoints (app )
314
+
289
315
return app
0 commit comments