pub struct Generator { /* private fields */ }Implementations§
Source§impl Generator
impl Generator
Sourcepub fn new(openapi: OpenAPI, default_options: GeneratorOptions) -> Self
pub fn new(openapi: OpenAPI, default_options: GeneratorOptions) -> Self
Creates a new instance of Generator.
§Arguments
openapi- An instance of theOpenAPIstructure representing the OpenAPI specification.default_options- An instance ofGeneratorOptionsto configure the generator’s behavior.
§Returns
A new Generator instance initialized with the provided OpenAPI specification and generator options.
§Examples
use openapiv3::OpenAPI;
use openapiv3_to_typescript::{Generator, GeneratorOptions};
let openapi = OpenAPI::default();
let options = GeneratorOptions::default();
let generator = Generator::new(openapi, options);Sourcepub fn generate_schema<'a>(
&'a self,
schema: &'a Schema,
options: Option<GeneratorOptions>,
) -> PartialGeneration<'a>
pub fn generate_schema<'a>( &'a self, schema: &'a Schema, options: Option<GeneratorOptions>, ) -> PartialGeneration<'a>
Generates a TypeScript type definition from an OpenAPI schema.
§Arguments
schema- A reference to theSchemaobject from the OpenAPI specification that you want to generate the TypeScript type for.options- An optional instance ofGeneratorOptionsto override the default options for this generation.
§Returns
A PartialGeneration instance containing the generated TypeScript type definition as a string
and a vector of references that were included in the generation process.
§Examples
use openapiv3::{OpenAPI, Schema};
use openapiv3_to_typescript::{Generator, GeneratorOptions, PartialGeneration};
let openapi = OpenAPI::default();
let options = GeneratorOptions { skip_read_only: true };
let generator = Generator::new(openapi, options);
let schema = Schema::new_number();
let partial_generation: PartialGeneration = generator.generate_schema(&schema, None);
println!("{:?}", partial_generation);pub fn generate_path( &self, operation_id: String, ) -> Option<PartialGeneration<'_>>
pub fn openapi(&self) -> &OpenAPI
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Generator
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more