-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a dict of fields for arguments #180
Comments
We never tried to support that. I wouldn't mind adding this feature if it is not too hard to support. |
+1 Also, currently if you want to define specific |
@technolingo do you mind being more explicit (with an example)? Can't you pass a single schema with each field providing its example and description? class QueryArgsSchema(ma.Schema):
arg1 = ma.fields.String(metadata={"description": "First arg", "example": "Example value})
... |
+1 for this feature. |
I've been trying to take over #423. The issue with I see no simple way to infer a better name. There is no point adding a @blp.arguments(ma.Schema.from_dict({'name': ma.fields.Str()}, name="MeaningfulSchemaName")) or even create a schema the normal way. We could use a unique name generator, for instance using a global counter and use it when we build the schemas from dict. I don't really like the sound of it but I suppose users using |
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
The text was updated successfully, but these errors were encountered: