#json #schema #code #generator

jsonschema_code_generator

Crate for generating rust types from JSON schemas

6 releases (2 stable)

2.0.0 Jun 29, 2021
1.0.0 Jun 29, 2021
0.2.1 Jun 28, 2021
0.1.1 May 21, 2021

#340 in Database interfaces

Download history 83/week @ 2021-09-28 66/week @ 2021-10-05 88/week @ 2021-10-12 13/week @ 2021-10-19 11/week @ 2021-10-26 8/week @ 2021-11-02 20/week @ 2021-11-09 17/week @ 2021-11-16 17/week @ 2021-11-23 21/week @ 2021-11-30 16/week @ 2021-12-07 64/week @ 2021-12-14 24/week @ 2021-12-21 26/week @ 2021-12-28 19/week @ 2022-01-04 10/week @ 2022-01-11

104 downloads per month
Used in webthings-gateway-ipc-types

MPL-2.0 license

78KB
2K SLoC

jsonschema_code_generator

Build Status Latest Version Docs

This Rust crate allows you to generate Rust types from JSON Schemas.

It attaches serde_json attributes to the structs for json serialization/deserialization.

Example

use jsonschema_code_generator::generate;
use std::path::Path;

fn main() {
    let rust_code = generate(&Path::new("schemas/draft-04.json"));
    println!("{}", rust_code);
}

Todo

  • Add support for draft 4 schemas
  • Resolve definitions across files
  • Resolve struct name collisions
  • Add macro
  • Merge anyOf and allOf definitions to a single type
  • Add support for draft 7 schemas
  • Add support for draft 2019-09 schemas
  • Add support for draft 2020-12 schemas

Dependencies

~0.8–1.5MB
~34K SLoC

`