A Rust library for generating random data from a JSON schema.
Add the following to your Cargo.toml
:
toml
[dependencies]
datagen-rs = "0.1.0"
```rust use datagenrs::util::helpers::{generaterandomdata, readschema};
fn main() { let schema = readschema("path/to/schema.json").unwrap(); let data = generaterandom_data(schema, None).unwrap(); println!("{}", data); } ```
```rust use datagenrs::util::helpers::{generaterandomdatafromstr, readschema};
fn main() { let schema: Schema = serdejson::fromstr(r#" { "type": "string", "value": "test } "#).unwrap(); let data = generaterandomdatafromstr(&schema, None).unwrap(); println!("{}", data); } ```
```rust use datagenrs::util::helpers::writejson_schema;
fn main() { writejsonschema("path/to/schema.json").unwrap(); } ```
| Feature | Description | Depends on |
| --------------- | -------------------------------------------------------------------- | ------------------------------------- |
| plugin
| Enables loading plugins | |
| native-plugin
| Enables loading plugins written in Rust | plugin
|
| serialize
| Enables serialization/deserialization for all structs using serde
. | |
| map-schema
| Enables data generation for several types | serialize
|
| generate
| Enables data generation for all types | map-schema
|
| schema
| Enables JSON schema generation using schemars
| serialize
|
| all
| Enables all features | native-plugin
, generate
, schema
|