pub struct JsonSchemaRenderer {
pub fragment_mode: bool,
}Expand description
Generator for JSON Schema (Draft 2020-12)
This generator produces a JSON Schema compatible with OpenAI’s response_format
and other AI tools that require structured output validation.
§Example
ⓘ
use unistructgen_codegen::JsonSchemaRenderer;
use unistructgen_core::CodeGenerator;
let generator = JsonSchemaRenderer::default();
let schema_json = generator.generate(&ir_module)?;Fields§
§fragment_mode: boolIf true, the generated schema will not include the $schema keyword, making it suitable for embedding in other schemas.
Implementations§
Trait Implementations§
Source§impl CodeGenerator for JsonSchemaRenderer
impl CodeGenerator for JsonSchemaRenderer
Source§type Error = JsonSchemaError
type Error = JsonSchemaError
The error type this generator produces
Source§fn generate(&self, module: &IRModule) -> Result<String, Self::Error>
fn generate(&self, module: &IRModule) -> Result<String, Self::Error>
Generate code from an IR module Read more
Source§fn file_extension(&self) -> &str
fn file_extension(&self) -> &str
Get the file extension for generated code Read more
Source§fn metadata(&self) -> GeneratorMetadata
fn metadata(&self) -> GeneratorMetadata
Get metadata about the generator (optional) Read more
Source§impl Debug for JsonSchemaRenderer
impl Debug for JsonSchemaRenderer
Source§impl Default for JsonSchemaRenderer
impl Default for JsonSchemaRenderer
Source§fn default() -> JsonSchemaRenderer
fn default() -> JsonSchemaRenderer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for JsonSchemaRenderer
impl RefUnwindSafe for JsonSchemaRenderer
impl Send for JsonSchemaRenderer
impl Sync for JsonSchemaRenderer
impl Unpin for JsonSchemaRenderer
impl UnsafeUnpin for JsonSchemaRenderer
impl UnwindSafe for JsonSchemaRenderer
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<G> CodeGeneratorExt for Gwhere
G: CodeGenerator,
impl<G> CodeGeneratorExt for Gwhere
G: CodeGenerator,
Source§fn generate_formatted(&self, module: &IRModule) -> Result<String, Self::Error>
fn generate_formatted(&self, module: &IRModule) -> Result<String, Self::Error>
Generate and format code in one step
Source§fn generate_validated(&self, module: &IRModule) -> Result<String, Self::Error>
fn generate_validated(&self, module: &IRModule) -> Result<String, Self::Error>
Generate code with validation first