Expand description
§schemastore
Parse and match files against the SchemaStore catalog.
SchemaStore is a community-maintained collection of JSON Schema definitions for common configuration files. This crate deserializes the catalog and matches file paths to their corresponding schemas using the fileMatch glob patterns.
§Usage
use schemastore::{parse_catalog, CompiledCatalog, CATALOG_URL};
// Fetch the catalog JSON yourself (using reqwest, ureq, etc.)
// let json = reqwest::blocking::get(CATALOG_URL)?.text()?;
// let value: serde_json::Value = serde_json::from_str(&json)?;
// let catalog = parse_catalog(value)?;
// Example with inline data:
let value = serde_json::json!({
"version": 1,
"schemas": [{
"name": "TypeScript",
"description": "TypeScript compiler configuration",
"url": "https://json.schemastore.org/tsconfig.json",
"fileMatch": ["tsconfig.json"]
}]
});
let catalog = parse_catalog(value).unwrap();
let compiled = CompiledCatalog::compile(&catalog);
assert!(compiled.find_schema("tsconfig.json", "tsconfig.json").is_some());§API
CATALOG_URL— the well-known URL for theSchemaStorecatalog JSONparse_catalog(Value)— deserialize the catalog from aserde_json::ValueCompiledCatalog::compile(&Catalog)— pre-compile allfileMatchglobsCompiledCatalog::find_schema(path, file_name)— look up the schema URL for a file path
Catalog types (Catalog, SchemaEntry, etc.) live in the schema-catalog crate.
Bare filename patterns (e.g. tsconfig.json) are automatically expanded to also match nested paths (**/tsconfig.json). Negation patterns (starting with !) are skipped.
§Design
This crate is #![no_std] — it only depends on alloc, serde, serde_json, and glob-match. No HTTP client is included; callers fetch the catalog JSON themselves.
§License
Apache-2.0
Structs§
- Compiled
Catalog - Compiled catalog for fast filename matching.
- Schema
Match - Information about how a schema was matched from a catalog.
Constants§
- CATALOG_
URL - The URL of the
SchemaStorecatalog.
Functions§
- parse_
catalog - Parse a
SchemaStorecatalog from aserde_json::Value.