Skip to content

Commit

Permalink
feat: impl OperationInput for axum_extra::extract::JsonDeserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 authored and JakkuSakura committed Dec 21, 2024
1 parent 4186760 commit 9daa5aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/aide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ axum-extra-cookie = ["axum", "axum-extra", "axum-extra/cookie"]
axum-extra-cookie-private = ["axum", "axum-extra", "axum-extra/cookie-private"]
axum-extra-form = ["axum", "axum-extra", "axum-extra/form"]
axum-extra-query = ["axum", "axum-extra", "axum-extra/query"]
axum-extra-json-deserializer = ["axum", "axum-extra", "axum-extra/json-deserializer"]
axum-wasm = ["axum"]


Expand Down
13 changes: 11 additions & 2 deletions crates/aide/src/axum/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::{
use axum::{
body::Body,
extract::{
Extension, Form, Host, Json, MatchedPath, OriginalUri, Path, Query, RawQuery,
State,
Extension, Form, Host, Json, MatchedPath, OriginalUri, Path, Query, RawQuery, State,
},
};

Expand Down Expand Up @@ -108,6 +107,16 @@ where
}
}

#[cfg(feature = "axum-extra-json-deserializer")]
impl<T> OperationInput for axum_extra::extract::JsonDeserializer<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
Json::<T>::operation_input(ctx, operation);
}
}

impl<T> OperationInput for Form<T>
where
T: JsonSchema,
Expand Down
3 changes: 2 additions & 1 deletion crates/aide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
//! - `axum-extra-cookie-private`
//! - `axum-extra-form`
//! - `axum-extra-query`
//! - `axum-extra-json-deserializer`
//!
//! ## MSRV
//!
Expand Down Expand Up @@ -140,7 +141,7 @@ pub mod redoc;
#[cfg(feature = "scalar")]
pub mod scalar;

pub use helpers::{no_api::NoApi, with_api::ApiOverride, with_api::WithApi, use_api::UseApi};
pub use helpers::{no_api::NoApi, use_api::UseApi, with_api::ApiOverride, with_api::WithApi};

pub use error::Error;
pub use operation::{OperationInput, OperationOutput};
Expand Down

0 comments on commit 9daa5aa

Please sign in to comment.