aiohttp-swagger3
raw JSON → 0.10.1 verified Fri May 01 auth: no python
OpenAPI 3.x validation and Swagger UI for aiohttp web apps. Automatically validates requests and responses, generates OpenAPI docs, and serves Swagger UI, Redoc, and RapiDoc. Current release 0.10.1 (released 2025-02-15). Active development with monthly or quarterly releases.
pip install aiohttp-swagger3 Common errors
error AttributeError: module 'aiohttp_swagger3' has no attribute 'SwaggerDocs' ↓
cause Using an outdated version or wrong import path.
fix
Ensure you have installed aiohttp-swagger3 (pip install aiohttp-swagger3) and use 'from aiohttp_swagger3 import SwaggerDocs'.
error aiohttp_swagger3.exceptions.RequestValidationError ↓
cause Request validation failed (e.g., missing required field, wrong type).
fix
Check your OpenAPI spec and request payload against the schema.
Warnings
breaking Python 3.8 dropped in v0.10.0; requires Python >=3.9. ↓
fix Upgrade Python to 3.9+.
breaking Python 3.7 dropped in v0.8.0. ↓
fix Upgrade Python to 3.8+ (or 3.9+ for >=0.10.0).
breaking aiohttp version support changes: v0.9.0 adds aiohttp 3.10.x; v0.8.0 adds 3.9.x and drops 3.6.x and 3.7.x. ↓
fix Pin aiohttp to supported version range.
gotcha aiohttp 3.6 and 3.7 are not supported after v0.8.0; use aiohttp >=3.8. ↓
fix Upgrade aiohttp to 3.8+.
Imports
- SwaggerDocs
from aiohttp_swagger3 import SwaggerDocs - swagger_doc wrong
from aiohttp_swagger3 import swagger_docscorrectfrom aiohttp_swagger3 import swagger_doc
Quickstart
from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs
app = web.Application()
swagger = SwaggerDocs(app, swagger_url="/api/doc", title="My API")
async def hello(request):
return web.json_response({"hello": "world"})
swagger.add_get("/hello", hello, summary="Hello endpoint")
web.run_app(app)