How to use the webargs.flaskparser.use_kwargs function in webargs

To help you get started, we’ve selected a few webargs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amicks / Speculator / api / resources / market.py View on Github external
    @use_kwargs({'id': fields.Integer(missing=None)})
    @validate_db(db)
    def delete(self, id):
        try:
            if id is None:
                DataModel.query.delete()
                db.session.commit()
            else:
                db.session.delete(DataModel.query.get_or_404(id))
                db.session.commit()
        except:
            return {'status': 'failed'}
        else:
            return {'status': 'successful'}
github jacebrowning / memegen / memegen / routes / custom.py View on Github external
@flaskparser.use_kwargs(OPTIONS)
def get(font, image):
    html = render_template(
        'custom.html',
        fonts=sorted(current_app.font_service.all()),
        font=font,
        image=image,
        config=current_app.config,
    )
    response = make_response(html)
    response.headers['Cache-Control'] = f'max-age={60*60*24*7}'
    return response
github marshmallow-code / webargs / examples / schema_example.py View on Github external
@use_kwargs({"limit": fields.Int(missing=10, location="query")})
@use_schema(UserSchema, list_view=True)
def user_list(reqargs, limit):
    users = db["users"].values()
    if request.method == "POST":
        User.insert(db=db, **reqargs)
    return list(users)[:limit]
github rotki / rotki / rotkehlchen / api / v1 / resources.py View on Github external
    @use_kwargs(modify_schema, location='json')  # type: ignore
    def delete(
            self,
            eth_tokens: List[EthereumToken],
            async_query: bool,
    ) -> Response:
        return self.rest_api.remove_owned_eth_tokens(tokens=eth_tokens, async_query=async_query)
github rotki / rotki / rotkehlchen / api / v1 / resources.py View on Github external
    @use_kwargs(delete_schema, location='json')  # type: ignore
    def delete(self, labels: List[str]) -> Response:
        return self.rest_api.remove_manually_tracked_balances(labels=labels)
github amicks / Speculator / api / resources / market.py View on Github external
    @use_kwargs({'id': fields.Integer(missing=None)})
    @validate_db(db)
    def get(self, id):
        if id is None:
            return [query_to_dict(q) for q in DataModel.query.all()]
        else:
            return query_to_dict(DataModel.query.get_or_404(id))
github rotki / rotki / rotkehlchen / api / v1 / resources.py View on Github external
    @use_kwargs(edit_schema, location='json')  # type: ignore
    def patch(self, balances: List[ManuallyTrackedBalance]) -> Response:
        return self.rest_api.edit_manually_tracked_balances(data=balances)
github fedspendingtransparency / data-act-broker-backend / dataactbroker / fileRoutes.py View on Github external
    @use_kwargs({'submission_id': webargs_fields.Int(required=True)})
    def submission_warning_reports(submission_id):
        file_manager = FileHandler(request, is_local=is_local, server_path=server_path)
        return file_manager.get_error_report_urls_for_submission(submission_id, is_warning=True)
github fedspendingtransparency / data-act-broker-backend / dataactbroker / routes / generation_routes.py View on Github external
    @use_kwargs({
        'file_type': webargs_fields.String(required=True, validate=webargs_validate.OneOf(('A', 'D1', 'D2'))),
        'cgac_code': webargs_fields.String(),
        'frec_code': webargs_fields.String(),
        'start': webargs_fields.String(),
        'end': webargs_fields.String(),
        'year': webargs_fields.Int(),
        'period': webargs_fields.Int(validate=webargs_validate.OneOf(list(range(2, 13)),
                                                                     error="Period must be an integer 2-12.")),
        'agency_type': webargs_fields.String(
            missing='awarding',
            validate=webargs_validate.OneOf(('awarding', 'funding'),
                                            error="Must be either awarding or funding if provided")
        ),
        'file_format': webargs_fields.String(
            missing='csv',
            validate=webargs_validate.OneOf(('csv', 'txt'),

webargs

Declarative parsing and validation of HTTP request objects, with built-in support for popular web frameworks, including Flask, Django, Bottle, Tornado, Pyramid, Falcon, and aiohttp.

MIT
Latest version published 4 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages