Ejemplo n.º 1
0
 async def post(
         self,
         model: UserModel = Body.i(),
         other_model: UserOtherModel = Body.i(),
 ) -> response.HTTPResponse:
     return_dict = model.dict()
     return_dict.update(other_model.dict())
     return_dict.update({"user_agent": self.user_agent})
     return response.json({"code": 0, "msg": "", "data": return_dict})
Ejemplo n.º 2
0
 def post(
         self,
         model: UserModel = Body.i(),
         other_model: UserOtherModel = Body.i(),
 ) -> dict:
     return_dict = model.dict()
     return_dict.update(other_model.dict())
     return_dict.update({"user_agent": self.user_agent})
     return {"code": 0, "msg": "", "data": return_dict}
Ejemplo n.º 3
0
async def test_raise_tip(
    model: UserModel = Body.i(),
    other_model: UserOtherModel = Body.i(),
    content_type: str = Header.i(description="content-type"),
) -> response.HTTPResponse:
    """Test Method: error tip"""
    return_dict = model.dict()
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content_type})
    return response.json({"code": 0, "msg": "", "data": return_dict})
Ejemplo n.º 4
0
async def test_post(
    model: UserModel = Body.i(),
    other_model: UserOtherModel = Body.i(),
    sex: SexEnum = Body.i(description="sex"),
    content_type: str = Header.i(alias="Content-Type", description="content-type"),
) -> JSONResponse:
    """Test Method:Post Pydantic Model"""
    return_dict = model.dict()
    return_dict["sex"] = sex.value
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content_type})
    return JSONResponse({"code": 0, "msg": "", "data": return_dict})
Ejemplo n.º 5
0
def test_raise_tip(
        model: UserModel = Body.i(),
        other_model: UserOtherModel = Body.i(),
        content__type: str = Header.i(
            description="Content-Type"
        ),  # in flask, Content-Type's key is content_type
) -> dict:
    """Test Method: error tip"""
    return_dict = model.dict()
    return_dict.update(other_model.dict())
    return_dict.update({"content_type": content__type})
    return {"code": 0, "msg": "", "data": return_dict}
Ejemplo n.º 6
0
def demo_sub_depend(
    user_agent: str = Header.i(alias="user-agent", description="user agent"),
    age: int = Body.i(description="age", gt=1, lt=100),
) -> Tuple[str, int]:
    return user_agent, age
Ejemplo n.º 7
0
class TestPaitModel(PaitBaseModel):
    uid: int = Query.i(description="user id", gt=10, lt=1000)
    user_name: str = Query.i(description="user name", min_length=2, max_length=4)
    user_agent: str = Header.i(alias="user-agent", description="user agent")
    age: int = Body.i(description="age", gt=1, lt=100)