How to use the serpyco.number_field function in serpyco

To help you get started, we’ve selected a few serpyco 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 algoo / hapic / example / usermanagement / schema_serpyco.py View on Github external
class AboutSchema(object):
    """ Representation of the /about route """

    version: str
    datetime: datetime


@dataclasses.dataclass
class UserIdPathSchema(object):
    """
    representation of a user id in the uri. This allow to define rules for
    what is expected. For example, you may want to limit id to number between
    1 and 999
    """

    id: int = number_field(minimum=1, cast_on_load=True)


@dataclasses.dataclass
class UserSchema(object):
    """Complete representation of a user"""

    first_name: str
    last_name: typing.Optional[str]
    display_name: str
    company: typing.Optional[str]
    id: int
    email_address: str = string_field(format_=StringFormat.EMAIL)


@dataclasses.dataclass
class UserDigestSchema(object):
github algoo / hapic / example / fake_api / schema_serpyco.py View on Github external
id: typing.Optional[int] = None  # Note: must be optional to be unused in POST user


@dataclasses.dataclass
class PaginationSchema(object):
    """A docstring to prevent auto generated docstring"""
    first_id: int
    last_id: int
    current_id: int


@dataclasses.dataclass
class ListsUserSchema(object):
    """A docstring to prevent auto generated docstring"""
    pagination: PaginationSchema
    item_nb: int = number_field(minimum=0)
    items: typing.List[UserSchema] = nested_field(
        only=['id', 'username', 'display_name', 'company'],
    )
github algoo / hapic / example / fake_api / schema_serpyco.py View on Github external
@dataclasses.dataclass
class NoContentSchema(object):
    """A docstring to prevent auto generated docstring"""


@dataclasses.dataclass
class AboutResponseSchema(object):
    """A docstring to prevent auto generated docstring"""
    version: str
    datetime: datetime


@dataclasses.dataclass
class UserPathSchema(object):
    """A docstring to prevent auto generated docstring"""
    id: int = number_field(minimum=1, cast_on_load=True)


@dataclasses.dataclass
class UserSchema(object):
    """A docstring to prevent auto generated docstring"""
    first_name: str
    last_name: str
    display_name: str
    company: str
    username: str = string_field(pattern='[\w-]+')
    email_address: str = string_field(format_=StringFormat.EMAIL)
    id: typing.Optional[int] = None  # Note: must be optional to be unused in POST user


@dataclasses.dataclass
class PaginationSchema(object):

serpyco

Fast serialization of dataclasses using Cython

MIT
Latest version published 7 months ago

Package Health Score

53 / 100
Full package analysis