flask-rest-jsonapi
flask-rest-jsonapi copied to clipboard
Allow providing `get_schema_kwargs` as a function
trafficstars
Allows users to provide fields like get_schema_kwargs as functions instead of dictionaries. These functions have access to the view's args and kwargs.
For example:
class PersonDetail(ResourceDetail):
schema = person_schema
data_layer = {
'model': person_model,
'session': session,
'url_field': 'person_id'
}
def get_schema_kwargs(self, args, kwargs):
return dict(
exclude=['name']
)
You can still use the simpler method of providing a dictionary, too.
I've added two tests for these two use-cases.