Skip to content

Commit

Permalink
rewrite start in "new-oas"
Browse files Browse the repository at this point in the history
  • Loading branch information
RazMag committed Oct 31, 2023
1 parent 16aea8a commit eb79464
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions cherrybomb-oas/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod legacy;
mod new_oas;

#[cfg(test)]
mod tests {
Expand Down
25 changes: 25 additions & 0 deletions cherrybomb-oas/src/new_oas/info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct Info {
pub title: String,
pub description: Option<String>,
#[serde(rename = "termsOfService")]
pub tos: Option<String>,
pub contact: Option<Contact>,
pub license: Option<License>,
pub version: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct Contact {
pub name: Option<String>,
pub url: Option<String>,
pub email: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct License {
pub name: String,
pub url: Option<String>,
}
3 changes: 3 additions & 0 deletions cherrybomb-oas/src/new_oas/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod info;
mod server;
mod paths;
11 changes: 11 additions & 0 deletions cherrybomb-oas/src/new_oas/paths.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Paths {
#[serde(flatten)]
pub paths: HashMap<String, PathItem>,
#[serde(flatten)]
pub extensions: HashMap<String, Value>,
}
19 changes: 19 additions & 0 deletions cherrybomb-oas/src/new_oas/server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct Server {
#[serde(rename(deserialize = "url"))]
pub base_url: String,
pub description: Option<String>,
pub variables: Option<HashMap<String, ServerVariable>>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct ServerVariable {
#[serde(rename = "enum")]
pub var_enum: Option<Vec<String>>,
pub default: String,
pub description: Option<String>,
}

0 comments on commit eb79464

Please sign in to comment.