Skip to main content

ferrin_schema/
lib.rs

1//! Ferrin JSON Schema support.
2//!
3//! - [`Schema`]: a JSON Schema plus a typed validation function, created from
4//!   a Rust type (`schemars` derive + `serde` deserialization), from a raw JSON
5//!   Schema (validated with `jsonschema` when the `json-schema-validation`
6//!   feature is enabled) or from a custom validator.
7//! - [`SchemaDialect`]: draft-07 (default) or 2020-12 generation settings.
8//! - [`SchemaTransform`]: provider-oriented schema rewrites
9//!   (`additionalProperties: false`, OpenAI strict mode).
10//! - [`partial_json`]: repair and parse truncated JSON produced by streaming
11//!   models.
12//! - [`json`]: JSON parsing with size and depth limits.
13//!
14//! Design: `docs/01-architecture/08-structured-output.md`, ADR 0004.
15//!
16//! # Attribution
17//!
18//! Portions of this crate are derived from the Vercel AI SDK (Apache-2.0,
19//! Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and
20//! modified. See the `NOTICE` file in the crate root.
21
22pub mod dialect;
23mod error;
24pub mod json;
25pub mod partial_json;
26pub mod schema;
27pub mod transform;
28pub mod validation;
29
30pub use dialect::SchemaDialect;
31pub use error::SchemaError;
32pub use ferrin_spec::error::JsonParseError;
33pub use ferrin_spec::error::TypeValidationContext;
34pub use ferrin_spec::error::TypeValidationError;
35pub use json::ParseLimits;
36pub use partial_json::PartialParse;
37pub use partial_json::PartialParseState;
38pub use schema::Schema;
39pub use schemars;
40pub use schemars::JsonSchema;
41pub use transform::SchemaTransform;
42pub use validation::ValidationIssue;
43pub use validation::ValidationIssues;