Extract JSON request body validation to middleware (#1588)

* Set up code skeleton for validation middleware

* Add more boilerplate code

* WIP

* Add ASGI JSONBodyValidator

* Revert example changes

* Remove incorrect content type test

Co-authored-by: Ruwan <ruwanlambrichts@gmail.com>
This commit is contained in:
Robbe Sneyders
2022-09-18 10:55:16 +02:00
committed by GitHub
parent e4b7827b6d
commit fb071ea56f
14 changed files with 2539 additions and 77 deletions

View File

@@ -95,8 +95,7 @@ def test_errors(problem_app):
)
assert unsupported_media_type_body["type"] == "about:blank"
assert unsupported_media_type_body["title"] == "Unsupported Media Type"
assert (
unsupported_media_type_body["detail"]
== "Invalid Content-type (text/html), expected JSON data"
assert unsupported_media_type_body["detail"].startswith(
"Invalid Content-type (text/html)"
)
assert unsupported_media_type_body["status"] == 415