Skip to main content

unistructgen_openapi_parser/
lib.rs

1//! OpenAPI/Swagger parser for UniStructGen
2//!
3//! This crate provides a parser that converts OpenAPI 3.0 specifications into
4//! UniStructGen's Intermediate Representation (IR), enabling automatic generation
5//! of Rust types, API clients, and validation code.
6//!
7//! # Features
8//!
9//! - Parse OpenAPI 3.0 specifications (YAML and JSON)
10//! - Convert schemas to Rust structs and enums
11//! - Generate API client traits with typed methods
12//! - Support for request/response validation
13//! - Handle references ($ref) and schema composition (allOf, oneOf, anyOf)
14//! - Fetch specs from URLs or local files
15//!
16//! # Examples
17//!
18//! ```no_run
19//! use unistructgen_openapi_parser::{OpenApiParser, OpenApiParserOptions};
20//! use unistructgen_core::Parser;
21//!
22//! let options = OpenApiParserOptions::builder()
23//!     .generate_client(true)
24//!     .generate_validation(true)
25//!     .build();
26//!
27//! let mut parser = OpenApiParser::new(options);
28//! let spec = std::fs::read_to_string("openapi.yaml").unwrap();
29//! let ir_module = parser.parse(&spec).unwrap();
30//! ```
31
32pub mod client;
33pub mod error;
34pub mod options;
35pub mod parser;
36pub mod schema;
37pub mod types;
38pub mod validation;
39
40#[cfg(feature = "fetch")]
41pub mod fetch;
42
43pub use error::{OpenApiError, Result};
44pub use options::{OpenApiParserOptions, OpenApiParserOptionsBuilder};
45pub use parser::OpenApiParser;
46
47// Re-export core types for convenience
48pub use unistructgen_core::{IRModule, IRStruct, IRType, IRTypeRef, Parser, PrimitiveKind};