Skip to main content

Generator

Struct Generator 

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

Main generator that coordinates all the pieces.

Implementations§

Source§

impl Generator

Source

pub fn builder(spec: OpenAPI) -> GeneratorBuilder

Create a builder from an OpenAPI spec.

Source

pub fn builder_from_file(path: &Path) -> Result<GeneratorBuilder>

Create a builder by loading an OpenAPI spec from a file.

Source

pub fn new(spec: OpenAPI) -> Result<Self>

Create a new generator from an OpenAPI spec with default settings.

Source

pub fn with_settings(spec: OpenAPI, settings: TypeSpaceSettings) -> Result<Self>

Create a new generator from an OpenAPI spec with custom type settings.

Source

pub fn from_file(path: &Path) -> Result<Self>

Load and parse an OpenAPI spec from a file path.

Source

pub fn spec(&self) -> &ParsedSpec

Get the parsed spec.

Source

pub fn type_generator(&self) -> &TypeGenerator

Get the type generator.

Source

pub fn generate_types(&self) -> TokenStream

Generate all types as a TokenStream.

Source

pub fn generate_responses(&self) -> TokenStream

Generate response enums for all operations.

Source

pub fn generate_query_structs(&self) -> TokenStream

Generate query parameter structs for all operations.

Source

pub fn generate_path_structs(&self) -> TokenStream

Generate path parameter structs for all operations.

Source

pub fn type_overrides(&self) -> &TypeOverrides

Get the type overrides.

Source

pub fn response_suffixes(&self) -> &ResponseSuffixes

Get the response suffixes.

Source

pub fn get_operation( &self, method: HttpMethod, path: &str, ) -> Option<&Operation>

Look up an operation by HTTP method and path.

Source

pub fn operations(&self) -> impl Iterator<Item = &Operation>

Get all operations.

Source

pub fn validate_coverage( &self, covered: &HashSet<(HttpMethod, String)>, ) -> Result<()>

Validate that all operations are covered by trait methods.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.