marshmallow-code / marshmallow-code/flask-smorest
Using a dict of fields for arguments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 717
- Forks
- 77
- Avg merge
- 7h 49m
- Merged PRs (30d)
- 3
Description
In the docs, I see there is a way to do: `@blp.arguments(PetSchema)`
Is there a way to simply do: `@blp.arguments({'name': ma.fields.Str()})` ?
I was trying to port some of my projects from flaks-apispec to flask-smorest and in flask-apispec I was doing: `@use_kwargs({'name': ma.fields.Str()})` a lot as that seemed generic and easy to define for my endpoints with simple query params.
I didn't see a similar thing in smorest, and was wondering if I have to define a schema every time ?
I don't like schemas too much because they become a bit verbose for 1 or 2 arguments ... and then in cases where I need borh a query-param and a body as arguments (POST with query params) I need to define 2 schemas - which seems to be confusing
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the blp.arguments entry point and the documentation describing PetSchema-based arguments, then compare the requested behavior with flask-apispec's use_kwargs pattern. Done means accepting a dictionary of fields for simple endpoint arguments, including cases combining query parameters and a body, with the behavior documented and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100