aiohttp-apispec icon indicating copy to clipboard operation
aiohttp-apispec copied to clipboard

Body argument is deprecated for http web exceptions

Open alvassin opened this issue 5 years ago • 0 comments

In example for custom validation errors handling you raise HTTPException with body argument:

def my_error_handler(
    error: ValidationError,
    req: web.Request,
    schema: Schema,
    error_status_code: Optional[int] = None,
    error_headers: Optional[Mapping[str, str]] = None,
) -> NoReturn:
    raise web.HTTPBadRequest(
            body=json.dumps(error.messages),
            headers=error_headers,
            content_type="application/json",
        )

I see many DeprecationWarning: body argument is deprecated for http web exceptions warnings.

According to this issue it was deprecated in aiohttp in 2018.

alvassin avatar Feb 23 '20 08:02 alvassin