我写的response_model_include和response_model_exclude没有效果
@app04.post( "/response_model/attributes", #response_model=UserOut, #response_model=Union[UserIn, UserOut]#取并集 #response_model=List[UserOut] #也可以用列表,响应多个模型类return [user,user] response_model_include=["username", "email"] #当响应字段太多时指定包含或排除哪些字段 # response_model_exclude={"mobile"} ) async def response_model_attributes(user: UserIn): #del user.password #Union[UserIn, UserOut]后,删除password属性 return user
我试了好几次,,返回都是返回了全部字段;