use crate::{Schemas, Validable, ValidationReport, schema};
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use url::Url;
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct RootSchema {
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
schema: Option<schema::common::draft::Draft>,
#[serde(flatten)]
object: schema::object::ObjectSchema,
#[serde(rename = "$vocabulary", skip_serializing_if = "Option::is_none")]
vocabulary: Option<IndexMap<Url, bool>>,
}
impl Validable for RootSchema {
fn validate(
&self,
instance: &Value,
state: &mut schema::common::state::State,
relative_schemas: &Schemas,
parent_id: Option<&schema::common::id::Id>,
) -> ValidationReport {
self.object
.validate(instance, state, relative_schemas, parent_id)
}
fn get_schemas(
&self,
parent_id: Option<&schema::common::id::Id>,
is_absolute: bool,
) -> Schemas {
self.object.get_schemas(parent_id, is_absolute)
}
}