Expand description
The OATS (Open Annotation Task Schemas) JSON schemas for Rust.
OATS is a collection of strict, versioned JSON Schema 2020-12 schemas, defining and validating the structured outputs of machine learning models, workflow steps and annotation. Models, pipelines and people write the same JSON for each task, whatever produced it.
Every OATS release from 0.8.0 on is compiled into the crate, unchanged, so nothing touches the network or the filesystem. Schemas, documentation and the changelog live at oatschema.org.
use oatschema::{SchemaName, schema_json};
let text = schema_json(SchemaName::Classification, None)?;
assert!(text.contains(r#""$id": "https://oatschema.org/0.8.0/classification""#));
let name: SchemaName = "llm-output".parse()?;
let pinned = schema_json(name, Some("0.8.0"))?;
assert!(pinned.contains(r#""x-version": "0.8.0""#));§Features
serde_json: addsschema, which returns a schema as aserde_json::Value.
§Schema versions
Every lookup takes a version, which defaults to SCHEMA_VERSION. Versions must be exact,
such as "0.8.0"; "0.8" and "latest" are rejected. available_versions lists every
bundled version. Before 1.0.0, a schema version may reject records that an older one accepted,
so validate a record against the version it was written for.
Each schema states its own version in its x-version keyword, and its $id includes the
version (https://oatschema.org/0.8.0/classification), so versions can sit side by side in one
JSON Schema registry. Releases before 0.8.0 are not bundled here; the Python package
oatschema bundles them.
Enums§
- Error
- An unknown schema name or version.
- Schema
Name - The name of an OATS schema.
Constants§
- SCHEMA_
VERSION - The newest bundled schema version, used when no version is given.
Functions§
- available_
versions - Every bundled schema version, oldest first. The first is 0.8.0.
- schema
- Returns the schema
namefrom schema versionversion, or fromSCHEMA_VERSIONif it isNone, parsed into a newserde_json::Valueon every call. - schema_
json - Returns the schema
namefrom schema versionversion, or fromSCHEMA_VERSIONif it isNone, as the schema file’s text exactly as released.