You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This flow is terribly broken currently. It's partially affected by aio-libs/aiohttp#2656.
But also it becomes messy in terms of setup sequence.
For now I won't suggest a long-term solution (till upstream issue fixed), but here's what I had to hack to get this working:
"""The app configuration module."""importloggingfromaiohttp.webimportApplicationfromaiohttp_swaggerimportsetup_swaggerfrom .viewsimportAPIView_logger=logging.getLogger(__name__)
asyncdefbuild_application():
"""Create and pre-populate an aiohttp.web.Application instance."""app=Application()
_logger.info('App initialized.')
api_app=Application()
_logger.info('API App initialized.')
api_app.router.add_route('POST', r'/ping-cad/', APIView)
_logger.info('Routes configured.')
# Achtung! Keep add_subapp after routes declaration and# before swagger setup. Otherwise things will get fragile.# Affected by https://github.com/aio-libs/aiohttp/issues/2656app.add_subapp('/api/v1', api_app)
_logger.info('API App mounted within main App.')
# Accepts also `swagger_url='/api/v1/doc'`, defaults to '/api/doc':# we set api_base_url='/' because setting up within main App,# but referring API App, which after .add_subapp() has routes prepended# with /api/v1# We have to mount it before configuring swagger to make it recognise API.setup_swagger(app, api_base_url='/', swagger_url='/api/doc')
_logger.info('Swagger Web UI configured.')
returnapp
Note api_base_url reset to /, setup_swagger called with app, add_subapp() done before swagger setup, routes done before add_subapp()
Why I needed to setup it on the main app?
It's just that I've got a middleware processing error responses and converting them into JSON. And I didn't want that middleware to affect queries to swagger app.
The text was updated successfully, but these errors were encountered:
This flow is terribly broken currently. It's partially affected by aio-libs/aiohttp#2656.
But also it becomes messy in terms of setup sequence.
For now I won't suggest a long-term solution (till upstream issue fixed), but here's what I had to hack to get this working:
Note
api_base_url
reset to/
,setup_swagger
called withapp
,add_subapp()
done before swagger setup, routes done beforeadd_subapp()
Why I needed to setup it on the main app?
It's just that I've got a middleware processing error responses and converting them into JSON. And I didn't want that middleware to affect queries to swagger app.
The text was updated successfully, but these errors were encountered: