File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -194,35 +194,25 @@ def _run(
194194 tag = "app" ,
195195 )
196196
197- docs_urls = get_docs_urls (import_data )
198-
199197 url = f"http://{ host } :{ port } "
200198
201199 use_root_path = root_path or get_root_path (import_data )
202200 if use_root_path :
203201 url += use_root_path
204202
205- docs_url = ""
206-
207- if docs_urls .openapi_url and (docs_urls .docs_url or docs_urls .redoc_url ):
208- if docs_urls .docs_url :
209- docs_url = (
210- f"[link={ url } { docs_urls .docs_url } ]{ url } { docs_urls .docs_url } [/]"
211- )
212- else :
213- docs_url = (
214- f"[link={ url } { docs_urls .redoc_url } ]{ url } { docs_urls .redoc_url } [/]"
215- )
216-
217203 toolkit .print_line ()
218204 toolkit .print (
219205 f"Server started at [link={ url } ]{ url } [/]" ,
220206 tag = "server" ,
221207 )
222208
223- if docs_url :
209+ docs_urls = get_docs_urls (import_data )
210+ docs_links = [
211+ f"[link={ url } { docs_url } ]{ url } { docs_url } [/]" for docs_url in docs_urls
212+ ]
213+ if docs_links :
224214 toolkit .print (
225- f"Documentation at { docs_url } " ,
215+ f"Documentation at { docs_links [ 0 ] } " ,
226216 tag = "server" ,
227217 )
228218
Original file line number Diff line number Diff line change @@ -159,14 +159,7 @@ def get_import_data_from_import_string(import_string: str) -> ImportData:
159159 )
160160
161161
162- @dataclass
163- class DocsURLs :
164- openapi_url : str | None
165- docs_url : str | None
166- redoc_url : str | None
167-
168-
169- def get_docs_urls (import_data : ImportData ) -> DocsURLs :
162+ def get_docs_urls (import_data : ImportData ) -> list [str ]:
170163 module = importlib .import_module (import_data .module_data .module_import_str )
171164 app_name = import_data .app_name
172165 app = getattr (module , app_name )
@@ -175,11 +168,13 @@ def get_docs_urls(import_data: ImportData) -> DocsURLs:
175168 assert FastAPI is not None
176169 assert isinstance (app , FastAPI )
177170
178- return DocsURLs (
179- openapi_url = app .openapi_url ,
180- docs_url = app .docs_url ,
181- redoc_url = app .redoc_url ,
182- )
171+ docs_urls : list [str ] = []
172+ if app .openapi_url and app .docs_url :
173+ docs_urls .append (app .docs_url )
174+ if app .openapi_url and app .redoc_url :
175+ docs_urls .append (app .redoc_url )
176+
177+ return docs_urls
183178
184179
185180def get_root_path (import_data : ImportData ) -> str :
You can’t perform that action at this time.
0 commit comments