Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added initial schema implementation #2

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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