File: collapse_root_models_field_constraints.py

package info (click to toggle)
python-datamodel-code-generator 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,052 kB
  • sloc: python: 29,621; makefile: 15
file content (51 lines) | stat: -rw-r--r-- 979 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# generated by datamodel-codegen:
#   filename:  not_real_string.json
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import List, Optional

from pydantic import BaseModel, Field


class Tweet(BaseModel):
    author_id: Optional[str] = None


class Users(BaseModel):
    __root__: List[str]


class FileHash(BaseModel):
    __root__: str = Field(
        ...,
        description='For file',
        max_length=32,
        min_length=32,
        regex='^[a-fA-F\\d]{32}$',
    )


class FileRequest(BaseModel):
    file_hash: str = Field(
        ...,
        description='For file',
        max_length=32,
        min_length=32,
        regex='^[a-fA-F\\d]{32}$',
    )


class ImageRequest(BaseModel):
    image_hash: Optional[str] = Field(
        None,
        description='For image',
        max_length=64,
        min_length=64,
        regex='^[a-fA-F\\d]{32}$',
    )


class FileHashes(BaseModel):
    __root__: List[FileHash]