Skip to content

Commit

Permalink
Merge pull request #2 from juhaku/schema-model-impl
Browse files Browse the repository at this point in the history
added initial schema implementation
  • Loading branch information
juhaku authored Oct 29, 2021
2 parents 35911c2 + 0e2f1af commit be50d6b
Show file tree
Hide file tree
Showing 2 changed files with 382 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/openapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use self::{
info::Info,
licence::Licence,
path::{PathItem, PathItemType, Paths},
schema::Schema,
security::Security,
server::Server,
tag::Tag,
Expand All @@ -22,6 +23,7 @@ pub mod licence;
pub mod path;
pub mod request_body;
pub mod response;
pub mod schema;
pub mod security;
pub mod server;
pub mod tag;
Expand All @@ -40,9 +42,9 @@ pub struct OpenApi {
pub servers: Option<Vec<Server>>,

pub paths: BTreeMap<String, PathItem>,
// TODO

#[serde(skip_serializing_if = "Option::is_none")]
pub components: Option<Vec<String>>,
pub components: Option<Schema>,

#[serde(skip_serializing_if = "Option::is_none")]
pub security: Option<Vec<Security>>,
Expand All @@ -69,6 +71,12 @@ impl OpenApi {
self
}

pub fn with_components(mut self, schema: Schema) -> Self {
self.components = Some(schema);

self
}

pub fn to_json(&self) -> Result<String, Error> {
serde_json::to_string(self).map_err(Error::Serde)
}
Expand Down
Loading

0 comments on commit be50d6b

Please sign in to comment.