-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
54 lines (44 loc) · 1.42 KB
/
models.py
File metadata and controls
54 lines (44 loc) · 1.42 KB
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
52
53
54
import uuid
from typing import Optional
from pydantic import BaseModel, Field
class Member(BaseModel):
account: str = Field(max_length=16,
min_length=8, description='最少輸入8個字元,最多16個字元')
password: str = Field(...)
name: str = Field(None)
phone: str = Field(None)
'''
Field(...)是必填欄位,Field(None) 是可選填
Field(None,title="The description of the item",max_length=10,alias='我是替代字')
'''
class Config:
allow_population_by_field_name = True
schema_extra = {
"example": {
"account": "testtest123",
"password": "testpassword",
"name": "Ansel",
"phone": "0912345678"
}
}
class MemberUpdate(BaseModel):
name: Optional[str]
phone: Optional[str]
class Config:
schema_extra = {
"example": {
"name": "Zoe",
"phone": "0900123321"
}
}
class Login(BaseModel):
account: str = Field(max_length=16,
min_length=8, description='最少輸入8個字元,最多16個字元')
password: str = Field(...)
class Config:
schema_extra = {
"example": {
"account": "testtest123",
"password": "testpassword"
}
}