#swagger #actix-web #openapi #codegen #cli

app cargo-swagg

Code generator from swagger file for actix-web framework

3 releases (breaking)

0.3.0 May 13, 2020
0.1.0 Mar 30, 2020
0.0.0 Jan 20, 2020

#73 in #swagger

Download history 1/week @ 2024-02-14 6/week @ 2024-02-21 2/week @ 2024-02-28 2/week @ 2024-03-06 5/week @ 2024-03-13 20/week @ 2024-03-27 31/week @ 2024-04-03

51 downloads per month

MIT license

125KB
3K SLoC

actix swagger

Usage

Not for production use yet

# Add cargo command to simplify usage
cargo install cargo-swagg

# Add support library to your project (via cargo-edit or manual)
cargo add actix-swagger

# Generate your code with cargo subcommand
cargo swagg ./openapi.yaml --out-file ./src/api.rs

# Format file after
rustfmt ./src/api.rs

Development

It uses insta for snapshot testing.

Install cargo-insta to better review experience.

Members

  • cargo-actix — support library, contents typed response named Answer and custom Method and ContentType that supports in swagg
  • swagg — library that transforms openapi3 (yaml|json) spec to rust code
  • cargo-swagg — same as swagg but for cli
  • demo — checks that generated code is compiles

Demo

# to convert ./demo/openapi.yaml to ./demo/src/lib.rs
# format ./demo/src/lib.rs
# and check just run
cargo install cargo-make
cargo make

Dependencies

~5–16MB
~174K SLoC