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