From 32bbdafddf4d8caf78e13b56a13a9e15cfbf7dc1 Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Sun, 4 Aug 2024 01:18:41 -0700 Subject: [PATCH] feat: Derive `OperationIo` for `Jwt` struct (#311) This will allow Jwt to be used in responses as well. Also, derive serialize/deserialize --- src/middleware/http/auth/jwt/mod.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/middleware/http/auth/jwt/mod.rs b/src/middleware/http/auth/jwt/mod.rs index 848808e5..63323464 100644 --- a/src/middleware/http/auth/jwt/mod.rs +++ b/src/middleware/http/auth/jwt/mod.rs @@ -10,8 +10,6 @@ use crate::middleware::http::auth::jwt::ietf::Claims; #[cfg(all(feature = "jwt-openid", not(feature = "jwt-ietf")))] use crate::middleware::http::auth::jwt::openid::Claims; use crate::util::serde::{deserialize_from_str, serialize_to_str}; -#[cfg(feature = "open-api")] -use aide::OperationInput; use async_trait::async_trait; use axum::extract::{FromRef, FromRequestParts}; use axum::http::request::Parts; @@ -35,19 +33,15 @@ type BearerAuthHeader = TypedHeader>; /// to the claims from `jwt-ietf`. If neither feature is enabled (but `jwt` is enabled), then /// the default will simply be a [serde_json::Value]. In all cases, the type can be overridden /// by the consumer. +#[cfg_attr(feature = "open-api", derive(aide::OperationIo))] +// #[derive(Deserialize)] +#[derive(Deserialize, Serialize)] #[non_exhaustive] -pub struct Jwt -where - C: for<'de> serde::Deserialize<'de>, -{ +pub struct Jwt { pub header: Header, pub claims: C, } -// Required in order to use `Jwt` in an Aide route. -#[cfg(feature = "open-api")] -impl OperationInput for Jwt {} - #[async_trait] impl FromRequestParts for Jwt where