1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use super::*;

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OperationSelection {
    pub include_tags: Option<Vec<String>>,
    pub exclude_tags: Option<Vec<String>>,
}

impl OperationSelection {
    pub fn filter_operation(&self, operation: &openapiv3::Operation) -> bool {
        if let Some(exclude) = &self.exclude_tags {
            if exclude.iter().any(|tag| operation.tags.contains(tag)) {
                tracing::debug!(
                    "Dropping {:?} because it is in exclude list",
                    operation.summary
                );
                return false;
            }
        }

        if let Some(include) = &self.include_tags {
            if include.iter().any(|tag| operation.tags.contains(tag)) {
                return true;
            } else {
                tracing::debug!(
                    "Dropping {:?} because it is NOT in include list",
                    operation.summary
                );
                return false;
            }
        }

        true
    }
}