Skip to main content

json2md/
lib.rs

1//! Validate JSON with JSON Schema and render it as Markdown.
2//!
3//! A [`View`] compiles one schema and one template for repeated use. Every
4//! [`View::render`] validates its input before running the template.
5//!
6//! ```
7//! use json2md::View;
8//! use serde_json::json;
9//!
10//! let schema = json!({
11//!     "type": "object",
12//!     "properties": {"title": {"type": "string"}},
13//!     "required": ["title"]
14//! });
15//! let view = View::new(&schema, "# {{ title }}\n")?;
16//! assert_eq!(view.render(&json!({"title": "Release notes"}))?, "# Release notes\n");
17//! # Ok::<(), Box<dyn std::error::Error>>(())
18//! ```
19//!
20//! Templates use MiniJinja syntax. Missing values are strict and output has no
21//! automatic escaping. Callers own file I/O, Markdown escaping, and the trust
22//! policy for their schemas, templates, input, and output.
23
24mod context;
25mod error;
26mod schema;
27mod validation;
28mod view;
29
30pub use error::Error;
31pub use validation::{ValidationErrors, ValidationIssue};
32pub use view::View;