Skip to content

Commit 612f211

Browse files
committed
Fix no_recursion support on maps
This commit fixes `no_recursion` attribute on map types like `HashMap<K, T>`. Fixes #1166
1 parent e9eebd0 commit 612f211

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

utoipa-gen/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog - utoipa-gen
22

3+
## Unreleased
4+
5+
### Fixed
6+
7+
* Fix `no_recursion` support on maps (https://github.com/juhaku/utoipa/pull/1167)
8+
39
## 5.1.2 - Oct 16 2024
410

511
### Added

utoipa-gen/src/component.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,7 @@ impl ComponentSchema {
11491149
for feature in features.iter().filter(|feature| feature.is_validatable()) {
11501150
feature.validate(&schema_type, type_tree);
11511151
}
1152+
let _ = pop_feature!(features => Feature::NoRecursion(_)); // primitive types are not recursive
11521153
tokens.extend(features.to_token_stream()?);
11531154
}
11541155
ValueType::Value => {

utoipa-gen/tests/schema_derive_test.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5970,6 +5970,7 @@ fn test_named_and_enum_container_recursion_compiles() {
59705970
pub struct Tree {
59715971
left: Box<Tree>,
59725972
right: Box<Tree>,
5973+
map: HashMap<String, Tree>,
59735974
}
59745975

59755976
#[derive(ToSchema)]
@@ -5988,7 +5989,7 @@ fn test_named_and_enum_container_recursion_compiles() {
59885989
right: Box<Recursion>,
59895990
},
59905991
#[schema(no_recursion)]
5991-
Unnamed(Box<Recursion>),
5992+
Unnamed(HashMap<String, Recursion>),
59925993
NoValue,
59935994
}
59945995

0 commit comments

Comments
 (0)