Skip to content

Commit

Permalink
Fix no_recursion support on maps (#1167)
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 authored Oct 27, 2024
1 parent e9eebd0 commit 542800b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions utoipa-gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog - utoipa-gen

## Unreleased

### Fixed

* Fix `no_recursion` support on maps (https://github.com/juhaku/utoipa/pull/1167)

## 5.1.2 - Oct 16 2024

### Added
Expand Down
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 542800b

Please sign in to comment.