aperture_cli/spec/
mod.rs

1//! `OpenAPI` specification validation and transformation module
2//!
3//! This module separates the concerns of validating and transforming `OpenAPI` specifications
4//! into distinct, testable components following the Single Responsibility Principle.
5
6pub mod transformer;
7pub mod validator;
8
9pub use transformer::SpecTransformer;
10pub use validator::SpecValidator;
11
12use openapiv3::{Operation, PathItem};
13
14/// A helper type to iterate over all HTTP methods in a `PathItem`
15pub type HttpMethodsIter<'a> = [(&'static str, &'a Option<Operation>); 8];
16
17/// Creates an iterator over all HTTP methods and their operations in a `PathItem`
18///
19/// # Arguments
20/// * `item` - The `PathItem` to extract operations from
21///
22/// # Returns
23/// An array of tuples containing the HTTP method name and its optional operation
24#[must_use]
25pub const fn http_methods_iter(item: &PathItem) -> HttpMethodsIter<'_> {
26    [
27        ("GET", &item.get),
28        ("POST", &item.post),
29        ("PUT", &item.put),
30        ("DELETE", &item.delete),
31        ("PATCH", &item.patch),
32        ("HEAD", &item.head),
33        ("OPTIONS", &item.options),
34        ("TRACE", &item.trace),
35    ]
36}