-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I wonder how to handle field-based authorization (i.e. a schema which is based on the request).
In webargs.core._get_schema the argmap is defined as
:param argmap: Either a `marshmallow.Schema`, `dict`
of argname -> `marshmallow.fields.Field` pairs, or a callable that returns
a `marshmallow.Schema` instance.
From my understanding aiohttp-apispec currently just supports passing a schema instance. For field-based authorization a callable that returns a schema instance would be required. Nevertheless, we still need to be able to create a schema from that callable without a request to be able to generate the swagger docs.
Maybe something like
def generate_schema(request):
if request is None:
return FullSchema()
elif request.user.is_admin():
return FullSchema()
else:
return NormalSchema()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels