mandolin
Mandolin is a tool to generate server-side code from OpenAPI specifications (YAML/JSON). It currently supports:
Mandolin adopts a "Logic in Templates" design philosophy, where Rust handles data preparation and $ref resolution, while templates handle the code assembly.
Getting started
Install mandolin from source:
Render axum server code using builtin "RUST_AXUM" template:
Using pipes:
|
You can also use mandolin as library
Mandolin exposes a simple API mandolin::environment that returns a configured Minijinja environment.
use mandolin;
use OpenAPI;
Example of generated code
The generated code defines a trait ApiInterface. You only need to implement this trait.
// This is generated by mandolin
use axum;
use serde;
use Future;
// ... Request/Response structs and Router definition follows ...
Running the generated server with your implementation
You can import the generated module and implement the trait to build your server.
// The file generated by mandolin
use *;
use ;
use TcpListener;
// Implement the business logic
async
Custom Templates
You can easily use your own templates.
Dependencies are minimized, and helpers like include_ref are no longer needed because $ref is pre-resolved.
use mandolin;
use OpenAPI;
use fs;
Version History
-
0.4.0-alpha.1
- Major Re-architecture: "Logic in Templates".
- Moved logic from Rust to templates.
$refis now pre-resolved in Rust.- Templates are consolidated into single files (no more
includehell). - TypeScript (Hono) support improved.
-
0.2.5
- Improve
rust_axum.templateto correctly setContent-Typeheader
- Improve
-
0.2.4
- Internal bug fixes and improvements to response handling
-
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
- support parse multipart/form-data
- support catch-all path arguments
-
0.1.13 support date schema
-
0.1.12 add target "TYPESCRIPT_HONO"
-
0.1.0 publish
My favorite mandolin music
- 月に舞う/武藤理恵 https://youtu.be/OVKkRj0di2I
- Suite Spagnola/C.Mandonico https://youtu.be/fCkcP_cuneUU