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-]+") # noqa: W605 email_address: str = string_field(format_=StringFormat.EMAIL) id: typing.Optional[ int] = None # Note: must be optional to be unused in POST user
class CustomPetASchema(PetSchema): email: str = serpyco.string_field( format_=serpyco.StringFormat.EMAIL, pattern="^[A-Z]", min_length=3, max_length=24, )
class Location(object): def get_openstreetmap_url(obj: "Location") -> str: return f"https://www.openstreetmap.org/search?#map=13/{obj.lat}/{obj.lon}" lon: float = serpyco.number_field(cast_on_load=True) lat: float = serpyco.number_field(cast_on_load=True) url: typing.Optional[str] = serpyco.string_field( getter=get_openstreetmap_url, default=None)
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)
class WithStringField(object): """String field test class""" foo: str = serpyco.string_field( format_=serpyco.StringFormat.EMAIL, pattern="^[A-Z]", min_length=3, max_length=24, )
class ZoneBuildModel: row_i: int = serpyco.number_field(getter=lambda b: b.doc.zone_row_i) col_i: int = serpyco.number_field(getter=lambda b: b.doc.zone_col_i) char: str = serpyco.string_field(getter=lambda b: b.desc.char) id: int = serpyco.number_field(getter=lambda b: b.doc.id) build_id: str = serpyco.number_field(getter=lambda b: b.doc.build_id) classes: typing.List[str] = serpyco.field(default_factory=list, getter=lambda b: b.desc.classes) traversable: typing.Dict[TransportType, bool] = serpyco.field( default_factory=dict, getter=lambda b: b.desc.traversable)
class PetSchema(object): id: int = string_field(description="Pet id") name: str = string_field(description="Pet name") password: str = string_field(description="Pet auth password")