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}
21
22#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
24pub struct SkippedEndpoint {
25 pub path: String,
26 pub method: String,
27 pub content_type: String,
28 pub reason: String,
29}
30
31pub const CACHE_FORMAT_VERSION: u32 = 2;
34
35#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
37pub struct GlobalCacheMetadata {
38 pub cache_format_version: u32,
40 pub specs: std::collections::HashMap<String, SpecMetadata>,
42}
43
44#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
46pub struct SpecMetadata {
47 pub updated_at: String, pub file_size: u64,
51}
52
53impl Default for GlobalCacheMetadata {
54 fn default() -> Self {
55 Self {
56 cache_format_version: CACHE_FORMAT_VERSION,
57 specs: std::collections::HashMap::new(),
58 }
59 }
60}
61
62#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
63pub struct CachedCommand {
64 pub name: String,
65 pub description: Option<String>,
66 pub summary: Option<String>,
67 pub operation_id: String,
68 pub method: String,
69 pub path: String,
70 pub parameters: Vec<CachedParameter>,
71 pub request_body: Option<CachedRequestBody>,
72 pub responses: Vec<CachedResponse>,
73 pub security_requirements: Vec<String>,
75 pub tags: Vec<String>,
77 pub deprecated: bool,
79 pub external_docs_url: Option<String>,
81}
82
83#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
84pub struct CachedParameter {
85 pub name: String,
86 pub location: String,
87 pub required: bool,
88 pub description: Option<String>,
89 pub schema: Option<String>,
90 pub schema_type: Option<String>,
91 pub format: Option<String>,
92 pub default_value: Option<String>,
93 pub enum_values: Vec<String>,
94 pub example: Option<String>,
95}
96
97#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
98pub struct CachedRequestBody {
99 pub content_type: String,
100 pub schema: String,
101 pub required: bool,
102 pub description: Option<String>,
103 pub example: Option<String>,
104}
105
106#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
107pub struct CachedResponse {
108 pub status_code: String,
109 pub description: Option<String>,
110 pub content_type: Option<String>,
111 pub schema: Option<String>,
112}
113
114#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
116pub struct CachedSecurityScheme {
117 pub name: String,
119 pub scheme_type: String,
121 pub scheme: Option<String>,
123 pub location: Option<String>,
125 pub parameter_name: Option<String>,
127 pub description: Option<String>,
129 pub bearer_format: Option<String>,
131 pub aperture_secret: Option<CachedApertureSecret>,
133}
134
135#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
137pub struct CachedApertureSecret {
138 pub source: String,
140 pub name: String,
142}