class NestedSchema(halogen.Schema): """A combination of a Person, an attribute is_friend, and a price.""" self = halogen.Link("/events/activity-event{?uid}", type='application/pdf', templated=True) person = halogen.Attr(PersonSchema) is_friend = halogen.Attr() price = halogen.Attr(AmountType) events = halogen.Embedded(halogen.types.List(EventSchema), attr=lambda collection: collection["events"], curie=em)
class VNDError(halogen.Schema): """An exception that can be serialized to the hal+json format.""" message = halogen.Attr(required=False, attr=get_error_message) logref = halogen.Attr(attr=lambda error: uuid.uuid4().hex) help = halogen.Link(required=False, attr=get_current_profile_link) # Extended fields type = halogen.Attr(required=False, attr='error_type', default='UNKNOWN_ERROR') """Error type identifier.""" details = halogen.Attr(required=False, attr='data') """Optional additional error details."""
class NestedSchema(halogen.Schema): """An example nested schema, with a person, an is_friend attribute, and a price.""" self = halogen.Link(attr='/some/link') person = halogen.Attr(Person) is_friend = halogen.Attr() price = halogen.Attr(Amount) products = halogen.Attr( halogen.types.List( Product, allow_scalar=True, validators=[ halogen.validators.Length(min_length=0, ), ], ), default=[], )
class AccountSchema(halogen.Schema): self = halogen.Link(attr=lambda account: url_for( "get_account", account_key=account.key.urlsafe())) id = halogen.Attr(attr=lambda account: account.key.id()) username = halogen.Attr()
class Schema(halogen.Schema): """A test schema.""" warehouse = halogen.Link("/test/123", deprecation="http://foo.bar")
class Schema(halogen.Schema): """A test schema.""" warehouse = halogen.Link(curie=ACME)
class Schema(halogen.Schema): self = halogen.Link(attr="uid")
class OrderedSchema2(halogen.Schema): self = halogen.Link('http://somewhere.com') hello = halogen.Attr() foo = halogen.Attr('bar') person = halogen.Embedded(PersonSchema)