Skip to main content

Resolver

Struct Resolver 

Source
pub struct Resolver<'a> {
    pub components: BTreeMap<String, Value>,
    pub gaps: Vec<Gap>,
    pub aux_resolved: BTreeSet<String>,
    /* private fields */
}
Expand description

Walks rustdoc JSON, emitting JSON Schema and collecting Gaps.

Resolution may span several documents (see Docs), but components, the component-name registry and the cycle-breaking stack are shared across all of them: one type gets one component wherever it was defined.

Fields§

§components: BTreeMap<String, Value>

Named schemas, emitted as components/schemas in OpenAPI.

§gaps: Vec<Gap>§aux_resolved: BTreeSet<String>

Canonical paths walked out of an auxiliary document. Resolved, so deliberately not gaps — reported only to say where they came from.

Implementations§

Source§

impl<'a> Resolver<'a>

Source

pub fn new( docs: impl Into<Docs<'a>>, table: &'a TypeTable, ) -> Result<Self, String>

Build a resolver over a parsed rustdoc JSON document, or over a primary document plus its workspace-local companions (Docs).

Source

pub fn find_type_id(&self, name: &str) -> Option<Value>

Find a struct or enum by its plain name, for attribute overrides that name a type rather than pointing at a signature.

Source

pub fn find_by_path(&self, canonical: &str) -> Option<&'a Value>

Find an item by its fully-qualified path, e.g. app::routes::create.

#[route] records handler ids as module_path!()::fn_name, which is exactly the path rustdoc reports, so route lookup is a direct match.

Source

pub fn resolve_by_name(&mut self, name: &str, at: &str) -> Option<Value>

Resolve a struct or enum named in an attribute, searching this crate first and then the workspace-local documents.

Source

pub fn is_option(ty: &Value) -> bool

True when a type is Option<..>, which makes a field optional on the wire independently of the schema its inner type produces.

Source

pub fn resolve(&mut self, ty: &Value, subst: &Subst, at: &str) -> Value

Resolve one rustdoc type node into a JSON Schema.

at is a human-readable location (Item.when) used for gap reports.

Auto Trait Implementations§

§

impl<'a> Forget for Resolver<'a>

§

impl<'a> Freeze for Resolver<'a>
where *const u8 is !null: Freeze, PhantomData<Doc<'a>>: Freeze, &'a TypeTable: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<Box<(String, String)>>: Freeze, PhantomData<Gap>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze,

§

impl<'a> Move for Resolver<'a>

§

impl<'a> RefUnwindSafe for Resolver<'a>

§

impl<'a> Send for Resolver<'a>
where RawVecInner: Send, &'a Map<String, Value>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, NodeRef<Owned, String, Option<String>, LeafOrInternal>: Send, BoxRaw<(String, Option<String>)>: Send, &'a TypeTable: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send,

§

impl<'a> Sync for Resolver<'a>
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, NodeRef<Owned, String, Option<String>, LeafOrInternal>: Sync, BoxRaw<(String, Option<String>)>: Sync, NodeRef<Owned, String, TypeMapping, LeafOrInternal>: Sync, BoxRaw<(String, TypeMapping)>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync,

§

impl<'a> Unpin for Resolver<'a>
where *const u8 is !null: Unpin, &'a Map<String, Value>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, *const LeafNode<String, Option<String>> is !null: Unpin, Box<(String, Option<String>)>: Unpin, &'a TypeTable: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin,

§

impl<'a> UnsafeUnpin for Resolver<'a>
where *const u8 is !null: UnsafeUnpin, PhantomData<Doc<'a>>: UnsafeUnpin, &'a TypeTable: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin, *const LeafNode<String, String> is !null: UnsafeUnpin, PhantomData<Box<(String, String)>>: UnsafeUnpin, PhantomData<Gap>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,

§

impl<'a> UnwindSafe for Resolver<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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