From 1bce6ad603ad194bdbd9ec94f924aec4dbf17282 Mon Sep 17 00:00:00 2001 From: Pratik Ghodke Date: Thu, 5 Jan 2023 12:12:23 +0530 Subject: [PATCH 1/2] FlaskAPIspec: 1 feature to provide args and kwargs externally commented due to the issue of injector and flask APIspec not working together --- flask_apispec/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flask_apispec/utils.py b/flask_apispec/utils.py index 686736a..9ff1052 100644 --- a/flask_apispec/utils.py +++ b/flask_apispec/utils.py @@ -6,8 +6,8 @@ def resolve_resource(resource, **kwargs): resource_class_args = kwargs.get('resource_class_args') or () resource_class_kwargs = kwargs.get('resource_class_kwargs') or {} - if isinstance(resource, type): - return resource(*resource_class_args, **resource_class_kwargs) + # if isinstance(resource, type): + # return resource(*resource_class_args, **resource_class_kwargs) return resource From 650a0ae1eea3897b039377f8bcd41f6d52d8e0e5 Mon Sep 17 00:00:00 2001 From: Pratik Ghodke Date: Thu, 5 Jan 2023 14:33:36 +0530 Subject: [PATCH 2/2] Moved static files to init --- flask_apispec/extension.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/flask_apispec/extension.py b/flask_apispec/extension.py index 5dd03d0..3153c72 100644 --- a/flask_apispec/extension.py +++ b/flask_apispec/extension.py @@ -38,13 +38,21 @@ def get_pet(pet_id): OPTIONS requests in the specification """ - def __init__(self, app=None, document_options=True): + def __init__(self, + static_folder='./static', + template_folder='./templates', + static_url_path='/flask-apispec/static', + app=None, + document_options=True): self._deferred = [] self.app = app self.view_converter = None self.resource_converter = None self.spec = None self.document_options = document_options + self.static_folder = static_folder + self.template_folder = template_folder + self.static_url_path = static_url_path if app: self.init_app(app) @@ -74,9 +82,9 @@ def add_swagger_routes(self): blueprint = flask.Blueprint( 'flask-apispec', __name__, - static_folder='./static', - template_folder='./templates', - static_url_path='/flask-apispec/static', + static_folder=self.static_folder, + template_folder=self.template_folder, + static_url_path=self.static_url_path, ) json_url = self.app.config.get('APISPEC_SWAGGER_URL', '/swagger/')