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 ///