Skip to content

Commit

Permalink
started to reorganize the structure of the open_api
Browse files Browse the repository at this point in the history
  • Loading branch information
RazMag committed Nov 8, 2023
1 parent 8b98d81 commit 7141638
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
7 changes: 7 additions & 0 deletions cherrybomb-oas/src/new_oas/external_docs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct ExternalDocs {
pub description: Option<String>,
pub url: String,
}
5 changes: 4 additions & 1 deletion cherrybomb-oas/src/new_oas/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mod info;
mod server;
mod paths;
mod paths;
mod open_api;
mod security;
mod external_docs;
18 changes: 18 additions & 0 deletions cherrybomb-oas/src/new_oas/open_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct OpenAPI {
pub openapi: String,
pub info: crate::new_oas::info::Info,
#[serde(rename = "jsonSchemaDialect")]
pub json_schema_dialect: Option<String>,
pub servers: Option<Vec<crate::new_oas::server::Server>>,
pub paths: Option<crate::new_oas::paths::Paths>,
pub webhooks: Option<HashMap<String,RelRef>>,
pub components: Option<crate::new_oas::components::Components>,
pub security: Option<Vec<crate::new_oas::security::Security>>,
pub tags: Option<Vec<crate::new_oas::tags::Tag>>,
pub external_docs: Option<crate::new_oas::external_docs::ExternalDocs>,
pub extensions: Option<HashMap<String, serde_json::Value>>,
}
26 changes: 17 additions & 9 deletions cherrybomb-oas/src/new_oas/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Operation {
pub summary: Option<String>,
pub description: Option<String>,
#[serde(rename = "externalDocs")]
pub external_docs: Option<ExternalDocs>,
pub external_docs: Option<crate::new_oas::external_docs::ExternalDocs>,
#[serde(rename = "operationId")]
pub operation_id: Option<String>,
pub parameters: Option<Vec<RelRef>>,
Expand All @@ -40,16 +40,10 @@ pub struct Operation {
pub responses: Option<Responses>,
pub callbacks: Option<HashMap<String, RelRef>>,
pub deprecated: Option<bool>,
pub security: Option<Vec<Security>>,
pub security: Option<Vec<crate::new_oas::security::Security>>,
pub servers: Option<Vec<crate::new_oas::server::Server>>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct ExternalDocs {
pub description: Option<String>,
pub url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct Parameter{
pub name: String,
Expand Down Expand Up @@ -84,4 +78,18 @@ pub struct Response {
pub headers: Option<HashMap<String, RelRef>>,
pub content: Option<HashMap<String, MediaType>>,
pub links: Option<HashMap<String, RelRef>>,
}
pub extensions: Option<HashMap<String, Value>>,
}



#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct MediaType {
pub schema: Option<Schema>,
pub example: Option<Value>,
pub examples: Option<HashMap<String, RelRef>>,
pub encoding: Option<HashMap<String, Encoding>>,
}



7 changes: 7 additions & 0 deletions cherrybomb-oas/src/new_oas/security.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct Security {
pub security: Option<HashMap<String, Vec<String>>>,
}

0 comments on commit 7141638

Please sign in to comment.