class TestSchema(JSONAPISchema):
        class Meta:
            type_ = 'foo'

        id = fields.Str()
        rel = JSONAPIRelationship(schema=OtherSchema,
                                  include_resource_linkage=False,
                                  type_='bar')
Esempio n. 2
0
    class TestSchema(JSONAPISchema):
        class Meta:
            type_ = 'foo'

        id = fields.Str()
        rel = JSONAPIRelationship(id_attribute='rel_id',
                                  schema=OtherSchema,
                                  include_resource_linkage=True,
                                  type_='bar')
    class TestSchema(JSONAPISchema):
        class Meta:
            type_ = 'foo'

        id = fields.Str()
        rel = JSONAPIRelationship(
            id_attribute='rel_id',
            schema=OtherSchema,
            type_='bar',
        )
Esempio n. 4
0
    class TSchema(JSONAPISchema):
        id = fields.Str(dump_only=True)
        name = fields.Str()

        rel_many = JSONAPIRelationship(schema='TRelatedSchema',
                                       type_='test-related-resource',
                                       many=True)

        class Meta:
            type_ = 'test-resource'
Esempio n. 5
0
    class TSchema(JSONAPISchema):
        id = fields.Str(dump_only=True)
        name = fields.Str()

        rel = JSONAPIRelationship(
            schema='TRelatedSchema',
            type_='test-related-resource',
            include_resource_linkage=True,
        )

        class Meta:
            type_ = 'test-resource'
Esempio n. 6
0
class UserSchema(JSONAPISchema):
    id = fields.Str(dump_only=True)
    username = fields.Str(required=True)

    organization = JSONAPIRelationship(
        type_='organizations',
        schema='OrganizationSchema',
        include_resource_linkage=True,
        required=True,
    )

    class Meta:
        type_ = 'users'
        self_route = 'users:get'
        self_route_kwargs = {'id': '<id>'}
        self_route_many = 'users:get_all'
Esempio n. 7
0
    class FooSchema(JSONAPISchema):
        id = fields.Str()
        rel = JSONAPIRelationship(
            schema='OtherSchema',
            include_resource_linkage=True,
            type_='others',
            related_route='others:get',
            related_route_kwargs={'id': '<rel_id>'},
            id_attribute='rel_id',
        )

        class Meta:
            type_ = 'foo'
            self_route = 'foo:get'
            self_route_kwargs = {'id': '<id>'}
            self_route_many = 'foo:get_all'
    class FooSchema(JSONAPISchema):
        id = fields.Str()
        rel = JSONAPIRelationship(
            schema='OtherSchema',
            type_='others',
            self_route='',
            related_resource='OtherResource',
            related_route='foo:rel',
            related_route_kwargs={'id': '<id>'},
            id_attribute='rel_id',
        )

        class Meta:
            type_ = 'foo'
            self_route = 'foo:get'
            self_route_kwargs = {'id': '<id>'}
            self_route_many = 'foo:get_many'
Esempio n. 9
0
class UserSchema(JSONAPISchema):
    id = fields.Str(dump_only=True)
    username = fields.Str(required=True)

    organization = JSONAPIRelationship(
        type_='organizations',
        schema='OrganizationSchema',
        id_attribute='organization_id',
        required=True,
        related_route='users:organization',
        related_route_kwargs={'id': '<id>'},
        related_resource='OrganizationsResource',
    )

    class Meta:
        type_ = 'users'
        strict = True
        self_route = 'users:get'
        self_route_kwargs = {'id': '<id>'}
        self_route_many = 'users:get_many'
Esempio n. 10
0
    class TSchema(JSONAPISchema):
        id = fields.Str(dump_only=True)
        name = fields.Str()

        rel = JSONAPIRelationship(
            schema='TRelatedSchema',
            type_='test-related-resource',
            self_route='test-resource:relationship-rel',
            self_route_kwargs={'id': '<id>'},
            related_resource='TRelatedResource',
            related_route='test-resource:rel',
            related_route_kwargs={'id': '<id>'},
            many=True,
        )

        class Meta:
            type_ = 'test-resource'
            self_route = 'test-resource:get'
            self_route_kwargs = {'id': '<id>'}
            self_route_many = 'test-resource:get_many'
Esempio n. 11
0
class TeamSchema(JSONAPISchema):
    id = fields.Str(dump_only=True)
    name = fields.Str(required=True)

    users = JSONAPIRelationship(
        type_='users',
        schema='UserSchema',
        many=True,
        required=True,
        self_route='teams:relationships-users',
        self_route_kwargs={'parent_id': '<id>'},
        related_resource='UsersResource',
        related_route='teams:users',
        related_route_kwargs={'id': '<id>'},
    )

    class Meta:
        type_ = 'teams'
        self_route = 'teams:get'
        self_route_kwargs = {'id': '<id>'}
        self_route_many = 'teams:get_many'
Esempio n. 12
0
    class TestSchema(JSONAPISchema):
        class Meta:
            type_ = 'foo'

        id = fields.Str()
        rel = JSONAPIRelationship(schema=OtherSchema, type_='bar')