Closed osma closed 6 months ago
I tried to upgrade to Connexion 3.0.0a6 in 79648cd88f5662c4cb749f8efb90505baba43208 but could not make the API routes work/registered: got only 404 responenses. It seemed the OpenAPI specfile (annif.yaml
) was not read at all, because no error was produced even if I used a nonexistent filename in its place.
CORS support could be added as Connexion middleware instead of using the separate flask-cors
dependency, see https://github.com/spec-first/connexion/discussions/1660#discussioncomment-5613349.
I tried to upgrade to Connexion 3.0.0a6 in 79648cd but could not make the API routes work/registered: got only 404 responenses. It seemed the OpenAPI specfile (
annif.yaml
) was not read at all, because no error was produced even if I used a nonexistent filename in its place.
Some progress:
I noticed that "Connexion 3.0 needs to be run using an ASGI server instead of a WSGI server. While any ASGI server should work, connexion comes with uvicorn as an extra", so for the API routes to work the command to start the application is uvicorn --factory annif:create_app
(using the setup in https://github.com/NatLibFi/Annif/blob/try-connexion3-alpha/annif/__init__.py).
However, using suggest method gives error Invalid Content-type (multipart/form-data), expected ['application/x-www-form-urlencoded']
Also, the annif run
CLI command uses FlaskGroup, which does not about uvicorn(?), so maybe the default run
command nees to be overridden to use uvicorn.
I did not manage to make Click work with Connexion 3 the right way.
Maybe having separate create_app()
and create_flask_app()
functions (the former creating app with Connexion and latter with only Flask) in annif/__init__.py
would help in this too. So PR #696 is better to be merged first.
Running pytest nowadays generates lots of warnings:
Many of these are Flask deprecation warnings triggered by connexion, e.g.:
It seems to me that these have been fixed (and more) in the Connexion
main
branch, but the fixes are not in version 2.14.2 that we are currently using. Instead, Connexion 3.0 is coming up soon, with the most recent release being 3.0.0a4 currently.I think we should try to upgrade to Connexion 3 because I don't think version 2 will have a long future. That should take care of most of the pytest warnings.