Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flask_rest_jsonapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import inspect
from functools import wraps

from flask import Flask
from flask_rest_jsonapi.resource import ResourceList


Expand All @@ -20,12 +21,19 @@ def __init__(self, app=None, blueprint=None, decorators=None):
:param blueprint: a flask blueprint
:param tuple decorators: a tuple of decorators plugged to each resource methods
"""

if app is None:
app = Flask(__name__)
Copy link
Contributor

@hellupline hellupline Nov 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this is a good idea:

If the user create a instance of the jsonapi, then configure it using self.init_app(app):
the user would have created a second Flask app,

instead, __init__ shoud try to call init_app if app is not None.
also, calling init_app on __init__ would solve the first issue, to set default PAGE_SIZE


self.app = app
self.blueprint = blueprint
self.resources = []
self.resource_registry = []
self.decorators = decorators or tuple()

self.app.config.setdefault('PAGE_SIZE', 30)


def init_app(self, app=None, blueprint=None):
"""Update flask application with our api

Expand Down