schema-catalog
Types for the JSON Schema catalog format (schema-catalog.json), compatible with SchemaStore.
Part of the Lintel project.
Usage
use ;
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.unwrap;
assert_eq!;
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