From c1b6044cde3345c63b6efeb85c8827caae1251d7 Mon Sep 17 00:00:00 2001 From: Francisco Altoe Date: Thu, 27 Apr 2023 17:24:20 -0300 Subject: [PATCH 1/2] fixes to accommodate for before_app_first_request deprecation --- .../{{cookiecutter.app_name}}/api/views.py | 1 - .../{{cookiecutter.app_name}}/app.py | 5 ++++- .../{{cookiecutter.app_name}}/auth/views.py | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/api/views.py b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/api/views.py index 818d531..703fbd9 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/api/views.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/api/views.py @@ -14,7 +14,6 @@ api.add_resource(UserList, "/users", endpoint="users") -@blueprint.before_app_first_request def register_views(): apispec.spec.components.schema("UserSchema", schema=UserSchema) apispec.spec.path(view=UserResource, app=current_app) diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/app.py b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/app.py index 8b79e47..f84aeb0 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/app.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/app.py @@ -20,8 +20,8 @@ def create_app(testing=False): configure_extensions(app) configure_cli(app) - configure_apispec(app) register_blueprints(app) + configure_apispec(app) {%- if cookiecutter.use_celery == "yes" %} init_celery(app) {%- endif %} @@ -58,6 +58,9 @@ def configure_apispec(app): } }, ) + with app.app_context(): + api.views.register_views() + auth.views.register_views() def register_blueprints(app): diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/auth/views.py b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/auth/views.py index 1927c40..3efa12d 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/auth/views.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.app_name}}/auth/views.py @@ -185,7 +185,6 @@ def check_if_token_revoked(jwt_headers, jwt_payload): return is_token_revoked(jwt_payload) -@blueprint.before_app_first_request def register_views(): apispec.spec.path(view=login, app=app) apispec.spec.path(view=refresh, app=app) From 4c0590c174fc0e7b9f2e49883106ca41f8d64ca3 Mon Sep 17 00:00:00 2001 From: Francisco Altoe Date: Thu, 27 Apr 2023 17:35:03 -0300 Subject: [PATCH 2/2] remove python versions not supported by modern flask --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index 61f24b7..f1bf3b4 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,7 +1,7 @@ { "project_name": "restful_api", "app_name": "myapi", - "python_version": ["3.8", "3.7", "3.6"], + "python_version": ["3.11", "3.10", "3.9", "3.8"], "tox_python_env": "py{{ cookiecutter.python_version|replace('.','') }}", "use_celery": ["no", "yes"], "admin_user_username": "admin",