Skip to content

Docs URL is served even when set to None #70

@jshields

Description

@jshields

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:
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions