Skip to main content

SpecKind

Enum SpecKind 

Source
pub enum SpecKind {
    OpenApi,
    AsyncApi,
    GraphQl,
    McpTools,
}
Expand description

Spec dialects soothfast reads and writes.

Variants§

§

OpenApi

§

AsyncApi

§

GraphQl

§

McpTools

Implementations§

Source§

impl SpecKind

Source

pub const ALL: &'static [SpecKind]

Every dialect that can be generated, for help text and diagnostics.

Source

pub fn name(self) -> &'static str

The name used in soothfast.toml and in messages.

Source

pub fn parse_name(s: &str) -> Option<SpecKind>

Parse a dialect = "..." value.

Source

pub fn for_path(path: &str) -> SpecKind

Guess the dialect of a spec file from its path.

Generation needs a dialect before the file exists, so content sniffing (which crate::sniff_kind does on the reconcile path) is not available here. The guess is conservative and always overridable with an explicit dialect = key: OpenAPI is the default because it is what an unqualified spec.yaml almost always means.

Source

pub fn document(self, info: &Info, ops: &[Operation]) -> Document

Assemble a document from inferred route shapes.

Source

pub fn render(self, path: &str, value: &Value) -> String

Serialize a document for writing to path.

GraphQL ignores the extension because SDL is its only serialization; the rest honour .json and default to the dialect’s usual form.

Source

pub fn parse(self, path: &str, text: &str) -> Result<Value, String>

Parse a committed spec file back into its generated document.

Round-trips the result through SpecKind::render and fails on any drift, so a stale or hand-edited file can never be silently diffed as the base.

Source

pub fn diff(self, old: &Value, new: &Value) -> Vec<Change>

Compare two revisions of a document for consumer compatibility.

Source

pub fn empty(self) -> Value

The document a spec file that does not yet exist compares as, so that everything in a newly added file reads as additive by construction.

Source

pub fn summarize(self, value: &Value) -> (usize, usize)

Operation and named-schema counts, for the one-line generation summary.

Trait Implementations§

Source§

impl Clone for SpecKind

Source§

fn clone(&self) -> SpecKind

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 Copy for SpecKind

Source§

impl Debug for SpecKind

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SpecKind

Source§

impl PartialEq for SpecKind

Source§

fn eq(&self, other: &SpecKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SpecKind

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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.