6 releases
new 0.1.5 | Jan 14, 2025 |
---|---|
0.1.4 | Jan 14, 2025 |
0.1.0 | Dec 11, 2024 |
#132 in Template engine
485 downloads per month
28KB
634 lines
mandolin
Generate openapi-based server code
Online demo with wasm: https://lzpel.github.io/mandolin/
Using mandolin
Render server code using builtin template
use mandolin;
use serde_yaml;
use std::fs;
fn main() {
let input=serde_yaml::from_str(fs::read_to_string("./openapi/openapi.yaml").unwrap().as_str()).unwrap();
let output=mandolin::Mandolin::new(input)
.template(mandolin::templates::MAIN)
.render()
.unwrap();
fs::write("./src/server.rs", output).unwrap();
}
Render server code using custom template
use mandolin;
use serde_yaml;
use std::fs;
fn main() {
let input=serde_yaml::from_str(fs::read_to_string("./openapi/openapi.yaml").unwrap().as_str()).unwrap();
let output=mandolin::Mandolin::new(input)
.template(fs::read_to_string("./custom/template.tera").unwrap())
.render()
.unwrap();
fs::write("./src/server.rs", output).unwrap();
}
version
- 0.1.5 fix ref filter
- 0.1.4 replace minijinja from tera
- 0.1.3
- simplify mandolin::Mandolin::new
pub fn new(api: OpenAPI) -> Result<Self, serde_yaml::Error>
intopub fn new(api: OpenAPI) -> Self
- remove mandolin::Mandolin::template_from_path
- move serde_yaml(deprecated) in dependency into in dev-dependency
- update README.md
- add examples
- rename mandolin::builtin into mandolin::templates
- exclude demo from crate
- simplify mandolin::Mandolin::new
- 0.1.0 publish
my favorite mandolin music
- 月に舞う/武藤理恵 https://youtu.be/OVKkRj0di2I
- Suite Spagnola/C.Mandonico https://youtu.be/fCkcP_cuneU
Dependencies
~4.5–6.5MB
~118K SLoC