pub struct SourceDocument { /* private fields */ }Expand description
A description, parsed and normalized to OpenAPI 3.2, together with the source it came from.
The raw and typed views are the same document by construction: the
fields are private and SourceDocument::parse is the only way to
make one, so a caller cannot pair the raw JSON of one document with
the typed model of another. The raw view keeps what the typed model
cannot express — whether type was written at all, the exact text a
diagnostic should quote — and every diagnostic pointer indexes it,
in the version it was written in.
Implementations§
Source§impl SourceDocument
impl SourceDocument
Sourcepub fn parse(input: Input, uri: Url) -> Result<SourceDocument, SourceError>
pub fn parse(input: Input, uri: Url) -> Result<SourceDocument, SourceError>
Detect the version, parse the typed model at that version, record what upconverting to 3.2 loses, and upconvert.
uri identifies the document in every SchemaId
it produces. Input with no natural URI takes a synthetic one, by
convention stdin:///.
Sourcepub fn version(&self) -> SourceVersion
pub fn version(&self) -> SourceVersion
The version the description was written in — not the version
spec is at, which is always 3.2.
Sourcepub fn raw(&self) -> &Value
pub fn raw(&self) -> &Value
The description exactly as given, before any conversion. Every diagnostic pointer indexes this value.
Sourcepub fn normalization(&self) -> &[Diagnostic]
pub fn normalization(&self) -> &[Diagnostic]
What normalizing to 3.2 lost. Recorded by the source-version
adapter before the lossy conversion runs, since a 2.0
collectionFormat: tsv that 3.0 drops cannot be recovered
afterwards.