roas_arazzo/lib.rs
1//! OpenAPI Arazzo Specification — parser and validator.
2//!
3//! Implements the [Arazzo Specification](https://spec.openapis.org/arazzo/v1.0.1.html):
4//! a document format that describes sequences of API calls (*workflows*)
5//! and their dependencies, independent of the underlying OpenAPI
6//! descriptions they orchestrate.
7//!
8//! ## Modules
9//!
10//! - [`common`] — version-agnostic helpers: the `x-` extensions serde
11//! helper.
12//! - [`validation`] — [`Validate`](validation::Validate) trait,
13//! [`ValidationOptions`](validation::ValidationOptions) flag set,
14//! `Context` / `ValidationError` types.
15//! - [`v1_0`] — Arazzo v1.0 document model + `Validate` impls.
16//!
17//! ## Parsing and validating
18//!
19//! ```rust
20//! use enumset::EnumSet;
21//! use roas_arazzo::v1_0::Description;
22//! use roas_arazzo::validation::Validate;
23//!
24//! // Parse an Arazzo description (JSON or YAML).
25//! let doc: Description = serde_json::from_str(r#"{
26//! "arazzo": "1.0.1",
27//! "info": { "title": "Example", "version": "1.0.0" },
28//! "sourceDescriptions": [
29//! { "name": "petStore", "url": "https://api.example.com/openapi.json", "type": "openapi" }
30//! ],
31//! "workflows": [
32//! {
33//! "workflowId": "getPet",
34//! "steps": [
35//! {
36//! "stepId": "findPet",
37//! "operationId": "getPetById",
38//! "successCriteria": [ { "condition": "$statusCode == 200" } ]
39//! }
40//! ]
41//! }
42//! ]
43//! }"#).unwrap();
44//!
45//! doc.validate(EnumSet::empty()).expect("description is well-formed");
46//! assert_eq!(doc.workflows[0].workflow_id, "getPet");
47//! ```
48//!
49//! YAML descriptions work the same way — parse with `serde_yaml_ng` (or
50//! any other YAML crate) into [`v1_0::Description`].
51//!
52//! ## Versions
53//!
54//! v1.0.x ([`v1_0`], default feature) and v1.1.x ([`v1_1`]) are both
55//! implemented; enable whichever you need. With both features enabled,
56//! an `impl From<v1_0::Description> for v1_1::Description` is available
57//! for upconverting an existing v1.0 description.
58
59pub mod common;
60pub mod validation;
61
62#[cfg(feature = "v1_0")]
63pub mod v1_0;
64
65#[cfg(feature = "v1_1")]
66pub mod v1_1;