fastapi-cli icon indicating copy to clipboard operation
fastapi-cli copied to clipboard

🐛 Fetch the documentation URL dynamically

Open chipytux opened this issue 1 year ago • 8 comments

Pull Request Description

Title: Fetch docs_url dynamically from FastAPI app

Description:

This pull request introduces a change to the fastapi-cli library that fetches the docs_url value dynamically from the FastAPI application instead of using a hardcoded value.

Implementation Details:

The change involves modifying the _run function to fetch the docs_url value from the FastAPI application using the app.openapi_url attribute. This ensures that the library always uses the URL specified by the application itself.

Testing:

The updated function has been thoroughly tested to ensure it correctly retrieves the docs_url value from the FastAPI application and show the appropriate URL.

 ╭────────── FastAPI CLI - Development mode ───────────╮                        
 │                                                     │                        
 │  Serving at: http://127.0.0.1:9901                  │                        
 │                                                     │                        
 │  API docs: http://127.0.0.1:9901/any-other-path     │                        
 │                                                     │                        
 │  Running in development mode, for production use:   │                        
 │                                                     │                        
 │  fastapi run                                        │                        
 │                                                     │                        
 ╰─────────────────────────────────────────────────────╯   

chipytux avatar May 13 '24 18:05 chipytux

Do you think this is a good approach @tiangolo ? 🙏🏻

😉 @pedroimpulcetto

chipytux avatar May 22 '24 21:05 chipytux

@tiangolo I do not have permission to configure a label for the PR. https://github.com/fastapi/fastapi-cli/actions/runs/10408815023/job/28827030912?pr=24

chipytux avatar Aug 15 '24 18:08 chipytux

I ran across the same bug today and I can confirm that the provided patch resolves the issue.

tobb10001 avatar Jan 27 '25 17:01 tobb10001