🐛 Fetch the documentation URL dynamically
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 │
│ │
╰─────────────────────────────────────────────────────╯
Do you think this is a good approach @tiangolo ? 🙏🏻
😉 @pedroimpulcetto
@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
I ran across the same bug today and I can confirm that the provided patch resolves the issue.