restify_openapi/
definition_holder.rs

1use indexmap::IndexMap;
2
3use crate::{
4  paths::{Operation, OperationType, PathItem},
5  Components,
6};
7
8pub trait DefinitionHolder {
9  fn path(&self) -> &str;
10  fn operations(&mut self) -> IndexMap<OperationType, Operation>;
11  fn components(&mut self) -> Vec<Components>;
12  fn update_path_items(&mut self, path_op_map: &mut IndexMap<String, PathItem>) {
13    let ops = self.operations();
14    if !ops.is_empty() {
15      let op_map = path_op_map.entry(self.path().into()).or_default();
16      op_map.operations.extend(ops);
17    }
18  }
19}