Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix support for nested applications #106

Open
RHeynsZa opened this issue Oct 18, 2022 · 0 comments
Open

Add prefix support for nested applications #106

RHeynsZa opened this issue Oct 18, 2022 · 0 comments

Comments

@RHeynsZa
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant