fix doc error
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
//! #### Example
|
//! #### Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::extract::FromRequestParts;
|
//! use axum::extract::FromRequestParts;
|
||||||
//! use axum::http::request::Parts;
|
//! use axum::http::request::Parts;
|
||||||
//! use axum::response::{IntoResponse, Response};
|
//! use axum::response::{IntoResponse, Response};
|
||||||
@@ -85,6 +87,8 @@
|
|||||||
//! #### Example
|
//! #### Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::extract::FromRequestParts;
|
//! use axum::extract::FromRequestParts;
|
||||||
//! use axum::http::request::Parts;
|
//! use axum::http::request::Parts;
|
||||||
//! use axum::http::StatusCode;
|
//! use axum::http::StatusCode;
|
||||||
@@ -151,6 +155,8 @@
|
|||||||
//! #### Example
|
//! #### Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::extract::FromRequestParts;
|
//! use axum::extract::FromRequestParts;
|
||||||
//! use axum::http::request::Parts;
|
//! use axum::http::request::Parts;
|
||||||
//! use axum::response::{IntoResponse, Response};
|
//! use axum::response::{IntoResponse, Response};
|
||||||
|
|||||||
@@ -65,8 +65,9 @@ mod tests {
|
|||||||
use crate::tests::{ValidTest, ValidTestParameter};
|
use crate::tests::{ValidTest, ValidTestParameter};
|
||||||
use axum_extra::extract::Form;
|
use axum_extra::extract::Form;
|
||||||
use reqwest::{RequestBuilder, StatusCode};
|
use reqwest::{RequestBuilder, StatusCode};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Form<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Form<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -69,8 +69,9 @@ mod tests {
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum_extra::extract::Query;
|
use axum_extra::extract::Query;
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Query<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Query<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
//! use axum::Form;
|
//! use axum::Form;
|
||||||
//! use axum::Router;
|
//! use axum::Router;
|
||||||
@@ -66,8 +68,9 @@ mod tests {
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::Form;
|
use axum::Form;
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Form<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Form<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNPROCESSABLE_ENTITY;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNPROCESSABLE_ENTITY;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
//!
|
//!
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
//! use axum::Json;
|
//! use axum::Json;
|
||||||
@@ -67,8 +68,9 @@ mod tests {
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Json<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Json<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNPROCESSABLE_ENTITY;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNPROCESSABLE_ENTITY;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -55,10 +55,9 @@ pub use crate::garde::{Garde, GardeRejection};
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use reqwest::{RequestBuilder, StatusCode};
|
use reqwest::{RequestBuilder, StatusCode};
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
/// # Valid test parameter
|
/// # Valid test parameter
|
||||||
pub trait ValidTestParameter: Serialize + 'static {
|
pub trait ValidTestParameter: 'static {
|
||||||
/// Create a valid parameter
|
/// Create a valid parameter
|
||||||
fn valid() -> &'static Self;
|
fn valid() -> &'static Self;
|
||||||
/// Create an error serializable array
|
/// Create an error serializable array
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//!#![cfg(feature = "validator")]
|
||||||
//!
|
//!
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
//! use axum::Router;
|
//! use axum::Router;
|
||||||
@@ -91,8 +92,9 @@ mod tests {
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum_msgpack::{MsgPack, MsgPackRaw};
|
use axum_msgpack::{MsgPack, MsgPackRaw};
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for MsgPack<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for MsgPack<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
@@ -119,7 +121,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for MsgPackRaw<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for MsgPackRaw<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
//!
|
//!
|
||||||
//! use axum::extract::Path;
|
//! use axum::extract::Path;
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
//!
|
//!
|
||||||
//! use axum::extract::Query;
|
//! use axum::extract::Query;
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
@@ -70,8 +71,9 @@ mod tests {
|
|||||||
use axum::extract::Query;
|
use axum::extract::Query;
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Query<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Query<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::BAD_REQUEST;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::headers::{Error, Header, HeaderValue};
|
//! use axum::headers::{Error, Header, HeaderValue};
|
||||||
//! use axum::http::HeaderName;
|
//! use axum::http::HeaderName;
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
//! use axum::Router;
|
//! use axum::Router;
|
||||||
//! use axum_typed_multipart::{BaseMultipart, TryFromMultipart, TypedMultipart, TypedMultipartError};
|
//! use axum_typed_multipart::{BaseMultipart, TryFromMultipart, TypedMultipart, TypedMultipartError};
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
//!
|
//!
|
||||||
//! 1. Implement `Deserialize` and `Validate` for your data type `T`.
|
//! 1. Implement `Deserialize` and `Validate` for your data type `T`.
|
||||||
//! 2. In your handler function, use `Valid<Yaml<T>>` as some parameter's type.
|
//! 2. In your handler function, use `Valid<Yaml<T>>` as some parameter's type.
|
||||||
|
|
||||||
//!
|
//!
|
||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
|
//! #![cfg(feature = "validator")]
|
||||||
|
//!
|
||||||
//! use axum::routing::post;
|
//! use axum::routing::post;
|
||||||
//! use axum::Router;
|
//! use axum::Router;
|
||||||
//! use axum_valid::Valid;
|
//! use axum_valid::Valid;
|
||||||
@@ -70,8 +71,9 @@ mod tests {
|
|||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum_yaml::Yaml;
|
use axum_yaml::Yaml;
|
||||||
use reqwest::RequestBuilder;
|
use reqwest::RequestBuilder;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
impl<T: ValidTestParameter> ValidTest for Yaml<T> {
|
impl<T: ValidTestParameter + Serialize> ValidTest for Yaml<T> {
|
||||||
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNSUPPORTED_MEDIA_TYPE;
|
const ERROR_STATUS_CODE: StatusCode = StatusCode::UNSUPPORTED_MEDIA_TYPE;
|
||||||
|
|
||||||
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
fn set_valid_request(builder: RequestBuilder) -> RequestBuilder {
|
||||||
|
|||||||
Reference in New Issue
Block a user