File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ def setup_swagger(app: web.Application,
4646 contact : str = "" ,
4747 swagger_home_decor : FunctionType = None ,
4848 swagger_def_decor : FunctionType = None ,
49- swagger_info : dict = None ):
49+ swagger_info : dict = None ,
50+ swagger_template_path : str = None ):
5051 _swagger_url = ("/{}" .format (swagger_url )
5152 if not swagger_url .startswith ("/" )
5253 else swagger_url )
@@ -60,7 +61,8 @@ def setup_swagger(app: web.Application,
6061 else :
6162 swagger_info = generate_doc_from_each_end_point (
6263 app , api_base_url = api_base_url , description = description ,
63- api_version = api_version , title = title , contact = contact
64+ api_version = api_version , title = title , contact = contact ,
65+ template_path = swagger_template_path
6466 )
6567 else :
6668 swagger_info = json .dumps (swagger_info )
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ def generate_doc_from_each_end_point(
6666 description : str = "Swagger API definition" ,
6767 api_version : str = "1.0.0" ,
6868 title : str = "Swagger API" ,
69- contact : str = "" ):
69+ contact : str = "" ,
70+ template_path : str = None ):
7071 # Clean description
7172 _start_desc = 0
7273 for i , word in enumerate (description ):
@@ -76,7 +77,10 @@ def generate_doc_from_each_end_point(
7677 cleaned_description = " " .join (description [_start_desc :].splitlines ())
7778
7879 # Load base Swagger template
79- with open (join (SWAGGER_TEMPLATE , "swagger.yaml" ), "r" ) as f :
80+ if template_path is None :
81+ template_path = join (SWAGGER_TEMPLATE , "swagger.yaml" )
82+
83+ with open (template_path , "r" ) as f :
8084 swagger_base = (
8185 Template (f .read ()).render (
8286 description = cleaned_description ,
You can’t perform that action at this time.
0 commit comments