Skip to content

Commit

Permalink
Fix no_recursion support on maps
Browse files Browse the repository at this point in the history
This commit fixes `no_recursion` attribute on map types like
`HashMap<K, T>`.

Fixes #1166
  • Loading branch information
juhaku committed Oct 27, 2024
1 parent e9eebd0 commit 0a1b1d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions utoipa-gen/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ impl ComponentSchema {
for feature in features.iter().filter(|feature| feature.is_validatable()) {
feature.validate(&schema_type, type_tree);
}
let _ = pop_feature!(features => Feature::NoRecursion(_)); // primitive types are not recursive
tokens.extend(features.to_token_stream()?);
}
ValueType::Value => {
Expand Down
3 changes: 2 additions & 1 deletion utoipa-gen/tests/schema_derive_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5970,6 +5970,7 @@ fn test_named_and_enum_container_recursion_compiles() {
pub struct Tree {
left: Box<Tree>,
right: Box<Tree>,
map: HashMap<String, Tree>,
}

#[derive(ToSchema)]
Expand All @@ -5988,7 +5989,7 @@ fn test_named_and_enum_container_recursion_compiles() {
right: Box<Recursion>,
},
#[schema(no_recursion)]
Unnamed(Box<Recursion>),
Unnamed(HashMap<String, Recursion>),
NoValue,
}

Expand Down

0 comments on commit 0a1b1d8

Please sign in to comment.