class Player(middle.Model): nickname = middle.field( type=str, description="The nickname of the player over the internet" ) youtube_channel = middle.field( type=str, description="The YouTube channel of the player", default=None )
class City(middle.Model): __description__ = "One awesome city built" name = middle.field(type=str, description="The city name") region = middle.field( default=CityRegionEnum.TEMPERATE, type=CityRegionEnum, description="The region this city is located", )
class PersonModel(middle.Model): name = middle.field(type=str, default="Paul") age = middle.field(type=int, default=42) children = middle.field(type=List[ChildModel], default=[{ "name": "James", "age": 12 }])
class MiddleGame(middle.Model): name: str = middle.field() platform: PlatformEnum = middle.field() score: float = middle.field() resolution_tested: str = middle.field() genre: List[str] = middle.field() rating: Dict[str, float] = middle.field() players: Set[str] = middle.field() language: LanguageEnum = middle.field() awesome_city: MiddleCity = middle.field()
class TestNoneModel(middle.Model): value = middle.field( type=Dict[str, int], min_properties=1, max_properties=2, default=None, )
class TestModel(middle.Model): value = middle.field( type=Dict[str, int], min_properties=1, max_properties=2, default={"hello": 1}, )
class Game(middle.Model): name: str = middle.field() platform: PlatformEnum = middle.field() score: float = middle.field() resolution_tested: str = middle.field(pattern="^\d+x\d+$") genre: List[str] = middle.field() players: List[str] = middle.field() language: LanguageEnum = middle.field() awesome_city: City = middle.field()
class Game(middle.Model): __description__ = "An electronic game model" name = middle.field(type=str, description="The name of the game") platform = middle.field( type=PlatformEnum, description="Which platform it runs on" ) score = middle.field( type=float, description="The average score of the game", minimum=0, maximum=10, multiple_of=0.1, ) resolution_tested = middle.field( type=str, description="The resolution which the game was tested", pattern="^\d+x\d+$", ) genre = middle.field( type=t.List[str], description="One or more genres this game is part of", min_items=1, unique_items=True, ) rating = middle.field( type=t.Dict[str, float], description="Ratings given on specialized websites", min_properties=3, ) players = middle.field( type=t.Set[Player], description="Some of the notorious players of this game", ) language = middle.field( type=LanguageEnum, description="The main language of the game" ) awesome_city = middle.field(type=City) remarkable_resources = middle.field( type=t.Union[Player, City], description="Some remarkable resources of this game over the internet", )
class GameModel(middle.Model): name: str = middle.field(description="The name of the game") platform: PlatformEnum = middle.field( description="Which platform it runs on") score: float = middle.field(description="The average score of the game") resolution_tested: str = middle.field( description="The resolution which the game was tested", pattern="^\d+x\d+$", ) genre: List[str] = middle.field( description="One or more genres this game is part of") rating: Dict[str, float] = middle.field( description="Ratings given on specialized websites") players: Set[str] = middle.field( description="Some of the notorious players of this game") language: LanguageEnum = middle.field( description="The main language of the game") awesome_city: CityModel = middle.field( description="One awesome city built")
class Game(middle.Model): name = middle.field(type=str, description="The name of the game") platform = middle.field(type=PlatformEnum, description="Which platform it runs on") score = middle.field(type=float, description="The average score of the game") resolution_tested = middle.field( type=str, description="The resolution which the game was tested", pattern="^\d+x\d+$", ) genre = middle.field(type=List[str], description="One or more genres this game is part of") rating = middle.field( type=Dict[str, float], description="Ratings given on specialized websites", ) players = middle.field( type=Set[str], description="Some of the notorious players of this game") language = middle.field(type=LanguageEnum, description="The main language of the game") awesome_city = middle.field(type=City, description="One awesome city built")
class TestModel(middle.Model): options = middle.field( type=t.Dict[str, str], description="Options for TestModel", min_properties=1, )
class City(BaseCity): population = middle.field(type=int) latitude = middle.field(type=float) longitude = middle.field(type=float)
class BaseCity(middle.Model): name = middle.field(type=str) region = middle.field(type=CityRegionEnum)
class TestModel(middle.Model): some_enum = middle.field(type=TestIntEnum, description="Some test enumeration")
class TestModel(middle.Model): person = middle.field(type=InnerModel, description="The person to access this resource") active = middle.field(type=bool, description="If the resource is active")
class TestModel(middle.Model): name = middle.field(type=t.Tuple[str, int])
class CityModel(middle.Model): name = middle.field(type=str, description="The city name") region = middle.field(type=CityRegionEnum, description="The region this city is located")
class TestModel(middle.Model): when = middle.field(type=datetime.datetime)
class TestModel(middle.Model): name = middle.field(type=str, description="The name", min_length=5)
class SomeAnotherModel(middle.Model): age = middle.field(type=None)
class TestModel(middle.Model): lots_of_values = middle.field(type=t.Union[str, int, float])
class TestModel(middle.Model): lots_of_values = middle.field(type=t.Union[None, str, int])
class TestModel(middle.Model): maybe_name = middle.field(type=t.Optional[str])
class TestModel(middle.Model): some_enum = middle.field(type=TestIntEnum)
class TestModel(middle.Model): __description__ = "Test model for unit tests" name = middle.field(type=t.List[str], description="List of names", default=[])
class InnerModel(middle.Model): name = middle.field(type=str, min_length=3, description="The person name") age = middle.field(type=int, minimum=18, description="The person age")
class TestModel(middle.Model): switch = middle.field(type=bool)
class TestModel(middle.Model): options = middle.field(type=t.Dict[float, str])
class TestModel(middle.Model): __looks_reserved__ = {"type": str} name = {"type": str} surname = middle.field(type=str) age = {"type": int} hobby = middle.field(type=typing.List[str])
class TestModel(middle.Model): file_data = middle.field(type=bytes, description="The contents of the file")