Crates.io | fluorite_codegen |
lib.rs | fluorite_codegen |
version | 0.1.9 |
source | src |
created_at | 2023-12-26 10:05:48.373478 |
updated_at | 2024-04-14 19:27:03.625958 |
description | Generate rust/typescript codes from schemas specified by Yaml/JSON. |
homepage | |
repository | https://github.com/zhxiaogg/fluorite |
max_upload_size | |
id | 1080817 |
size | 54,148 |
Generate rust/typescript codes from schemas specified by Yaml/JSON.
The Fluorite Schema definition code is generated by
fluorite rust -i src/fluorite/definition.yaml -o ./src/definitions/
.
fluorite
in a Cargo ProjectPlease check the demo project for details. Add following dependencies first:
[dependencies]
serde = "<serde-version>"
fluorite = "0.1"
derive-new = "0.6"
[build-dependencies]
fluorite_codegen = "0.1"
Using fluorite
in the build.rs
to generate codes during the Cargo build process:
fn main() {
let out_dir = std::env::var("OUT_DIR").unwrap();
fluorite::compile(&["fluorite/demo.yaml"], out_dir.as_str()).unwrap();
}
Instruct your project to include the generated codes, e.g. in your lib or main file:
mod demo {
include!(concat!(env!("OUT_DIR"), "/demo/mod.rs"));
}
fluorite
as a cli$ fluorite --help
Generate rust/typescript codes from schemas specified by Yaml/JSON.
Usage: fluorite [OPTIONS] --output <OUTPUT>
Options:
-i, --inputs <INPUTS> Input definition files
-o, --output <OUTPUT> Output directory
-t, --target <TARGET> Target language [default: rust] [possible values: rust]
-h, --help Print help
-V, --version Print version
build.rs
scriptfluorite
More details can be found in definitions.rs.