From 2c985246bae5193e6ecde4ca1a8f093cd4554d11 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 19 Mar 2022 01:24:28 +0100 Subject: [PATCH] Fix out of date docs for `Json` (#871) Fixes https://github.com/tokio-rs/axum/issues/865 --- axum/src/json.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/axum/src/json.rs b/axum/src/json.rs index 9fcb53cb..e1d068fa 100644 --- a/axum/src/json.rs +++ b/axum/src/json.rs @@ -15,9 +15,16 @@ use std::ops::{Deref, DerefMut}; /// JSON Extractor / Response. /// /// When used as an extractor, it can deserialize request bodies into some type that -/// implements [`serde::Deserialize`]. If the request body cannot be parsed, or it does not contain -/// the `Content-Type: application/json` header, it will reject the request and return a -/// `400 Bad Request` response. +/// implements [`serde::Deserialize`]. The request will be rejected (and a [`JsonRejection`] will +/// be returned) if: +/// +/// - The request doesn't have a `Content-Type: application/json` (or similar) header. +/// - The body doesn't contain syntactically valid JSON. +/// - The body contains syntactically valid JSON but it couldn't be deserialized into the target +/// type. +/// - Buffering the request body fails. +/// +/// See [`JsonRejection`] for more details. /// /// # Extractor example ///