Skip to main content

SourceDocument

Struct SourceDocument 

Source
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

Source

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:///.

Source

pub fn uri(&self) -> &Url

The document’s identity.

Source

pub fn version(&self) -> SourceVersion

The version the description was written in — not the version spec is at, which is always 3.2.

Source

pub fn fidelity(&self) -> Fidelity

How faithfully the numbers reflect what was written.

Source

pub fn raw(&self) -> &Value

The description exactly as given, before any conversion. Every diagnostic pointer indexes this value.

Source

pub fn spec(&self) -> &Spec

The description normalized to OpenAPI 3.2.

Source

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.

Trait Implementations§

Source§

impl Clone for SourceDocument

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceDocument

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for SourceDocument

§

impl Freeze for SourceDocument
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, PhantomData<Server>: Freeze, *const LeafNode<String, PathItem> is !null: Freeze, PhantomData<Box<(String, PathItem)>>: Freeze, *const LeafNode<String, RefOr<Schema, SchemaRef>> is !null: Freeze, PhantomData<Box<(String, RefOr<Schema, SchemaRef>)>>: Freeze, *const LeafNode<String, RefOr<Response>> is !null: Freeze, PhantomData<Box<(String, RefOr<Response>)>>: Freeze, *const LeafNode<String, RefOr<Parameter>> is !null: Freeze, PhantomData<Box<(String, RefOr<Parameter>)>>: Freeze, *const LeafNode<String, RefOr<Example>> is !null: Freeze, PhantomData<Box<(String, RefOr<Example>)>>: Freeze, *const LeafNode<String, RefOr<RequestBody>> is !null: Freeze, PhantomData<Box<(String, RefOr<RequestBody>)>>: Freeze, *const LeafNode<String, RefOr<Header>> is !null: Freeze, PhantomData<Box<(String, RefOr<Header>)>>: Freeze, *const LeafNode<String, RefOr<SecurityScheme>> is !null: Freeze, PhantomData<Box<(String, RefOr<SecurityScheme>)>>: Freeze, *const LeafNode<String, RefOr<Link>> is !null: Freeze, PhantomData<Box<(String, RefOr<Link>)>>: Freeze, *const LeafNode<String, RefOr<Callback>> is !null: Freeze, PhantomData<Box<(String, RefOr<Callback>)>>: Freeze, *const LeafNode<String, RefOr<MediaType>> is !null: Freeze, PhantomData<Box<(String, RefOr<MediaType>)>>: Freeze, PhantomData<BTreeMap<String, Vec<String>>>: Freeze, PhantomData<Tag>: Freeze, PhantomData<Diagnostic>: Freeze,

§

impl Move for SourceDocument

§

impl RefUnwindSafe for SourceDocument

§

impl Send for SourceDocument
where RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, ServerVariable, LeafOrInternal>: Send, BoxRaw<(String, ServerVariable)>: Send, NodeRef<Owned, String, PathItem, LeafOrInternal>: Send, BoxRaw<(String, PathItem)>: Send, NodeRef<Owned, String, RefOr<Schema, SchemaRef>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Schema, SchemaRef>)>: Send, NodeRef<Owned, String, RefOr<Response>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Response>)>: Send, NodeRef<Owned, String, RefOr<Parameter>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Parameter>)>: Send, NodeRef<Owned, String, RefOr<Example>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Example>)>: Send, NodeRef<Owned, String, RefOr<RequestBody>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<RequestBody>)>: Send, NodeRef<Owned, String, RefOr<Header>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Header>)>: Send, NodeRef<Owned, String, RefOr<SecurityScheme>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<SecurityScheme>)>: Send, NodeRef<Owned, String, RefOr<Link>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Link>)>: Send, NodeRef<Owned, String, RefOr<Callback>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<Callback>)>: Send, NodeRef<Owned, String, RefOr<MediaType>, LeafOrInternal>: Send, BoxRaw<(String, RefOr<MediaType>)>: Send, NodeRef<Owned, String, Vec<String>, LeafOrInternal>: Send, BoxRaw<(String, Vec<String>)>: Send,

§

impl Sync for SourceDocument
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, ServerVariable, LeafOrInternal>: Sync, BoxRaw<(String, ServerVariable)>: Sync, NodeRef<Owned, String, PathItem, LeafOrInternal>: Sync, BoxRaw<(String, PathItem)>: Sync, NodeRef<Owned, String, RefOr<Schema, SchemaRef>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Schema, SchemaRef>)>: Sync, NodeRef<Owned, String, RefOr<Response>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Response>)>: Sync, NodeRef<Owned, String, RefOr<Parameter>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Parameter>)>: Sync, NodeRef<Owned, String, RefOr<Example>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Example>)>: Sync, NodeRef<Owned, String, RefOr<RequestBody>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<RequestBody>)>: Sync, NodeRef<Owned, String, RefOr<Header>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Header>)>: Sync, NodeRef<Owned, String, RefOr<SecurityScheme>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<SecurityScheme>)>: Sync, NodeRef<Owned, String, RefOr<Link>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Link>)>: Sync, NodeRef<Owned, String, RefOr<Callback>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<Callback>)>: Sync, NodeRef<Owned, String, RefOr<MediaType>, LeafOrInternal>: Sync, BoxRaw<(String, RefOr<MediaType>)>: Sync, NodeRef<Owned, String, Vec<String>, LeafOrInternal>: Sync, BoxRaw<(String, Vec<String>)>: Sync,

§

impl Unpin for SourceDocument
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, ServerVariable> is !null: Unpin, Box<(String, ServerVariable)>: Unpin, *const LeafNode<String, PathItem> is !null: Unpin, Box<(String, PathItem)>: Unpin, *const LeafNode<String, RefOr<Schema, SchemaRef>> is !null: Unpin, Box<(String, RefOr<Schema, SchemaRef>)>: Unpin, *const LeafNode<String, RefOr<Response>> is !null: Unpin, Box<(String, RefOr<Response>)>: Unpin, *const LeafNode<String, RefOr<Parameter>> is !null: Unpin, Box<(String, RefOr<Parameter>)>: Unpin, *const LeafNode<String, RefOr<Example>> is !null: Unpin, Box<(String, RefOr<Example>)>: Unpin, *const LeafNode<String, RefOr<RequestBody>> is !null: Unpin, Box<(String, RefOr<RequestBody>)>: Unpin, *const LeafNode<String, RefOr<Header>> is !null: Unpin, Box<(String, RefOr<Header>)>: Unpin, *const LeafNode<String, RefOr<SecurityScheme>> is !null: Unpin, Box<(String, RefOr<SecurityScheme>)>: Unpin, *const LeafNode<String, RefOr<Link>> is !null: Unpin, Box<(String, RefOr<Link>)>: Unpin, *const LeafNode<String, RefOr<Callback>> is !null: Unpin, Box<(String, RefOr<Callback>)>: Unpin, *const LeafNode<String, RefOr<MediaType>> is !null: Unpin, Box<(String, RefOr<MediaType>)>: Unpin, *const LeafNode<String, Vec<String>> is !null: Unpin, Box<(String, Vec<String>)>: Unpin,

§

impl UnsafeUnpin for SourceDocument
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Value>: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin, PhantomData<Server>: UnsafeUnpin, *const LeafNode<String, PathItem> is !null: UnsafeUnpin, PhantomData<Box<(String, PathItem)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Schema, SchemaRef>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Schema, SchemaRef>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Response>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Response>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Parameter>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Parameter>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Example>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Example>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<RequestBody>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<RequestBody>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Header>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Header>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<SecurityScheme>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<SecurityScheme>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Link>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Link>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<Callback>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<Callback>)>>: UnsafeUnpin, *const LeafNode<String, RefOr<MediaType>> is !null: UnsafeUnpin, PhantomData<Box<(String, RefOr<MediaType>)>>: UnsafeUnpin, PhantomData<BTreeMap<String, Vec<String>>>: UnsafeUnpin, PhantomData<Tag>: UnsafeUnpin, PhantomData<Diagnostic>: UnsafeUnpin,

§

impl UnwindSafe for SourceDocument

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.