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

Download history 85/week @ 2024-12-05 67/week @ 2024-12-12 1/week @ 2024-12-19 336/week @ 2025-01-02 145/week @ 2025-01-09

485 downloads per month

MIT/Apache

28KB
634 lines

mandolin

crates.io

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> into pub 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
  • 0.1.0 publish

my favorite mandolin music

Dependencies

~4.5–6.5MB
~118K SLoC