-
-
Notifications
You must be signed in to change notification settings - Fork 164
RFC: Use annotations for parsing arguments #353
Open
Labels
Description
Add a decorator that will parse request arguments from the view function's type annotations.
I've built a working proof of concept of this idea in webargs-starlette.
@app.route("/") @use_annotations(locations=("query",)) async def index(request, name: str = "World"): return JSONResponse({"Hello": name})
A marshmallow Schema is generated from the annotations using Schema.TYPE_MAPPING to construct fields.
The code for use_annotations mostly isn't tied to Starlette and could be adapted for AsyncParser (and core.Parser when we drop Python 2 support).
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.