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;
26mod provider_schema;
27pub mod schema;
28pub mod transform;
29mod transform_refs;
30pub mod validation;
31
32pub use dialect::SchemaDialect;
33pub use error::SchemaError;
34pub use ferrin_spec::error::JsonParseError;
35pub use ferrin_spec::error::TypeValidationContext;
36pub use ferrin_spec::error::TypeValidationError;
37pub use json::ParseLimits;
38pub use partial_json::PartialParse;
39pub use partial_json::PartialParseState;
40pub use schema::Schema;
41pub use schemars;
42pub use schemars::JsonSchema;
43pub use transform::SchemaTransform;
44pub use validation::ValidationIssue;
45pub use validation::ValidationIssues;