Skip to content

Commit e32b642

Browse files
committed
Allow ignoring paths in client gen
1 parent 412550c commit e32b642

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub fn gen(
7070
overwrite_cargo: bool,
7171
disable_clippy: bool,
7272
mapping: &[(&str, &str)],
73+
ignored_paths: &[&str],
7374
) -> Result<()> {
7475
let mapping: HashMap<&str, &str> = HashMap::from_iter(mapping.iter().cloned());
7576

@@ -90,7 +91,14 @@ pub fn gen(
9091
let modules: Result<Vec<Module>> = open_api
9192
.tags
9293
.iter()
93-
.map(|tag| rust::client_gen::client_gen(&open_api, Some(tag.clone()), &mut ref_cache))
94+
.map(|tag| {
95+
rust::client_gen::client_gen(
96+
&open_api,
97+
Some(tag.clone()),
98+
&mut ref_cache,
99+
&ignored_paths,
100+
)
101+
})
94102
.collect();
95103

96104
let mut api_module_defs = Vec::new();

src/rust/client_gen.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,11 +1072,17 @@ pub fn client_gen(
10721072
open_api: &OpenAPI,
10731073
tag: Option<Tag>,
10741074
ref_cache: &mut RefCache,
1075+
ignored_paths: &[&str],
10751076
) -> Result<Module> {
1077+
let ignored_paths: HashSet<String> =
1078+
HashSet::from_iter(ignored_paths.iter().map(|ip| ip.to_string()));
1079+
10761080
let paths: HashSet<String> = open_api
10771081
.paths
10781082
.iter()
1079-
.filter(|(_, path_item)| match_tag(&tag, path_item))
1083+
.filter(|(path_key, path_item)| {
1084+
!ignored_paths.contains(*path_key) && match_tag(&tag, path_item)
1085+
})
10801086
.map(|(p, _)| p.clone())
10811087
.collect();
10821088

0 commit comments

Comments
 (0)