pub struct SchemaDefinition {
pub name: String,
pub description: Option<String>,
pub fields: Vec<FieldDefinition>,
pub relationships: HashMap<String, Relationship>,
pub metadata: HashMap<String, Value>,
}Expand description
Schema definition for data generation
Fields§
§name: StringSchema name
description: Option<String>Schema description
fields: Vec<FieldDefinition>Field definitions
relationships: HashMap<String, Relationship>Relationships to other schemas
metadata: HashMap<String, Value>Additional metadata
Implementations§
Source§impl SchemaDefinition
impl SchemaDefinition
Sourcepub fn with_field(self, field: FieldDefinition) -> Self
pub fn with_field(self, field: FieldDefinition) -> Self
Add a field to the schema
Sourcepub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
pub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
Add multiple fields to the schema
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Set description
Sourcepub fn with_relationship(self, name: String, relationship: Relationship) -> Self
pub fn with_relationship(self, name: String, relationship: Relationship) -> Self
Add a relationship
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Add metadata
Sourcepub fn generate_row(&self, faker: &mut EnhancedFaker) -> Result<Value>
pub fn generate_row(&self, faker: &mut EnhancedFaker) -> Result<Value>
Generate a single row of data
Sourcepub fn get_field(&self, name: &str) -> Option<&FieldDefinition>
pub fn get_field(&self, name: &str) -> Option<&FieldDefinition>
Get field by name
Sourcepub fn from_json_schema(json_schema: &Value) -> Result<Self>
pub fn from_json_schema(json_schema: &Value) -> Result<Self>
Create schema from JSON Schema
Sourcepub fn from_openapi_spec(openapi_spec: &Value) -> Result<Self>
pub fn from_openapi_spec(openapi_spec: &Value) -> Result<Self>
Create schema from OpenAPI spec
Trait Implementations§
Source§impl Clone for SchemaDefinition
impl Clone for SchemaDefinition
Source§fn clone(&self) -> SchemaDefinition
fn clone(&self) -> SchemaDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaDefinition
impl Debug for SchemaDefinition
Source§impl<'de> Deserialize<'de> for SchemaDefinition
impl<'de> Deserialize<'de> for SchemaDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SchemaDefinition
impl RefUnwindSafe for SchemaDefinition
impl Send for SchemaDefinition
impl Sync for SchemaDefinition
impl Unpin for SchemaDefinition
impl UnwindSafe for SchemaDefinition
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