Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion okapi-operation-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ proc-macro = true

[dependencies]
darling = "0.20"
lazy_static = "1"
lazy_static = { version = "1", optional = true}
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
thiserror = "1"

[features]
axum = []
legacy_lazy = ["lazy_static"]
Comment thread
Flowneee marked this conversation as resolved.
Outdated

[dev-dependencies]
assert_matches = "1"
16 changes: 16 additions & 0 deletions okapi-operation-macro/src/operation/request_body/axum.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
use std::collections::HashSet;
#[cfg(not(feature = "legacy_lazy"))]
use std::sync::LazyLock;

use syn::{PatType, Type};

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

#[cfg(not(feature = "legacy_lazy"))]
// 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()
});

#[cfg(feature = "legacy_lazy")]
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
Expand Down
1 change: 1 addition & 0 deletions okapi-operation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ macro = ["okapi-operation-macro"]
yaml = ["serde_yaml"]

axum = ["dep:axum", "paste", "tower", "okapi-operation-macro/axum"]
legacy_lazy = ["okapi-operation-macro/legacy_lazy"]
# Deprecated, use feature `axum` instead
axum-integration = ["axum"]

Expand Down