pub struct TypeGenerator { /* private fields */ }Expand description
Type generator that wraps typify’s TypeSpace.
Implementations§
Source§impl TypeGenerator
impl TypeGenerator
Sourcepub fn new(spec: &ParsedSpec) -> Result<Self>
pub fn new(spec: &ParsedSpec) -> Result<Self>
Create a new type generator from a parsed spec.
Sourcepub fn generate_all_types(&self) -> TokenStream
pub fn generate_all_types(&self) -> TokenStream
Generate all types as a TokenStream.
Sourcepub fn get_type_name(&self, reference: &str) -> Option<String>
pub fn get_type_name(&self, reference: &str) -> Option<String>
Get the type name for a schema reference.
Sourcepub fn type_for_schema(
&self,
schema: &ReferenceOr<Schema>,
name_hint: &str,
) -> TokenStream
pub fn type_for_schema( &self, schema: &ReferenceOr<Schema>, name_hint: &str, ) -> TokenStream
Generate a type for an inline schema.
Sourcepub fn type_for_boxed_schema(
&self,
schema: &ReferenceOr<Box<Schema>>,
name_hint: &str,
) -> TokenStream
pub fn type_for_boxed_schema( &self, schema: &ReferenceOr<Box<Schema>>, name_hint: &str, ) -> TokenStream
Generate a type for a boxed schema reference.
Sourcepub fn path_param_type(&self, param: &OperationParam) -> TokenStream
pub fn path_param_type(&self, param: &OperationParam) -> TokenStream
Get the type for a path parameter.
Sourcepub fn query_param_type(&self, param: &OperationParam) -> TokenStream
pub fn query_param_type(&self, param: &OperationParam) -> TokenStream
Get the type for a query parameter.
Sourcepub fn request_body_type(
&self,
body: &RequestBody,
op_name: &str,
) -> TokenStream
pub fn request_body_type( &self, body: &RequestBody, op_name: &str, ) -> TokenStream
Get the type for a request body.
Sourcepub fn response_type(
&self,
schema: &Option<ReferenceOr<Schema>>,
op_name: &str,
status: u16,
) -> TokenStream
pub fn response_type( &self, schema: &Option<ReferenceOr<Schema>>, op_name: &str, status: u16, ) -> TokenStream
Get the type for a response body.
Sourcepub fn generate_query_struct(
&self,
op: &Operation,
) -> Option<(Ident, TokenStream)>
pub fn generate_query_struct( &self, op: &Operation, ) -> Option<(Ident, TokenStream)>
Generate a query params struct for an operation.
Sourcepub fn generate_path_type(&self, op: &Operation) -> TokenStream
pub fn generate_path_type(&self, op: &Operation) -> TokenStream
Generate a path params type for an operation (usually a tuple).
Auto Trait Implementations§
impl Freeze for TypeGenerator
impl RefUnwindSafe for TypeGenerator
impl !Send for TypeGenerator
impl !Sync for TypeGenerator
impl Unpin for TypeGenerator
impl UnwindSafe for TypeGenerator
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