File size: 1,311 Bytes
1865436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Optional, List

from pydantic import BaseModel, EmailStr, Field


class UserSchema(BaseModel):
    username: str = Field(...)
    email: str = Field(...)
    password: str = Field(...)
    projectname: List[str]
    projectpath: List[str]

    class Config:
        schema_extra = {
            "example": {
                "username": "John Doe",
                "email": "[email protected]",
                "password": "Water resources engineering",
                "projectname": ["1", "2"],
                "projectpath": ["1", "2"],
            }
        }


class UpdateUserModel(BaseModel):
    username: Optional[str]
    email: Optional[EmailStr]
    password: Optional[str]
    projectname: List[str]
    projectpath: List[str]

    class Config:
        schema_extra = {
            "example": {
                "username": "John Doe",
                "email": "[email protected]",
                "password": "Water resources engineering",
                "projectname": ["1", "2"],
                "projectpath": ["1", "2"],
            }
        }


def ResponseModel(data, message):
    return {
        "data": [data],
        "code": 200,
        "message": message,
    }


def ErrorResponseModel(error, code, message):
    return {"error": error, "code": code, "message": message}