1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
5pub struct CachedSpec {
6 pub cache_format_version: u32,
8 pub name: String,
9 pub version: String,
10 pub commands: Vec<CachedCommand>,
11 pub base_url: Option<String>,
13 pub servers: Vec<String>,
15 pub security_schemes: HashMap<String, CachedSecurityScheme>,
17 #[serde(default)]
19 pub skipped_endpoints: Vec<SkippedEndpoint>,
20 #[serde(default)]
22 pub server_variables: HashMap<String, ServerVariable>,
23}
24
25impl CachedSpec {
26 #[cfg(test)]
28 pub fn new_for_test(name: &str) -> Self {
29 Self {
30 cache_format_version: CACHE_FORMAT_VERSION,
31 name: name.to_string(),
32 version: "1.0.0".to_string(),
33 commands: vec![],
34 base_url: None,
35 servers: vec![],
36 security_schemes: HashMap::new(),
37 skipped_endpoints: vec![],
38 server_variables: HashMap::new(),
39 }
40 }
41}
42
43#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
45pub struct SkippedEndpoint {
46 pub path: String,
47 pub method: String,
48 pub content_type: String,
49 pub reason: String,
50}
51
52pub const CACHE_FORMAT_VERSION: u32 = 3;
57
58#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
60pub struct GlobalCacheMetadata {
61 pub cache_format_version: u32,
63 pub specs: std::collections::HashMap<String, SpecMetadata>,
65}
66
67#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
69pub struct SpecMetadata {
70 pub updated_at: String, pub file_size: u64,
74}
75
76impl Default for GlobalCacheMetadata {
77 fn default() -> Self {
78 Self {
79 cache_format_version: CACHE_FORMAT_VERSION,
80 specs: std::collections::HashMap::new(),
81 }
82 }
83}
84
85#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
86pub struct CachedCommand {
87 pub name: String,
88 pub description: Option<String>,
89 pub summary: Option<String>,
90 pub operation_id: String,
91 pub method: String,
92 pub path: String,
93 pub parameters: Vec<CachedParameter>,
94 pub request_body: Option<CachedRequestBody>,
95 pub responses: Vec<CachedResponse>,
96 pub security_requirements: Vec<String>,
98 pub tags: Vec<String>,
100 pub deprecated: bool,
102 pub external_docs_url: Option<String>,
104}
105
106#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
107pub struct CachedParameter {
108 pub name: String,
109 pub location: String,
110 pub required: bool,
111 pub description: Option<String>,
112 pub schema: Option<String>,
113 pub schema_type: Option<String>,
114 pub format: Option<String>,
115 pub default_value: Option<String>,
116 pub enum_values: Vec<String>,
117 pub example: Option<String>,
118}
119
120#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
121pub struct CachedRequestBody {
122 pub content_type: String,
123 pub schema: String,
124 pub required: bool,
125 pub description: Option<String>,
126 pub example: Option<String>,
127}
128
129#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
130pub struct CachedResponse {
131 pub status_code: String,
132 pub description: Option<String>,
133 pub content_type: Option<String>,
134 pub schema: Option<String>,
135}
136
137#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
139pub struct CachedSecurityScheme {
140 pub name: String,
142 pub scheme_type: String,
144 pub scheme: Option<String>,
146 pub location: Option<String>,
148 pub parameter_name: Option<String>,
150 pub description: Option<String>,
152 pub bearer_format: Option<String>,
154 pub aperture_secret: Option<CachedApertureSecret>,
156}
157
158#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
160pub struct CachedApertureSecret {
161 pub source: String,
163 pub name: String,
165}
166
167#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
169pub struct ServerVariable {
170 pub default: Option<String>,
172 pub enum_values: Vec<String>,
174 pub description: Option<String>,
176}