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}
18
19pub const CACHE_FORMAT_VERSION: u32 = 1;
21
22#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
24pub struct GlobalCacheMetadata {
25 pub cache_format_version: u32,
27 pub specs: std::collections::HashMap<String, SpecMetadata>,
29}
30
31#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
33pub struct SpecMetadata {
34 pub updated_at: String, pub file_size: u64,
38}
39
40impl Default for GlobalCacheMetadata {
41 fn default() -> Self {
42 Self {
43 cache_format_version: CACHE_FORMAT_VERSION,
44 specs: std::collections::HashMap::new(),
45 }
46 }
47}
48
49#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
50pub struct CachedCommand {
51 pub name: String,
52 pub description: Option<String>,
53 pub summary: Option<String>,
54 pub operation_id: String,
55 pub method: String,
56 pub path: String,
57 pub parameters: Vec<CachedParameter>,
58 pub request_body: Option<CachedRequestBody>,
59 pub responses: Vec<CachedResponse>,
60 pub security_requirements: Vec<String>,
62 pub tags: Vec<String>,
64 pub deprecated: bool,
66 pub external_docs_url: Option<String>,
68}
69
70#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
71pub struct CachedParameter {
72 pub name: String,
73 pub location: String,
74 pub required: bool,
75 pub description: Option<String>,
76 pub schema: Option<String>,
77 pub schema_type: Option<String>,
78 pub format: Option<String>,
79 pub default_value: Option<String>,
80 pub enum_values: Vec<String>,
81 pub example: Option<String>,
82}
83
84#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
85pub struct CachedRequestBody {
86 pub content_type: String,
87 pub schema: String,
88 pub required: bool,
89 pub description: Option<String>,
90 pub example: Option<String>,
91}
92
93#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
94pub struct CachedResponse {
95 pub status_code: String,
96 pub description: Option<String>,
97 pub content_type: Option<String>,
98 pub schema: Option<String>,
99}
100
101#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
103pub struct CachedSecurityScheme {
104 pub name: String,
106 pub scheme_type: String,
108 pub scheme: Option<String>,
110 pub location: Option<String>,
112 pub parameter_name: Option<String>,
114 pub description: Option<String>,
116 pub bearer_format: Option<String>,
118 pub aperture_secret: Option<CachedApertureSecret>,
120}
121
122#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
124pub struct CachedApertureSecret {
125 pub source: String,
127 pub name: String,
129}