aperture_cli/cache/
models.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
5pub struct CachedSpec {
6    pub name: String,
7    pub version: String,
8    pub commands: Vec<CachedCommand>,
9    /// Base URL extracted from the first server in the `OpenAPI` spec
10    pub base_url: Option<String>,
11    /// All server URLs from the `OpenAPI` spec for future multi-environment support
12    pub servers: Vec<String>,
13    /// Security schemes defined in the `OpenAPI` spec with `x-aperture-secret` mappings
14    pub security_schemes: HashMap<String, CachedSecurityScheme>,
15}
16
17#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
18pub struct CachedCommand {
19    pub name: String,
20    pub description: Option<String>,
21    pub summary: Option<String>,
22    pub operation_id: String,
23    pub method: String,
24    pub path: String,
25    pub parameters: Vec<CachedParameter>,
26    pub request_body: Option<CachedRequestBody>,
27    pub responses: Vec<CachedResponse>,
28    /// Security requirements for this operation (references to security scheme names)
29    pub security_requirements: Vec<String>,
30    /// All tags associated with this operation
31    pub tags: Vec<String>,
32    /// Whether this operation is deprecated
33    pub deprecated: bool,
34    /// External documentation URL if available
35    pub external_docs_url: Option<String>,
36}
37
38#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
39pub struct CachedParameter {
40    pub name: String,
41    pub location: String,
42    pub required: bool,
43    pub description: Option<String>,
44    pub schema: Option<String>,
45    pub schema_type: Option<String>,
46    pub format: Option<String>,
47    pub default_value: Option<String>,
48    pub enum_values: Vec<String>,
49    pub example: Option<String>,
50}
51
52#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
53pub struct CachedRequestBody {
54    pub content_type: String,
55    pub schema: String,
56    pub required: bool,
57    pub description: Option<String>,
58    pub example: Option<String>,
59}
60
61#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
62pub struct CachedResponse {
63    pub status_code: String,
64    pub description: Option<String>,
65    pub content_type: Option<String>,
66    pub schema: Option<String>,
67}
68
69/// Cached representation of a security scheme with x-aperture-secret mapping
70#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
71pub struct CachedSecurityScheme {
72    /// Security scheme name from the `OpenAPI` spec
73    pub name: String,
74    /// Type of security scheme (apiKey, http, oauth2, etc.)
75    pub scheme_type: String,
76    /// Subtype for http schemes (bearer, basic, etc.)
77    pub scheme: Option<String>,
78    /// Location for apiKey schemes (header, query, cookie)
79    pub location: Option<String>,
80    /// Parameter name for apiKey schemes (e.g., "Authorization", "X-API-Key")
81    pub parameter_name: Option<String>,
82    /// Description of the security scheme from `OpenAPI` spec
83    pub description: Option<String>,
84    /// Bearer format for HTTP bearer schemes (e.g., "JWT")
85    pub bearer_format: Option<String>,
86    /// x-aperture-secret mapping for environment variable resolution
87    pub aperture_secret: Option<CachedApertureSecret>,
88}
89
90/// Cached representation of x-aperture-secret extension
91#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
92pub struct CachedApertureSecret {
93    /// Source of the secret (currently only "env" supported)
94    pub source: String,
95    /// Environment variable name to read the secret from
96    pub name: String,
97}