Expand description
§schema-catalog
Types for the JSON Schema catalog format (schema-catalog.json), compatible with SchemaStore.
Part of the Lintel project.
§Usage
use schema_catalog::{Catalog, parse_catalog};
let json = r#"{"version":1,"schemas":[{"name":"Example","description":"An example schema","url":"https://example.com/schema.json","fileMatch":["*.example.json"]}]}"#;
let catalog: Catalog = parse_catalog(json).unwrap();
assert_eq!(catalog.schemas[0].name, "Example");§API
Catalog/SchemaEntry— serde types for the catalog formatparse_catalog(json)— deserialize a catalog from a JSON stringparse_catalog_value(value)— deserialize from aserde_json::Valueschema()— generate the JSON Schema for theCatalogtypeCompiledCatalog::compile(&Catalog)— pre-compile allfileMatchglobs into a fast matcherCompiledCatalog::find_schema(path, file_name)— look up the schema URL for a file pathCompiledCatalog::find_schema_detailed(path, file_name)— look up with full match details
Bare filename patterns (e.g. tsconfig.json) are automatically expanded to also match nested paths (**/tsconfig.json). Negation patterns (starting with !) are skipped.
§Design
CompiledCatalog uses a single GlobMap from the glob-set crate. The GlobMap’s MatchEngine automatically dispatches each pattern to the fastest strategy (literal hash, extension hash, prefix/suffix tries, Aho-Corasick pre-filter).
This crate is #![no_std] — it only depends on alloc, serde, serde_json, schemars, and glob-set.
§License
Apache-2.0
Structs§
- Catalog
- Schema catalog index that maps file patterns to JSON Schema URLs.
- Catalog
Group - A group of related schemas in the catalog.
- Compiled
Catalog - Compiled catalog for fast filename matching.
- Schema
Entry - A single schema entry in the catalog.
- Schema
Match - Information about how a schema was matched from a catalog.
Constants§
- DEFAULT_
SCHEMA_ URL - The default
$schemaURL for Lintel catalogs.
Functions§
- parse_
catalog - Parse a catalog from a JSON string.
- parse_
catalog_ value - Parse a catalog from a
serde_json::Value. - schema
- Generate the JSON Schema for the
Catalogtype.