Registry / web-framework / aiohttp-swagger

aiohttp-swagger

JSON →
library1.0.16pypypi✓ verified 85d ago

Swagger API Documentation builder for aiohttp server. Version 1.0.16 (last release 2020). No recent updates; likely in maintenance mode.

pip install aiohttp-swagger
INSTALL
IMPORT
SIG · AIOHTTP-SWAGGER
A
aiohttp-swagger
web-frameworkpythonv1.0.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setup_swagger
from aiohttp_swagger import setup_swagger
from aiohttp_swagger import swagger
Wrong symbol, older examples used 'swagger' but current uses setup_swagger
swagger
from aiohttp_swagger import swagger
Valid alternative import for the swagger decorator
swagger_path
from aiohttp_swagger import swagger_path
Commonly imported for YAML file path

Basic aiohttp app with Swagger UI enabled

from aiohttp import web from aiohttp_swagger import setup_swagger async def handler(request): return web.json_response({"hello": "world"}) app = web.Application() app.router.add_get('/hello', handler) setup_swagger(app, swagger_url="/api/v1/doc") web.run_app(app, host='0.0.0.0', port=8080)
Debug
Known issues
breakingaiohttp-swagger may not work with aiohttp >= 4.x due to API changes.
fix
Pin aiohttp<4 or use alternative like aiohttp-swagger3 or aiohttp-swagger-ui
affects: all
deprecatedProject has not been updated since 2020. Consider using more actively maintained alternatives.
fix
Switch to aiohttp-swagger3 or aiohttp-swagger-ui
affects: all
gotchasetup_swagger expects aiohttp.Application instance. Passing a sub-app may cause issues.
fix
Ensure you pass the main app object, not a nested app.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'setup_swagger' from 'aiohttp_swagger'
Installed version < 1.0.0 or wrong import path
fix
Upgrade to latest: pip install --upgrade aiohttp-swagger
TypeError: setup_swagger() got an unexpected keyword argument 'swagger_url'
Older version of library does not support swagger_url parameter
fix
Use 'url' instead: setup_swagger(app, url='/api/v1/doc')
AttributeError: module 'aiohttp_swagger' has no attribute 'swagger'
Misunderstanding the import; 'swagger' is a decorator, not a function
fix
Use: from aiohttp_swagger import swagger as swagger_decorator
Upgrade
Version history
1.0.16latest on PyPI · released Oct 22, 2021
Audit
Dependencies
aiohttprequiredRequires aiohttp server
Agent activity
35 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources
aiohttp-swagger — pip install aiohttp-swagger · libregistry