Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs URL is served even when set to None #70

Open
jshields opened this issue Jul 15, 2022 · 2 comments
Open

Docs URL is served even when set to None #70

jshields opened this issue Jul 15, 2022 · 2 comments

Comments

@jshields
Copy link

jshields commented Jul 15, 2022

Describe the bug
Even with docs_url set to None, the docs are still served.
Per the FastAPI documentation, the app should no longer serve docs with this option set.

You can disable it by setting docs_url=None.
https://fastapi.tiangolo.com/tutorial/metadata/#docs-urls

def docs_url_kwargs() -> dict:
    return  {
        "openapi_url": None,
        "docs_url": None,
        "redoc_url": None,
    }

application = FastAPI(
    title='Example FastApi',
    description='Nice',
    **docs_url_kwargs(),
)
application = VersionedFastAPI(
    application,
    version_format="{major}",
    prefix_format="/v{major}/api/",
    description='version',
    enable_latest=True,
    **docs_url_kwargs(),
)

To Reproduce
Set docs_url=None when instantiating the FastAPI app and VersionedFastAPI but still see the docs served at /docs.

Expected behavior
Expecting docs to no longer be served (for production use case).

Additional details
Issue may be here:

@parent_app.get(
f"{prefix}/openapi.json", name=semver, tags=["Versions"]
)
@parent_app.get(f"{prefix}/docs", name=semver, tags=["Documentations"])
def noop() -> None:
...

@josemarcosrf
Copy link

That same bit of code seems to be the responsible for always making the documentation avaialable at /docs even when provided a different url via the docs_url parameter.

This:

@parent_app.get(f"{prefix}/docs", name=semver, tags=["Documentations"])

Should probably check the docs_url of the FastAPI instance or take it from the kwargs of the VersionedFastAPI

@D1ver
Copy link

D1ver commented May 28, 2024

I also have same problem - docs enabled, but:
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants