bump_api/
model.rs

1use serde::{Serialize, Deserialize};
2#[derive(Debug, Serialize, Deserialize, Default)]
3pub struct Hub {
4    ///The name of the Hub
5    pub name: Option<String>,
6    ///The description of the Hub
7    pub description: Option<String>,
8    ///The public URL of the hub
9    pub url: Option<String>,
10    ///Creation date of this Hub
11    pub created: Option<serde_json::Value>,
12    ///Last udpate date of this Hub
13    pub modified: Option<serde_json::Value>,
14    ///The list of APIs belonging to this Hub
15    pub apis: Option<Vec<Api>>,
16}
17impl std::fmt::Display for Hub {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
19        write!(f, "{}", serde_json::to_string(self).unwrap())
20    }
21}
22#[derive(Debug, Serialize, Deserialize, Default)]
23pub struct Api {
24    ///UUID of this API
25    pub id: Option<String>,
26    ///Name of this API
27    pub name: Option<String>,
28    ///Description of this API from the latest definition
29    pub description: Option<String>,
30    ///Slug of this API
31    pub slug: Option<String>,
32    ///public documentation URL
33    pub url: Option<String>,
34    ///Version of this API taken from the latest definition
35    pub version: Option<String>,
36    ///Extra properties attached to this API
37    pub properties: Option<Vec<serde_json::Value>>,
38    ///Creation date of this API
39    pub created: Option<serde_json::Value>,
40    ///Last udpate date of this API
41    pub modified: Option<serde_json::Value>,
42}
43impl std::fmt::Display for Api {
44    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
45        write!(f, "{}", serde_json::to_string(self).unwrap())
46    }
47}
48#[derive(Debug, Serialize, Deserialize, Default)]
49pub struct Reference {
50    ///Location of the external reference as it's called from `definition`, without the relative path (the part after `#/`). Can be an URL of a file system path.
51    pub location: Option<String>,
52    ///Content of the external reference, as a string.
53    pub content: Option<String>,
54}
55impl std::fmt::Display for Reference {
56    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
57        write!(f, "{}", serde_json::to_string(self).unwrap())
58    }
59}
60#[derive(Debug, Serialize, Deserialize, Default)]
61pub struct Error {
62    ///Human readable error message.
63    pub message: Option<String>,
64    ///Hash of invalid attributes with their error messages.
65    pub errors: Option<serde_json::Value>,
66}
67impl std::fmt::Display for Error {
68    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
69        write!(f, "{}", serde_json::to_string(self).unwrap())
70    }
71}
72#[derive(Debug, Serialize, Deserialize, Default)]
73pub struct Pong {
74    ///Sentence about ping and pong
75    pub pong: Option<String>,
76}
77impl std::fmt::Display for Pong {
78    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
79        write!(f, "{}", serde_json::to_string(self).unwrap())
80    }
81}
82#[derive(Debug, Serialize, Deserialize, Default)]
83pub struct Preview {
84    ///Unique id for the preview URL: `https://bump.sh/preview/:id`.
85    pub id: Option<String>,
86    ///Preview expiration date and time.
87    pub expires_at: Option<String>,
88    ///The public URL where the preview will be visible.
89    pub public_url: Option<String>,
90}
91impl std::fmt::Display for Preview {
92    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
93        write!(f, "{}", serde_json::to_string(self).unwrap())
94    }
95}
96#[derive(Debug, Serialize, Deserialize, Default)]
97pub struct Version {
98    ///Unique id of your version.
99    pub id: Option<String>,
100    ///Unique id of your documentation.
101    pub doc_id: Option<String>,
102    ///The public URL of your documentation.
103    pub doc_public_url: Option<String>,
104}
105impl std::fmt::Display for Version {
106    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
107        write!(f, "{}", serde_json::to_string(self).unwrap())
108    }
109}
110#[derive(Debug, Serialize, Deserialize, Default)]
111pub struct WithDiff {
112    ///Details of each change as a list of diff items
113    pub diff_details: Option<Vec<DiffItem>>,
114    ///The comparaison diff summary in markdown format
115    pub diff_markdown: Option<String>,
116    ///The comparaison diff summary
117    pub diff_summary: Option<String>,
118    ///The public URL of your diff
119    pub diff_public_url: Option<String>,
120    ///Identifies if the diff includes breaking changes
121    pub diff_breaking: Option<bool>,
122}
123impl std::fmt::Display for WithDiff {
124    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
125        write!(f, "{}", serde_json::to_string(self).unwrap())
126    }
127}
128#[derive(Debug, Serialize, Deserialize, Default)]
129pub struct Diff {
130    ///Unique id of your diff
131    pub id: Option<String>,
132    ///The title of the last parsed definition
133    pub title: Option<String>,
134    ///The public URL of your diff
135    pub public_url: Option<String>,
136    ///Identifies if the diff includes breaking changes
137    pub breaking: Option<bool>,
138    ///Details of each change as a list of diff items
139    pub details: Option<Vec<DiffItem>>,
140    ///URL of previous version specification, in JSON format
141    pub previous_version_url: Option<String>,
142    ///URL of current version specification, in JSON format
143    pub current_version_url: Option<String>,
144}
145impl std::fmt::Display for Diff {
146    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
147        write!(f, "{}", serde_json::to_string(self).unwrap())
148    }
149}
150#[derive(Debug, Serialize, Deserialize, Default)]
151pub struct DiffItem {
152    ///The identifier of the diff change
153    pub id: Option<String>,
154    ///The human name of diff change
155    pub name: Option<String>,
156    pub status: Option<String>,
157    #[serde(rename = "type")]
158    ///The object type of the diff change
159    pub type_: Option<String>,
160    ///Identifies if the item is a breaking change
161    pub breaking: Option<bool>,
162    ///A list of children item changes
163    pub children: Option<Vec<DiffItem>>,
164}
165impl std::fmt::Display for DiffItem {
166    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
167        write!(f, "{}", serde_json::to_string(self).unwrap())
168    }
169}
170#[derive(Debug, Serialize, Deserialize)]
171pub struct DiffForApi(pub Diff, serde_json::Value);
172#[derive(Debug, Serialize, Deserialize, Default)]
173pub struct DocumentationRequest {
174    ///UUID or slug of the documentation.
175    pub documentation: String,
176    ///UUID or slug of the hub if the documentation is part of a hub.
177    pub hub: Option<String>,
178    ///Name of the documentation to create. Used only if `auto_create_documentation` is set.
179    pub documentation_name: Option<String>,
180    ///Create the documentation if it does not exist yet. Must be used with a `hub` and a `documentation`.
181    pub auto_create_documentation: Option<bool>,
182}
183impl std::fmt::Display for DocumentationRequest {
184    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
185        write!(f, "{}", serde_json::to_string(self).unwrap())
186    }
187}
188#[derive(Debug, Serialize, Deserialize, Default)]
189pub struct Validation {
190    ///Specification of the given definition as a path: `speficiation_name/specification_version/format`.
191    pub specification: Option<String>,
192}
193impl std::fmt::Display for Validation {
194    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
195        write!(f, "{}", serde_json::to_string(self).unwrap())
196    }
197}
198#[derive(Debug, Serialize, Deserialize, Default)]
199pub struct VersionRequest {
200    /**Serialized definition of the version. This should be an OpenAPI 2.x, 3.x or AsyncAPI 2.x file serialized as a string, in YAML or JSON.
201*/
202    pub definition: String,
203    ///Import external references used by `definition`. It's usually resources not accessible by Bump servers, like local files or internal URLs.
204    pub references: Option<Vec<Reference>>,
205    /**Select a branch for this new version (branch will be created if it doesn't exist).
206
207*Defaults to the main branch*.
208*/
209    pub branch_name: Option<String>,
210}
211impl std::fmt::Display for VersionRequest {
212    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
213        write!(f, "{}", serde_json::to_string(self).unwrap())
214    }
215}
216#[derive(Debug, Serialize, Deserialize, Default)]
217pub struct PreviewRequest {
218    /****Required** if [`definition`](#post-validations-definition) is not present.
219Target definition URL. It should be accessible through HTTP by Bump servers.
220*/
221    pub url: Option<String>,
222    /****Required** if [`url`](#post-validations-url) is not present.
223Serialized definition. This should be an OpenAPI 2.x, 3.x or AsyncAPI 2.x file
224serialized as a string, in YAML or JSON.
225*/
226    pub definition: Option<String>,
227    ///Import external references used by `definition`. It's usually resources not accessible by Bump servers, like local files or internal URLs.
228    pub references: Option<Vec<Reference>>,
229}
230impl std::fmt::Display for PreviewRequest {
231    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
232        write!(f, "{}", serde_json::to_string(self).unwrap())
233    }
234}
235#[derive(Debug, Serialize, Deserialize, Default)]
236pub struct DiffRequest {
237    /****Required** if `definition` is not present.
238Current definition URL. It should be accessible through HTTP by Bump servers.
239*/
240    pub url: Option<String>,
241    /****Required** if `definition` is not present.
242Previous definition URL. It should be accessible through HTTP by Bump servers.
243*/
244    pub previous_url: Option<String>,
245    /****Required** if `url` is not present.
246Serialized definition of the previous version. This should be an OpenAPI 2.x, 3.x or AsyncAPI 2.x file
247serialized as a string, in YAML or JSON.
248*/
249    pub previous_definition: Option<String>,
250    ///Import external references used by `previous_definition`. It's usually resources not accessible by Bump servers, like local files or internal URLs.
251    pub previous_references: Option<Vec<Reference>>,
252    /****Required** if `url` is not present.
253Serialized definition of the current version. This should be an OpenAPI 2.x, 3.x or AsyncAPI 2.x file
254serialized as a string, in YAML or JSON.
255*/
256    pub definition: Option<String>,
257    ///Import external references used by `definition`. It's usually resources not accessible by Bump servers, like local files or internal URLs.
258    pub references: Option<Vec<Reference>>,
259    ///Public change expiration date and time. After this date, this documentation change will be destroyed.
260    pub expires_at: Option<String>,
261}
262impl std::fmt::Display for DiffRequest {
263    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
264        write!(f, "{}", serde_json::to_string(self).unwrap())
265    }
266}