Skip to main content

lintel_validate/
catalog.rs

1use lintel_schema_cache::SchemaCache;
2use schema_catalog::Catalog;
3
4/// The URL of the `SchemaStore` catalog.
5pub const SCHEMASTORE_CATALOG_URL: &str = "https://www.schemastore.org/api/json/catalog.json";
6
7/// Fetch the `SchemaStore` catalog via the schema cache.
8///
9/// # Errors
10///
11/// Returns an error if the catalog cannot be fetched or parsed.
12pub async fn fetch_catalog(
13    cache: &SchemaCache,
14) -> Result<Catalog, Box<dyn core::error::Error + Send + Sync>> {
15    let (value, _status) = cache.fetch(SCHEMASTORE_CATALOG_URL).await?;
16    let catalog = schema_catalog::parse_catalog_value(value)?;
17    Ok(catalog)
18}