roas 0.9.0

Rust OpenAPI Specification
Documentation

roas

Rust OpenAPI Specification (v2.0, v3.0.X, v3.1.X and v3.2.X) parser and generator.

crates.io docs.rs

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:

[dependencies]
roas = "0.8"

The default feature is v3_2. To parse v2.0, v3.0 or v3.1 specs, enable the corresponding feature:

[dependencies]
roas = { version = "0.7", default-features = false, features = ["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 roas::v3_2::spec::Spec;
use roas::validation::{Options, Validate};

let raw_json = r#"{ "openapi": "3.2.0", "info": { "title": "demo", "version": "1" }, "paths": {} }"#;
let spec: Spec = serde_json::from_str(raw_json).unwrap();
spec.validate(Options::IgnoreMissingTags | Options::IgnoreExternalReferences).unwrap();