use crate::analysis::{OperationInfo, SchemaAnalysis};
pub mod codegen;
pub mod edit;
pub mod list;
pub mod selector;
pub use selector::{Resolution, Selector, SelectorParseError, SelectorResolveError, resolve};
#[derive(Debug, Clone)]
pub struct OperationIndex {
operations: Vec<OperationSummary>,
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct OperationSummary {
pub operation_id: String,
pub method: String,
pub path: String,
pub tags: Vec<String>,
pub supports_streaming: bool,
}
impl OperationIndex {
pub fn from_analysis(analysis: &SchemaAnalysis) -> Self {
let operations = analysis
.operations
.values()
.map(OperationSummary::from)
.collect();
Self { operations }
}
pub fn from_summaries(operations: Vec<OperationSummary>) -> Self {
Self { operations }
}
pub fn operations(&self) -> &[OperationSummary] {
&self.operations
}
pub fn tag_count(&self) -> usize {
let mut tags: std::collections::BTreeSet<&str> = std::collections::BTreeSet::new();
for op in &self.operations {
for t in &op.tags {
tags.insert(t.as_str());
}
}
tags.len()
}
}
impl From<&OperationInfo> for OperationSummary {
fn from(op: &OperationInfo) -> Self {
Self {
operation_id: op.operation_id.clone(),
method: op.method.clone(),
path: op.path.clone(),
tags: op.tags.clone(),
supports_streaming: op.supports_streaming,
}
}
}