Closed spinenkoia closed 2 years ago
This is because aiohttp creates a View for each request, and Flask when the application is initialized
I wasn't able to reproduce this.
I took the methodresolver example as you suggested, replaced FlaskApp
with AioHttpApp
and it started and accepted requests from httpie
.
@dtkav Good day, I'm sorry, here is the repository with the error reproduced https://github.com/spinenkoia/connexion_aiohttp
Thanks for the more complete example.
You don't need to inherit aiohttp.web.View
.
The following works for me:
from connexion import NoContent
class PetsView(object):
method_decorators = []
pets = {}
async def search(self):
return NoContent, 204
Thanks for the more complete example. You don't need to inherit
aiohttp.web.View
.The following works for me:
from connexion import NoContent class PetsView(object): method_decorators = [] pets = {} async def search(self): return NoContent, 204
This way you will just get a class with the get method. Here is the recommended method https://docs.aiohttp.org/en/stable/web_quickstart.html#class-based-views. There we lose self.request for example. And since aiohttp initializes this class not once but at each request and it turns out that connexion/resolver.py initializes it early
@dtkav ?
@jmcs please take a look
Outdated since #1491
Description
Tried using aiohttp.web.View with MethodViewResolver, as in the example, but there is Flask (https://github.com/zalando/connexion/tree/master/examples/openapi3/methodresolver). Maybe I'm doing something wrong ?
Expected behaviour
The app started
Actual behaviour
Getting an error
Steps to reproduce
Take an example https://github.com/zalando/connexion/tree/master/examples/openapi3/methodresolver, replace the Flask with AioHTTP
Additional info:
Output of the commands:
python --version
Python 3.7.4pip show connexion | grep "^Version\:"
Version: 2.5.1