Skip to main content

validate_api

Function validate_api 

Source
pub fn validate_api(
    api: Api,
    source: Option<(&str, &str)>,
) -> Result<ResolvedApi, ValidationDiagnostics>
Expand description

Validate an Api document, reporting every rule violation found. The optional source is (filename, contents) of the IDL file and is used to attach spans to the returned diagnostics. Pass None when the API is constructed in memory (tests, programmatic builds) and there is no on-disk source.

This is the one checked way to turn a parsed document into the ResolvedApi every generator consumes. The document is never rewritten; the resolved view indexes its declarations so that ResolvedApi::resolve can turn each written reference into a Ty whose kind and owning module are known.

ยงErrors

Returns ValidationDiagnostics carrying one ValidationDiagnostic per violation: an unsupported schema version, a duplicate or invalid name, an unknown or misplaced type, an empty struct or enum, a throws without an error domain, or any other rule violation in the catalog above.