Skip to main content

Module spec_source

Module spec_source 

Source
Expand description

Spec-source policy and document parsing shared by the CLI, library consumers, and the WASM playground build.

Everything in this module is pure: URL policy checks build on url::Url and document parsing goes through serde_yaml/serde_json in memory. The I/O that actually fetches or reads a spec lives in crate::cli, which is gated behind the cli feature.

Functionsยง

is_remote_spec
Whether an input string names a supported remote OpenAPI source.
json_from_str_lossy
Parse JSON with lossy number handling: numbers that overflow i64/u64 are stored as f64.
parse_oas_version
Parse the openapi version string into (major, minor). Tolerates patch and build-metadata suffixes. Returns None for unrecognised input.
parse_spec
sanitize_source_provenance
Remove URL credentials, query strings, and fragments before recording a source label in generated code. Local paths are retained as supplied.
validate_oas_document
Validate the openapi version field of a parsed document.
validate_remote_spec_url
Parse and enforce the remote-source transport policy.
yaml_to_json_value
Parse YAML to serde_json::Value, converting large numbers to f64 to avoid overflow. serde_yaml 0.9 cannot represent integers exceeding i64/u64 range (e.g. numbers > 2^64), so we preprocess the YAML to convert such numbers to float notation, then go through serde_yaml::Value and convert to serde_json::Value manually.