marshmallow

My API is returning blank json, instead of desired nested schema

∥☆過路亽.° 提交于 2020-08-09 09:24:11
问题 My schema is: import time from marshmallow import fields, Schema from ramas_core.api.resources.base import CamelCaseSchema, base_filters, unfilterable_fields class colorMapLayersSchema(CamelCaseSchema): #raster_layer id = fields.UUID() visibility = fields.Boolean() color_map_type = fields.String() #capture field_id = fields.UUID() event_date = fields.DateTime() event_date_time = fields.String() class gridMapLayersSchema(CamelCaseSchema): #raster_layer id = fields.UUID() visibility = fields

Flask, Marshmallow 3, and webargs use_args fails to parse arguments

邮差的信 提交于 2020-07-22 06:13:11
问题 With Flask 1.1.2, marshmallow 3.6.1 and webargs 6.1.0 all of my arguments are always missing . Schema: class ExportSearchSchema(Schema): limit = fields.Integer(required=False, allow_none=False, default=10, missing=10) offset = fields.Integer(required=False, allow_none=False, default=0, missing=0) status = fields.Str(required=False) class Meta: unknown = RAISE @validates('status') def validate_status(self, value): if value and value not in ['complete', 'pending', 'failed']: raise

Define fields programmatically in Marshmallow Schema

大兔子大兔子 提交于 2020-07-17 08:24:30
问题 Say I have a Schema like this: class MySchema(Schema): field_1 = Float() field_2 = Float() ... field_42 = Float() Is there a way to add those fields programmatically to the class? Something like this: class MyClass(BaseClass): FIELDS = ('field_1', 'field_2',..., 'field_42') for field in FIELDS: setattr(?, field, Float()) # What do I replace this "?" with? I've seen posts about adding attributes dynamically to class instances, but this is different because I don't want to patch an instance but