class CompanyMapper(Mapper): __type__ = User id = field.String(read_only=True) name = field.String() __roles__ = {'public': whitelist('name', 'id')}
class UserMapper(BaseMapper): __type__ = User name = field.String() email = field.String() __roles__ = {'__default__': role.blacklist('password')}
class DocumentMapper(Mapper): __type__ = dict id = field.String(required=True) name = field.String() user = field.Nested('UserMapper', name='user', allow_partial_updates=True)
class BookMapper(BaseMapper): __type__ = Book title = field.String() amazon_url = field.String() author = field.String() genre = field.String()
class PlanetMapper(Mapper): __type__ = Planet id = field.Integer(read_only=True) name = field.String() description = field.String() created_at = field.DateTime(read_only=True)
class UserMapper(Mapper): __type__ = User id = field.String(read_only=True) name = field.String() password = field.String() is_admin = field.Boolean(required=False, default=False) __roles__ = {'public': whitelist('name', 'id', 'is_admin')}
class UserMapper(Mapper): __type__ = dict id = field.String(required=True, read_only=True) name = field.String() __roles__ = { 'public': [ 'name', ] }
class SchedulableMapper(PolymorphicMapper): __type__ = TestType id = field.Integer(read_only=True) name = field.String() object_type = field.String(choices=['event', 'task'], read_only=True) __mapper_args__ = { 'polymorphic_on': object_type, 'allow_polymorphic_marshal': True, } __roles__ = { 'name_only': ['name'], 'public': whitelist('name', 'id'), }
class PostMapper(Mapper): __type__ = Post title = field.String() user = field.Nested('UserMapper', required=True, allow_create=True) readers = field.Collection(field.Nested('UserMapper'), required=False)
class CharacterMapper(Mapper): __type__ = Character id = field.Integer(read_only=True) name = field.String() created_at = field.DateTime(read_only=True)
class MyMapper(Mapper): __type__ = MyObject id = field.Integer() name = field.String() __roles__ = {'name_only': ['name']}
class PostMapper(Mapper): __type__ = Post title = field.String() user = field.Nested('UserMapper', required=True, allow_updates_in_place=True)
class UserMapper(Mapper): __type__ = User id = field.Integer(read_only=True) name = field.String() is_admin = field.Boolean(required=False, default=False) company = field.Nested(CompanyMapper, getter=company_getter) __roles__ = { 'overview': whitelist('id', 'name') }
class PostMapper(Mapper): __type__ = Post title = field.String() user = field.Nested('UserMapper', required=False, allow_updates_in_place=True) readers = field.Collection(field.Nested('PostMapper', getter=foo_getter), required=False)
def test_collection_proxies_name_to_wrapped_field(): f = field.Collection(field.Integer(), name='post_ids') f2 = field.Collection(field.String(), name='test') with pytest.raises(field.FieldError): field.Collection(field.String(name='foo')) class UserMapper(Mapper): __type__ = TestType id = field.String(required=True) tags = field.Collection(field.String()) assert f.name == 'post_ids' assert f2.name == 'test' mapper = UserMapper({}) assert mapper.fields['tags'].name == 'tags'
class UserMapper(BaseMapper): __type__ = User name = field.String() email = field.String() website = field.String() street_address = field.String() city = field.String() state = field.String() zip = field.String() phone = field.String() __roles__ = {'__default__': role.blacklist('password')}
class TaskMapper(SchedulableMapper): __type__ = TestType status = field.String() __mapper_args__ = { 'polymorphic_name': 'task' } __roles__ = { 'public': SchedulableMapper.__roles__['public'] | whitelist('status'), 'task_only_role': whitelist('id', 'status'), 'task_blacklist': blacklist('status') }
class EventMapper(SchedulableMapper): __type__ = TestType location = field.String() __mapper_args__ = { 'polymorphic_name': 'event' } __roles__ = { 'public': SchedulableMapper.__roles__['public'] | whitelist('location'), 'event_only_role': whitelist('id', 'location'), 'event_blacklist': blacklist('location') }
class UserMapper(Mapper): __type__ = User name = field.String()
class CompanyMapper(Mapper): __type__ = Company id = field.Integer(read_only=True) name = field.String()
class PostMapper(Mapper): __type__ = Post title = field.String() user = field.Nested('UserMapper', required=True, getter=getter)
class SchoolMapper(BaseMapper): __type__ = School school_name = field.String() wut = field.String() date_of_graduation = field.String()
class Inner(Mapper): __type__ = dict name = field.String(source='user_name')
class UserMapper(Mapper): __type__ = dict id = field.String(required=True, read_only=True) name = field.String()
class UserMapper(Mapper): __type__ = User id = field.Integer(read_only=True) name = field.String()
class WeaponOfChoiceMapper(BaseMapper): __type__ = WeaponOfChoice title = field.String() items = field.Collection(field.String())
class TechnicalExperienceMapper(BaseMapper): __type__ = TechnicalExperience title = field.String() items = field.Collection(field.String())
class SubMapper(Mapper): __type__ = SubResource w = field.String() x = field.String(extra_serialize_pipes={'output': [x_pipe]}) y = field.String() z = field.String()
class CharacterMapper(BaseMapper): __type__ = Character name = field.String()
class ComplexMapper(Mapper): __type__ = Complex foo = field.String() bar = field.String(extra_serialize_pipes={'output': [bar_pipe]}) sub = field.Nested(SubMapper) subs = field.Collection(field.Nested(SubMapper))