Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 30cf6eb

Browse files
committed
Merge branch 'hotfix-0.11.2' into develop
2 parents 3501aeb + 4674ffa commit 30cf6eb

File tree

9 files changed

+44
-32
lines changed

9 files changed

+44
-32
lines changed

docs/data_layer.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Example:
2929
'model': Person}
3030
3131
You can also plug additional methods to your data layer in the resource manager. There is 2 kind of additional methods:
32+
3233
* query: the "query" additional method takes view_kwargs as parameter and return an alternative query to retrieve the collection of objects in the get method of the ResourceList manager.
34+
3335
* pre / post process methods: all CRUD and relationship(s) operations have a pre / post process methods. Thanks to it you can make additional work before and after each operations of the data layer. Parameters of each pre / post process methods are available in the `flask_rest_jsonapi.data_layers.base.Base <https://github.com/miLibris/flask-rest-jsonapi/blob/master/flask_rest_jsonapi/data_layers/base.py>`_ base class.
3436

3537
Example:
@@ -109,7 +111,7 @@ Usage example:
109111
110112
from flask_rest_jsonapi import ResourceList
111113
from your_project.schemas import PersonSchema
112-
from your_project_data_layers import MyCustomDataLayer
114+
from your_project.data_layers import MyCustomDataLayer
113115
114116
class PersonList(ResourceList):
115117
schema = PersonSchema

docs/errors.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ The previous example displays error located in data provided instead of this nex
5555

5656
Flask-REST-JSONAPI provides two kind of helpers to achieve error displaying:
5757

58-
| * **the errors module**: you can import jsonapi_errors from the errors module to create the structure of a list of errors according to JSONAPI 1.0 specification
58+
| * **the errors module**: you can import jsonapi_errors from the `errors module <https://github.com/miLibris/flask-rest-jsonapi/blob/master/flask_rest_jsonapi/errors.py>`_ to create the structure of a list of errors according to JSONAPI 1.0 specification
5959
|
60-
| * **the exceptions module**: you can import lot of exceptions from this module that helps you to raise exceptions that will be well formatted according to JSONAPI 1.0 specification
60+
| * **the exceptions module**: you can import lot of exceptions from this `module <https://github.com/miLibris/flask-rest-jsonapi/blob/master/flask_rest_jsonapi/exceptions.py>`_ that helps you to raise exceptions that will be well formatted according to JSONAPI 1.0 specification
6161
6262
When you create custom code for your api I recommand to use exceptions from exceptions module of Flask-REST-JSONAPI to raise errors because JsonApiException based exceptions are catched and rendered according to JSONAPI 1.0 specification.
6363

docs/filtering.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ You can also use boolean combinaison of operations:
106106
] HTTP/1.1
107107
Accept: application/vnd.api+json
108108

109-
Availables operators depend on field type
110-
111109
Common available operators:
112110

113111
* any: used to filter on to many relationships

docs/include_related_objects.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ This features will add an additional key in result named "included"
1111

1212
Example:
1313

14-
.. sourcecode:: http
15-
1614
Request:
1715

1816
GET /persons/1?include=computers HTTP/1.1
@@ -81,8 +79,6 @@ You can even follow relationships with include
8179

8280
Example:
8381

84-
.. sourcecode:: http
85-
8682
Request:
8783

8884
GET /persons/1?include=computers.owner HTTP/1.1

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Main concepts
1212
:width: 600px
1313
:alt: Architecture
1414

15-
| * `JSON API 1.0 specification <http://jsonapi.org/>`_: it is a very popular specification about client server interactions for REST JSON API. It helps you to work in team because it is a very precise and sharable. Thanks to this specification your server will offer lot of features for clients like a strong structure of request and response, filtering, pagination, sparse fieldsets, including related resources, great error formatting etc.
15+
| * `JSON API 1.0 specification <http://jsonapi.org/>`_: it is a very popular specification about client server interactions for REST JSON API. It helps you to work in team because it is very precise and sharable. Thanks to this specification your api offers lot of features like a strong structure of request and response, filtering, pagination, sparse fieldsets, including related objects, great error formatting etc.
1616
|
1717
| * **Logical data abstration**: you usually need to expose resources to clients that don't fit your data table architecture. For example sometimes you don't want to expose all attributes of a table, compute additional attributes or create a resource that use data from multiple data storage. Flask-REST-JSONAPI helps you to create a logical abstraction of your data with `Marshmallow <https://marshmallow.readthedocs.io/en/latest/>`_ / `marshmallow-jsonapi <https://marshmallow-jsonapi.readthedocs.io/>`_ so you can expose your data through a very flexible way.
1818
|

docs/resource_manager.rst

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Resource Manager
77

88
Resource manager is the link between your logical data abstraction, your data layer and optionally other softwares. It is the place where logic management of your resource is located.
99

10-
Flask-REST-JSONAPI provides 3 kind of resource manager with default methods implementation according to JSONAPI 1.0 specification:
10+
Flask-REST-JSONAPI provides 3 kinds of resource manager with default methods implementation according to JSONAPI 1.0 specification:
1111

1212
| * **ResourceList**: provides get and post methods to retrieve a collection of objects or create one.
1313
|
@@ -32,6 +32,7 @@ Example:
3232
from flask_rest_jsonapi import ResourceList
3333
from your_project.schemas import PersonSchema
3434
from your_project.models import Person
35+
from your_project.extensions import db
3536
3637
class PersonList(ResourceList):
3738
schema = PersonSchema
@@ -48,28 +49,28 @@ All resource mangers are inherited from flask.views.MethodView so you can provid
4849

4950
You can plug additional decorators to each methods with this optional attributes:
5051

51-
:get_decorators: a list a decorators plugged to the get method of the resource manager
52-
:post_decorators: a list a decorators plugged to the post method of the resource manager
53-
:patch_decorators: a list a decorators plugged to the patch method of the resource manager
54-
:delete_decorators: a list a decorators plugged to the delete method of the resource manager
52+
:get_decorators: a list a decorators plugged to the get method
53+
:post_decorators: a list a decorators plugged to the post method
54+
:patch_decorators: a list a decorators plugged to the patch method
55+
:delete_decorators: a list a decorators plugged to the delete method
5556

5657
You can also provides default schema kwargs to each resource manager methods with this optional attributes:
5758

58-
:get_schema_kwargs: a dict of default schema instance kwargs in get method
59-
:post_schema_kwargs: a dict of default schema instance kwargs in post method
60-
:patch_schema_kwargs: a dict of default schema instance kwargs in patch method
61-
:delete_schema_kwargs: a dict of default schema instance kwargs in delete method
59+
:get_schema_kwargs: a dict of default schema kwargs in get method
60+
:post_schema_kwargs: a dict of default schema kwargs in post method
61+
:patch_schema_kwargs: a dict of default schema kwargs in patch method
62+
:delete_schema_kwargs: a dict of default schema kwargs in delete method
6263

6364
Each method of a resource manager got a pre and post process methods that take view args and kwargs as parameter for the pre process methods and the result of the method as parameter for the post process method. Thanks to this you can make custom work before and after the method process. Availables rewritable methods are:
6465

65-
:before_get(*args, **kwargs): pre process method of the get method
66-
:after_get(result): post process method of the get method
67-
:before_post(*args, **kwargs): pre process method of the post method
68-
:after_post(result): post process method of the post method
69-
:before_patch(*args, **kwargs): pre process method of the patch method
70-
:after_patch(result): post process method of the patch method
71-
:before_delete(*args, **kwargs): pre process method of the delete method
72-
:after_delete(result): post process method of the delete method
66+
:before_get: pre process method of the get method
67+
:after_get: post process method of the get method
68+
:before_post: pre process method of the post method
69+
:after_post: post process method of the post method
70+
:before_patch: pre process method of the patch method
71+
:after_patch: post process method of the patch method
72+
:before_delete: pre process method of the delete method
73+
:after_delete: post process method of the delete method
7374

7475
Example:
7576

@@ -80,6 +81,7 @@ Example:
8081
from your_project.models import Person
8182
from your_project.security import login_required
8283
from your_project.decorators import dummy_decorator
84+
from your_project.extensions import db
8385
8486
class PersonList(ResourceDetail):
8587
schema = PersonSchema
@@ -88,9 +90,14 @@ Example:
8890
methods = ['GET', 'PATCH']
8991
decorators = (login_required, )
9092
get_decorators = [dummy_decorator]
93+
get_schema_kwargs = {'only': ('name', )}
9194
9295
def before_patch(*args, **kwargs):
93-
"""Make custom work here. View args and kwargs are provided as parameter
96+
"""Make custom work here. View args and kwargs are provided as parameter
97+
"""
98+
99+
def after_patch(result):
100+
"""Make custom work here. Add something to the result of the view.
94101
"""
95102
96103
ResourceList
@@ -105,6 +112,9 @@ Example:
105112
.. code-block:: python
106113
107114
from flask_rest_jsonapi import ResourceList
115+
from your_project.schemas import PersonSchema
116+
from your_project.models import Person
117+
from your_project.extensions import db
108118
109119
class PersonList(ResourceList):
110120
schema = PersonSchema
@@ -123,6 +133,9 @@ Example:
123133
.. code-block:: python
124134
125135
from flask_rest_jsonapi import ResourceDetail
136+
from your_project.schemas import PersonSchema
137+
from your_project.models import Person
138+
from your_project.extensions import db
126139
127140
class PersonDetail(ResourceDetail):
128141
schema = PersonSchema
@@ -131,7 +144,7 @@ Example:
131144
132145
This minimal ResourceDetail configuration provides GET, PATCH and DELETE interface to retrieve details of objects, update an objects and delete an object with all powerful features like sparse fieldsets and including related objects.
133146

134-
If your schema has relationship(s) field(s) you can update an object and also link(s) to his related object(s) in the same time. If you want to see example go to :ref:`quickstart`.
147+
If your schema has relationship(s) field(s) you can update an object and also update his link(s) to related object(s) in the same time. If you want to see example go to :ref:`quickstart`.
135148

136149
ResourceRelationship
137150
--------------------
@@ -141,6 +154,9 @@ Example:
141154
.. code-block:: python
142155
143156
from flask_rest_jsonapi import ResourceRelationship
157+
from your_project.schemas import PersonSchema
158+
from your_project.models import Person
159+
from your_project.extensions import db
144160
145161
class PersonRelationship(ResourceRelationship):
146162
schema = PersonSchema

docs/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Routing
55

66
.. currentmodule:: flask_rest_jsonapi
77

8-
The routing system is very simple and fits this pattern:
8+
The routing system is very simple and fits this pattern ::
99

1010
api.route(<Resource manager>, <endpoint name>, <url_1>, <url_2>, ...)
1111

docs/sparse_fieldsets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ Example:
4646

4747
.. warning::
4848

49-
If you want to use both "fields" and "include" don't forget to specify the name of the relation in fields; if you don't the include wont work.
49+
If you want to use both "fields" and "include" don't forget to specify the name of the relationship in fields; if you don't the include wont work.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33

4-
__version__ = '0.11.1'
4+
__version__ = '0.11.2'
55

66

77
setup(

0 commit comments

Comments
 (0)