Make path params work with aide
This commit is contained in:
parent
461021cef1
commit
f9dafdfc88
5 changed files with 57 additions and 5 deletions
|
|
@ -6,6 +6,8 @@ use axum_extra::{
|
|||
headers::{authorization::Bearer, Authorization},
|
||||
TypedHeader,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::auth::auth;
|
||||
use crate::{
|
||||
|
|
@ -14,10 +16,16 @@ use crate::{
|
|||
errors::{server_error, SyncServerError},
|
||||
};
|
||||
|
||||
// This is required for aide to infer the path parameter types and names
|
||||
#[derive(Deserialize, JsonSchema)]
|
||||
pub struct PathParams {
|
||||
vault_id: VaultId,
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
pub async fn fetch_latest_documents(
|
||||
TypedHeader(auth_header): TypedHeader<Authorization<Bearer>>,
|
||||
Path(vault_id): Path<VaultId>,
|
||||
Path(PathParams { vault_id }): Path<PathParams>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Vec<DocumentVersionWithoutContent>>, SyncServerError> {
|
||||
auth(&state, auth_header.token())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue