pub struct OpenApiParser { /* private fields */ }Expand description
OpenAPI/Swagger parser
Converts OpenAPI 3.0 specifications into UniStructGen’s Intermediate Representation (IR). Supports both YAML and JSON formats.
§Examples
use unistructgen_openapi_parser::{OpenApiParser, OpenApiParserOptions};
use unistructgen_core::Parser;
let options = OpenApiParserOptions::builder()
.generate_client(true)
.generate_validation(true)
.build();
let mut parser = OpenApiParser::new(options);
let yaml = std::fs::read_to_string("openapi.yaml").unwrap();
let ir_module = parser.parse(&yaml).unwrap();
println!("Generated {} types", ir_module.types.len());Implementations§
Source§impl OpenApiParser
impl OpenApiParser
Sourcepub fn new(options: OpenApiParserOptions) -> Self
pub fn new(options: OpenApiParserOptions) -> Self
Create a new OpenAPI parser with the given options
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new parser with default options
Trait Implementations§
Source§impl Parser for OpenApiParser
impl Parser for OpenApiParser
Source§type Error = OpenApiError
type Error = OpenApiError
The error type this parser produces
Source§fn parse(&mut self, input: &str) -> Result<IRModule>
fn parse(&mut self, input: &str) -> Result<IRModule>
Parse input text and return an IR module Read more
Source§fn extensions(&self) -> &[&'static str]
fn extensions(&self) -> &[&'static str]
Get the file extensions this parser supports Read more
Source§fn validate(&self, input: &str) -> Result<()>
fn validate(&self, input: &str) -> Result<()>
Validate input without full parsing (optional) Read more
Source§fn metadata(&self) -> ParserMetadata
fn metadata(&self) -> ParserMetadata
Get metadata about the parser (optional) Read more
Auto Trait Implementations§
impl Freeze for OpenApiParser
impl RefUnwindSafe for OpenApiParser
impl Send for OpenApiParser
impl Sync for OpenApiParser
impl Unpin for OpenApiParser
impl UnsafeUnpin for OpenApiParser
impl UnwindSafe for OpenApiParser
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