aiohttp-swagger3
aiohttp-swagger3 copied to clipboard
Add prefix support for nested applications
As per aiohttp, nested applications are used to avoid monolithic files with all your endpoints.
I've been able to generate the swagger for every single sub_app, as well as the route app. The only issue is that the swagger has no idea of the prefix that is set on the aiohttp level
Example
main.py
app = web.Application()
s = SwaggerDocs(
app,
swagger_ui_settings=SwaggerUiSettings(path="/docs"),
info=SwaggerInfo(
title="Base API",
version="1.0.0",
),
)
s.add_routes([web.get("/admin-health", handle_health, allow_head=False)])
admin = admin_factory.create_app()
app.add_subapp('/admin/', admin)
admin_factory.py
#
app = web.Application()
s = SwaggerDocs(
app,
swagger_ui_settings=SwaggerUiSettings(path="/docs"),
info=SwaggerInfo(
title="Admin API",
version="1.0.0",
),
)
s.add_routes([web.get("/admin-health", handle_health, allow_head=False)])
return app
Description
So this works, the only issue is that the admin api swagger has no clue of the prefix. ie
App health is -> <url>/health
Admin health is -> <url>/admin/admin-health
The swagger documentation wrongfully points to <url>/admin-health
Should be a pretty easy fix on SwaggerUiSettings