Skip to main content

Crate roas_overlay

Crate roas_overlay 

Source
Expand description

OpenAPI Overlay Specification — parser, validator, and applier.

Implements the OpenAPI Overlay Specification: a sidecar document format that transforms OpenAPI documents through an ordered list of JSONPath actions (update, remove, and v1.1’s copy).

§Modules

§Applying an overlay

use enumset::EnumSet;
use roas_overlay::apply::Apply;
use roas_overlay::v1_0::Overlay;

// Parse the overlay document (JSON or YAML).
let overlay: Overlay = serde_json::from_str(r#"{
    "overlay": "1.0.0",
    "info": { "title": "Example", "version": "1.0.0" },
    "actions": [
        { "target": "$.info", "update": { "description": "Patched." } }
    ]
}"#).unwrap();

// Parse the target OpenAPI document as untyped JSON.
let mut target: serde_json::Value = serde_json::from_str(r#"{
    "openapi": "3.1.0",
    "info": { "title": "API", "version": "1.0.0" },
    "paths": {}
}"#).unwrap();

// Apply the overlay in-place.
let report = overlay.apply(&mut target, EnumSet::empty()).unwrap();
assert_eq!(report.actions.len(), 1);
assert_eq!(target["info"]["description"], "Patched.");

Modules§

apply
Public surface for applying an Overlay to a target JSON document.
common
Version-agnostic helpers shared across overlay versions.
v1_0
OpenAPI Overlay v1.0 — see https://spec.openapis.org/overlay/v1.0.0.html.
validation
Validation framework for Overlay documents.