Skip to content

Commit 36d1877

Browse files
committed
fix filter
1 parent f2275ee commit 36d1877

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/rust/client_gen.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,24 +1077,26 @@ pub fn client_gen(
10771077
let ignored_paths: HashSet<String> =
10781078
HashSet::from_iter(ignored_paths.iter().map(|ip| ip.to_string()));
10791079

1080-
let paths: HashSet<String> = open_api
1080+
let paths: HashMap<String, ReferenceOr<PathItem>> = open_api
10811081
.paths
10821082
.iter()
1083-
.filter(|(path_key, path_item)| {
1084-
println!("generating for path: {path_key}");
1085-
!ignored_paths.contains(*path_key) && match_tag(&tag, path_item)
1083+
.filter_map(|(path_key, path_item)| {
1084+
if !ignored_paths.contains(path_key) && match_tag(&tag, path_item) {
1085+
Some((path_key.clone(), path_item.clone()))
1086+
} else {
1087+
None
1088+
}
10861089
})
1087-
.map(|(p, _)| p.clone())
10881090
.collect();
10891091

1090-
let paths: Vec<Path> = paths.into_iter().map(|p| Path::from_string(&p)).collect();
1091-
1092-
let common_prefix = paths.into_iter().reduce(|acc, e| e.common_prefix(acc));
1092+
let common_prefix = paths
1093+
.iter()
1094+
.map(|(p, _)| Path::from_string(&p))
1095+
.reduce(|acc, e| e.common_prefix(acc));
10931096

10941097
let prefix_length = common_prefix.map(|p| p.0.len()).unwrap_or(0);
10951098

1096-
let operations: Vec<PathOperation> = open_api
1097-
.paths
1099+
let operations: Vec<PathOperation> = paths
10981100
.iter()
10991101
.flat_map(|(path, op)| tag_operations(&tag, path, op))
11001102
.collect();

0 commit comments

Comments
 (0)