Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion okapi-operation-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ proc-macro = true

[dependencies]
darling = "0.20"
lazy_static = "1"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
Expand Down
27 changes: 12 additions & 15 deletions okapi-operation-macro/src/operation/request_body/axum.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use std::collections::HashSet;
use std::{collections::HashSet, sync::LazyLock};

use syn::{PatType, Type};

use super::{RequestBody, RequestBodyAttrs};
use crate::error::Error;

lazy_static::lazy_static! {
// NOTE: `Form` is not enabled because it have different content types
// based on method https://docs.rs/axum/latest/axum/struct.Form.html#as-extractor
static ref KNOWN_BODY_TYPES: HashSet<&'static str> = [
// std types
"String",

// axum types
"Json",

// 3rd party types
"Bytes",
].into_iter().collect();
}
// NOTE: `Form` is not enabled because it have different content types
// based on method https://docs.rs/axum/latest/axum/struct.Form.html#as-extractor
static KNOWN_BODY_TYPES: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
[
"String", // std types
"Json", // 3rd party types
"Bytes", // 3rd party types
]
.into_iter()
.collect()
});

impl RequestBody {
pub(super) fn try_find_axum(pt: &PatType) -> Result<Option<Self>, Error> {
Expand Down