Docs URL is served even when set to None
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: https://github.com/DeanWay/fastapi-versioning/blob/18d480f5bb067088f157f235a673cb4c65ec77d5/fastapi_versioning/versioning.py#L68-L73
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: https://github.com/DeanWay/fastapi-versioning/blob/18d480f5bb067088f157f235a673cb4c65ec77d5/fastapi_versioning/versioning.py#L71
Should probably check the docs_url of the FastAPI instance or take it from the kwargs of the VersionedFastAPI
I also have same problem - docs enabled, but:
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)