openapi_merge/input/
operation.rs

1use super::*;
2
3#[derive(Debug, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct OperationSelection {
6    pub include_tags: Option<Vec<String>>,
7    pub exclude_tags: Option<Vec<String>>,
8}
9
10impl OperationSelection {
11    pub fn filter_operation(&self, operation: &openapiv3::Operation) -> bool {
12        if let Some(exclude) = &self.exclude_tags {
13            if exclude.iter().any(|tag| operation.tags.contains(tag)) {
14                tracing::debug!(
15                    "Dropping {:?} because it is in exclude list",
16                    operation.summary
17                );
18                return false;
19            }
20        }
21
22        if let Some(include) = &self.include_tags {
23            if include.iter().any(|tag| operation.tags.contains(tag)) {
24                return true;
25            } else {
26                tracing::debug!(
27                    "Dropping {:?} because it is NOT in include list",
28                    operation.summary
29                );
30                return false;
31            }
32        }
33
34        true
35    }
36}