框架用的fastAPI 报错如标题
我有两个路由:
@router.get("/{id}")
pass
@router.get("/others")
pass
结果访问 /others报错:
fastapi.exceptions.RequestValidationError: 1 validation error for Request
path -> id
value is not a valid integer (type=type_error.integer)
官网对此的解释 ,
解决方法如下:
you need to make sure that the path for /others is declared before the one for /{id}:
Otherwise, the path for /{id} would match also for /others, “thinking” that it’s receiving a parameter id with a value of “others”.