How to use the webargs.fields.Nested 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 marshmallow-code / webargs / tests / apps / django_app / echo / views.py View on Github external
def echo_nested(request):
    argmap = {"name": fields.Nested({"first": fields.Str(), "last": fields.Str()})}
    return json_response(parser.parse(argmap, request))
github marshmallow-code / webargs / tests / apps / aiohttp_app.py View on Github external
async def echo_nested_many_data_key(request):
    data_key_kwarg = {
        "load_from" if (MARSHMALLOW_VERSION_INFO[0] < 3) else "data_key": "X-Field"
    }
    args = {"x_field": fields.Nested({"id": fields.Int()}, many=True, **data_key_kwarg)}
    parsed = await parser.parse(args, request)
    return json_response(parsed)
github marshmallow-code / webargs / tests / apps / flask_app.py View on Github external
def echo_nested():
    args = {"name": fields.Nested({"first": fields.Str(), "last": fields.Str()})}
    return J(parser.parse(args))
github marshmallow-code / webargs / tests / apps / falcon_app.py View on Github external
def on_post(self, req, resp):
        args = {"name": fields.Nested({"first": fields.Str(), "last": fields.Str()})}
        resp.body = json.dumps(parser.parse(args, req))
github FreeDiscovery / FreeDiscovery / freediscovery / server / resources.py View on Github external
    @use_args({'dataset_definition': wfields.Nested(_DatasetDefinitionShort,
                                                    many=True, required=True)})
    @marshal_with(EmptySchema())
    def post(self, dsid, **args):
        fe = FeatureVectorizer(self._cache_dir, dsid=dsid, mode='r')
        fe.remove(args['dataset_definition'])
        return {}
github indico / indico / indico / modules / rb / controllers / backend / admin.py View on Github external
               'nonbookable_periods': fields.Nested({'start_dt': fields.Date(),
                                                     'end_dt': fields.Date()}, many=True)})
    def _process(self, args):
        if 'bookable_hours' in args:
            self._check_invalid_times(args)
        update_room_availability(self.room, args)
        return jsonify(
            nonbookable_periods=nonbookable_periods_schema.dump(self.room.nonbookable_periods, many=True),
            bookable_hours=bookable_hours_schema.dump(self.room.bookable_hours, many=True)
        )
github FreeDiscovery / FreeDiscovery / freediscovery / server / resources.py View on Github external
    @use_args({'data': wfields.Nested(DocumentIndexFullSchema, many=True),
               'return_file_path': wfields.Bool(missing=True)})
    @marshal_with(DocumentIndexNestedSchema())
    def post(self, dsid, **args):
        fe = FeatureVectorizer(self._cache_dir, dsid=dsid)
        if 'data' in args and args['data']:
            query = pd.DataFrame(args['data'])
            fe.db_.filenames_ = fe.filenames_
            res = fe.db_.search(query, return_file_path=args['return_file_path'])
        else:
            res = None
        if args['return_file_path']:
            fe.db_.filenames_ = fe.filenames_
        res_repr = fe.db_.render_dict(res, return_file_path=args['return_file_path'])
        return {'data': res_repr}
github FreeDiscovery / FreeDiscovery / freediscovery / server / resources.py View on Github external
               "dataset_definition": wfields.Nested(_DatasetDefinition, many=True),
               "vectorize": wfields.Bool(missing=True),
               "document_id_generator": wfields.Str(missing="indexed_file_path")})
    @marshal_with(IDSchema())
    def post(self, dsid, **args):
        fe = FeatureVectorizer(self._cache_dir, dsid=dsid, mode='r')
        fe.ingest(**args)
        if fe.pars_['parse_email_headers']:
            fe.parse_email_headers()
        return {'id': fe.dsid}

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

88 / 100
Full package analysis

Similar packages