Skip to main content

Spec

Struct Spec 

Source
pub struct Spec { /* private fields */ }
Expand description

High-level representation of a parsed and queryable OpenAPI spec.

Implementations§

Source§

impl Spec

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self, ForgeError>

Load an OpenAPI spec from a YAML or JSON file.

§Errors

Returns an error if the file cannot be read, parsed, or is not OpenAPI 3.0.x.

Source

pub fn parse(content: &str) -> Result<Self, ForgeError>

Parse an OpenAPI spec from a string (YAML or JSON).

Convenience wrapper around the FromStr implementation.

§Errors

Returns an error if the string cannot be parsed.

Source

pub fn endpoints(&self) -> Vec<Endpoint>

Get all endpoints in the spec.

Source

pub fn schema(&self, name: &str) -> Result<&SchemaObject, ForgeError>

Look up a component schema by name.

§Errors

Returns SchemaNotFound if the schema name does not exist.

Source

pub fn schema_names(&self) -> Vec<&str>

Get all component schema names.

Source

pub fn fields(&self, schema_name: &str) -> Result<Vec<Field>, ForgeError>

Resolve fields from a named schema, including type info and required status.

§Errors

Returns an error if the schema is not found.

Source

pub fn resolve_type(&self, schema: &SchemaObject) -> TypeInfo

Resolve the type info for a sekkei Schema.

Delegates to takumi::schema_to_field_type for consistent type resolution.

Source

pub fn resolve_schema_or_ref_type( &self, schema_or_ref: &SchemaOrRef, ) -> TypeInfo

Resolve the type info for a SchemaOrRef adapter.

Source

pub fn diff_schemas( &self, name_a: &str, name_b: &str, ) -> Result<SchemaDiff, ForgeError>

Diff two schemas by name, showing added/removed/changed fields.

§Errors

Returns an error if either schema is not found.

Source

pub fn group_by_crud_pattern(&self) -> Vec<CrudGroup>

Heuristic CRUD grouping of endpoints by operation pattern.

Groups endpoints like /create-secret, /get-secret-value, /update-secret-val, /delete-item into clusters by matching create/get/update/delete prefixes.

Source

pub fn endpoint_by_path(&self, path: &str) -> Option<Endpoint>

Find an endpoint by its path.

Trait Implementations§

Source§

impl Clone for Spec

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 Spec

Source§

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

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

impl FromStr for Spec

Source§

type Err = ForgeError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

§

impl Freeze for Spec

§

impl RefUnwindSafe for Spec

§

impl Send for Spec

§

impl Sync for Spec

§

impl Unpin for Spec

§

impl UnsafeUnpin for Spec

§

impl UnwindSafe for Spec

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