implement ArraySchema

This commit is contained in:
Dietmar Maurer 2018-11-23 12:05:55 +01:00
parent 7edeec7b06
commit 8a41cfdd55
1 changed files with 20 additions and 0 deletions

View File

@ -155,6 +155,20 @@ pub struct ArraySchema {
pub items: Arc<Schema>, pub items: Arc<Schema>,
} }
impl ArraySchema {
pub fn new(description: &'static str, item_schema: Arc<Schema>) -> Self {
ArraySchema {
description: description,
items: item_schema,
}
}
pub fn arc(self) -> Arc<Schema> {
Arc::new(self.into())
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct ObjectSchema { pub struct ObjectSchema {
pub description: &'static str, pub description: &'static str,
@ -227,6 +241,12 @@ impl From<ObjectSchema> for Schema {
} }
} }
impl From<ArraySchema> for Schema {
fn from(array_schema: ArraySchema) -> Self {
Schema::Array(array_schema)
}
}
pub enum ApiStringFormat { pub enum ApiStringFormat {
Enum(Vec<String>), Enum(Vec<String>),
Pattern(Box<Regex>), Pattern(Box<Regex>),