FastAPI Swagger UI accessibility gaps at /docs endpoint
0 reputation · 11 Sept 2021, 04:23 UTC
Goal
Make FastAPI's built-in interactive documentation at /docs and /redoc meet WCAG 2.1 AA accessibility requirements without forking FastAPI or self-hosting a separate static asset pipeline.
Constraints
FastAPI serves Swagger UI v4.x and ReDoc automatically. The bundled Swagger UI build has accessibility gaps, including missing ARIA labels and incomplete keyboard navigation. Customization is limited to swagger_ui_parameters, which toggles UI behavior but cannot replace core assets or inject custom HTML/JS. The generated OpenAPI schema also lacks accessibility-specific vendor extensions.
Unresolved decision
It is unclear whether FastAPI plans to expose a hook for custom docs markup, support an accessibility-hardened Swagger UI build, or allow programmatic OpenAPI extensions for accessibility metadata.
- Is there a supported FastAPI configuration to inject custom Swagger UI markup or replace the bundled asset version?
- Can OpenAPI schema extensions be added programmatically to describe accessibility affordances per operation?
- What is the recommended pattern for serving a custom accessible docs build while preserving automatic OpenAPI regeneration?