pub struct JSONSchemaExporter;Expand description
Exporter for JSON Schema format.
Implementations§
Source§impl JSONSchemaExporter
impl JSONSchemaExporter
Sourcepub fn export(&self, tables: &[Table]) -> Result<ExportResult, ExportError>
pub fn export(&self, tables: &[Table]) -> Result<ExportResult, ExportError>
Export tables to JSON Schema format (SDK interface).
§Arguments
tables- Slice of tables to export
§Returns
An ExportResult containing JSON Schema with all tables in the definitions section.
§Example
use data_modelling_sdk::export::json_schema::JSONSchemaExporter;
use data_modelling_sdk::models::{Table, Column};
let tables = vec![
Table::new("User".to_string(), vec![Column::new("id".to_string(), "INTEGER".to_string())]),
];
let exporter = JSONSchemaExporter;
let result = exporter.export(&tables).unwrap();
assert_eq!(result.format, "json_schema");
assert!(result.content.contains("\"definitions\""));Sourcepub fn export_table(table: &Table) -> Value
pub fn export_table(table: &Table) -> Value
Export a table to JSON Schema format.
§Arguments
table- The table to export
§Returns
A serde_json::Value representing the JSON Schema for the table.
§Example
use data_modelling_sdk::export::json_schema::JSONSchemaExporter;
use data_modelling_sdk::models::{Table, Column};
let table = Table::new(
"User".to_string(),
vec![Column::new("id".to_string(), "INTEGER".to_string())],
);
let schema = JSONSchemaExporter::export_table(&table);
assert_eq!(schema["title"], "User");
assert_eq!(schema["type"], "object");Auto Trait Implementations§
impl Freeze for JSONSchemaExporter
impl RefUnwindSafe for JSONSchemaExporter
impl Send for JSONSchemaExporter
impl Sync for JSONSchemaExporter
impl Unpin for JSONSchemaExporter
impl UnwindSafe for JSONSchemaExporter
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