FastAPI auto-generates an OpenAPI spec at /docs and /openapi.json, but the static file mount at / catches all routes, making the Swagger UI inaccessible.
This makes the API harder to discover for integrators. The API surface is small and clean, so exposing /docs would make it self-documenting with zero additional code.
Options:
- Mount static files on a subpath (e.g.,
/ui). This would be a breaking change for existing users.
- Register the static mount with lower priority so explicit FastAPI routes take precedence.
- Add a specific route exclusion for
/docs and /openapi.json.
Option 2 seems least disruptive.
FastAPI auto-generates an OpenAPI spec at
/docsand/openapi.json, but the static file mount at/catches all routes, making the Swagger UI inaccessible.This makes the API harder to discover for integrators. The API surface is small and clean, so exposing
/docswould make it self-documenting with zero additional code.Options:
/ui). This would be a breaking change for existing users./docsand/openapi.json.Option 2 seems least disruptive.