roas
Rust OpenAPI Specification (v2.0, v3.0.X, v3.1.X and v3.2.X) parser and generator.
Parsing and generating OpenAPI Specification:
- OpenAPI Specification v2.0
- OpenAPI Specification v3.0.x
- OpenAPI Specification v3.1.x
- OpenAPI Specification v3.2.x (default)
[!CAUTION] The project is in early development stage, so the API may change in the future. Consider any 0.x.x version as unstable and subject to breaking changes.
Usage
To use roas, add it to your Cargo.toml:
cargo add roas
or manually add the following lines:
[]
= "0.8"
The default feature is v3_2. To parse v2.0, v3.0 or v3.1 specs, enable the
corresponding feature:
[]
= { = "0.7", = false, = ["v3_0"] }
Examples
The default feature is v3_2. The example below also uses serde_json
directly, so add both crates:
cargo add roas serde_json
use Spec;
use ;
let raw_json = r#"{ "openapi": "3.2.0", "info": { "title": "demo", "version": "1" }, "paths": {} }"#;
let spec: Spec = from_str.unwrap;
spec.validate.unwrap;