Exemple #1
0
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
    )
Exemple #2
0
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",
    )
Exemple #3
0
 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
                             }])
Exemple #4
0
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()
Exemple #5
0
 class TestNoneModel(middle.Model):
     value = middle.field(
         type=Dict[str, int],
         min_properties=1,
         max_properties=2,
         default=None,
     )
Exemple #6
0
 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()
Exemple #8
0
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",
    )
Exemple #9
0
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")
Exemple #10
0
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")
Exemple #11
0
 class TestModel(middle.Model):
     options = middle.field(
         type=t.Dict[str, str],
         description="Options for TestModel",
         min_properties=1,
     )
Exemple #12
0
 class City(BaseCity):
     population = middle.field(type=int)
     latitude = middle.field(type=float)
     longitude = middle.field(type=float)
Exemple #13
0
 class BaseCity(middle.Model):
     name = middle.field(type=str)
     region = middle.field(type=CityRegionEnum)
Exemple #14
0
 class TestModel(middle.Model):
     some_enum = middle.field(type=TestIntEnum,
                              description="Some test enumeration")
Exemple #15
0
 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")
Exemple #16
0
 class TestModel(middle.Model):
     name = middle.field(type=t.Tuple[str, int])
Exemple #17
0
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")
Exemple #18
0
 class TestModel(middle.Model):
     when = middle.field(type=datetime.datetime)
Exemple #19
0
 class TestModel(middle.Model):
     name = middle.field(type=str, description="The name", min_length=5)
Exemple #20
0
 class SomeAnotherModel(middle.Model):
     age = middle.field(type=None)
Exemple #21
0
 class TestModel(middle.Model):
     lots_of_values = middle.field(type=t.Union[str, int, float])
Exemple #22
0
 class TestModel(middle.Model):
     lots_of_values = middle.field(type=t.Union[None, str, int])
Exemple #23
0
 class TestModel(middle.Model):
     maybe_name = middle.field(type=t.Optional[str])
Exemple #24
0
 class TestModel(middle.Model):
     some_enum = middle.field(type=TestIntEnum)
Exemple #25
0
 class TestModel(middle.Model):
     __description__ = "Test model for unit tests"
     name = middle.field(type=t.List[str],
                         description="List of names",
                         default=[])
Exemple #26
0
 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")
Exemple #27
0
 class TestModel(middle.Model):
     switch = middle.field(type=bool)
Exemple #28
0
 class TestModel(middle.Model):
     options = middle.field(type=t.Dict[float, str])
Exemple #29
0
 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])
Exemple #30
0
 class TestModel(middle.Model):
     file_data = middle.field(type=bytes,
                              description="The contents of the file")