mandolin: Strongly Typed Rust Code Generator from OpenAPI
Input openapi.json/yaml, output one server code in rust.
Online demo with wasm: https://lzpel.github.io/mandolin/
What is this.
Generate one complete code for server from openapi specification and jinja2 templates.
You can implement actual behavior of api handler with generated types and traits.
Currently, mandolin provide 1 builtin templates for following frameworks
- axum(Rust) https://github.com/tokio-rs/axum
Getting started
Install mandolin
Render axum server code using builtin "RUST_AXUM" template
You can also use mandolin as library
Render axum server code using builtin "RUST_AXUM" template
use mandolin;
use serde_yaml;
Example of generated code
// This is generated by mandolin https://github.com/lzpel/mandolin from OpenApi specification
/* Cargo.toml for build this server
[dependencies]
serde= { version="*", features = ["derive"] }
serde_json= "*"
axum = { version = "*", features = ["multipart"] }
tokio = { version = "*", features = ["rt", "rt-multi-thread", "macros", "signal"] }
# optional
uuid = { version = "*", features = ["serde"] }
chrono = { version = "*", features = ["serde"] }
*/
use HashMap;
use serde;
use Future;
async
Running the generated server with your implementation
You can run the mock server from fn main.
You can add your implementation along with the generated trait ApiInterface like followings.
use crateout; // generated module
async
You can run your server with generated out.rs and your main.rs like above code. You can check your api serves as you impleted.
{
}
Open the output uri http://localhost:8080/api/ui show following swagger-ui page.

Render axum server source code using your custom jinja2 template.
use mandolin;
use serde_yaml;
use fs;
version
- 0.2.3 add binary target
- 0.2.2 Fix bugs about no content response
- 0.2.1 Add impl AsRef<axum::http::Requestaxum::body::Body> for Requests
- 0.2.0
- update README.md
- fix many bugs.
- support parse multipart/form-data
- support catch-all path arguments like /files/{file_path} in axum
- 0.1.13
- support date schema {type: "string", format: "date-time" or "date"}
- add &self argument in rust interface()
- 0.1.12 add target "TYPESCRIPT_HONO" https://github.com/honojs/hono
- 0.1.11 update to flatten nested schema. prepare cli-command
mandolin-cli. - 0.1.7 hotfix
- 0.1.6 independent from regex, tera
- 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 frontend 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