-
-
Notifications
You must be signed in to change notification settings - Fork 159
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).
bastula, khvn26, troyswanson, kokokuo, mbello and 1 more