Skip to content

Commit ed73520

Browse files
committed
add fields from schema.only to schema.dump_fields
1 parent 79e604d commit ed73520

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

flask_rest_jsonapi/schema.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helpers to deal with marshmallow schemas"""
2+
from collections import OrderedDict
23

34
from marshmallow import class_registry
45
from marshmallow.base import SchemaABC
@@ -58,6 +59,8 @@ def compute_schema(schema_cls, default_kwargs, qs, include):
5859
if schema.only is not None and 'id' not in schema.only:
5960
schema.only += ('id',)
6061

62+
schema.dump_fields = OrderedDict(**{name: val for name, val in schema.fields.items() if name in schema.only})
63+
6164
# manage compound documents
6265
if include:
6366
for include_path in include:

0 commit comments

Comments
 (0)