#json-schema #code-generation

macro bin polywrap_schemafy

Generates serializable Rust types from a json schema

2 releases

0.1.1 Nov 7, 2022
0.1.0 Nov 7, 2022

#1552 in Procedural macros

Download history 143/week @ 2023-07-14 282/week @ 2023-07-21 159/week @ 2023-07-28 127/week @ 2023-08-04 299/week @ 2023-08-11 324/week @ 2023-08-18 327/week @ 2023-08-25 202/week @ 2023-09-01 111/week @ 2023-09-08 101/week @ 2023-09-15 26/week @ 2023-09-22 165/week @ 2023-09-29 84/week @ 2023-10-06 94/week @ 2023-10-13 126/week @ 2023-10-20 108/week @ 2023-10-27

416 downloads per month
Used in 24 crates (3 directly)

MIT license

1.5K SLoC


Build Status Docs

This is a Rust crate which can take a JSON schema (draft 4) and generate Rust types which are serializable with serde. No checking such as min_value are done but instead only the structure of the schema is followed as closely as possible.

As a schema could be arbitrarily complex this crate makes no guarantee that it can generate good types or even any types at all for a given schema but the crate does manage to bootstrap itself which is kind of cool.


Generated types for VS Codes debug server protocol: https://docs.rs/debugserver-types


The types generated by the JSON schema specification can be regenerated with cargo build --features internal-regenerate if changes have been made in the library itself. Rustfmt is required so that src/schema.rs is readable.


~142K SLoC