Skip to main content

jsonschema_schema/
lib.rs

1#![doc = include_str!("../README.md")]
2
3extern crate alloc;
4
5pub(crate) mod absolute;
6pub mod extensions;
7pub(crate) mod flatten;
8mod schema;
9pub(crate) mod validate;
10
11pub use extensions::{
12    EnumValueMeta, ExtDocs, ExtLinks, IntellijSchemaExt, LintelSchemaExt, TaploInfoSchemaExt,
13    TaploSchemaExt, TombiSchemaExt,
14};
15pub use schema::{
16    Schema, SchemaValue, SimpleType, TypeValue, navigate_pointer, ref_name, resolve_ref,
17    vocabularies::{
18        ApplicatorVocabulary, ContentVocabulary, CoreVocabulary, FormatAnnotationVocabulary,
19        MetaDataVocabulary, UnevaluatedVocabulary, ValidationVocabulary,
20    },
21};
22pub use validate::SchemaError;
23
24/// Generate the JSON Schema for [`SchemaValue`] (a JSON Schema 2020-12
25/// document).
26///
27/// # Panics
28///
29/// Panics if the generated schema cannot be serialized to
30/// `serde_json::Value` (should never happen in practice).
31pub fn schema() -> serde_json::Value {
32    serde_json::to_value(schemars::schema_for!(SchemaValue))
33        .expect("schema serialization cannot fail")
34}