Expand description
brake — a brake on breaking API changes.
Compares an API contract against its previous version and reports changes that would break a consumer. Hermetic by construction: no network, no toolchain, no running service.
The public surface below is the one design/03-implementation-plan.md §3
fixes, and it is deliberately small — every item in it is a compatibility
obligation on a tool whose entire subject is compatibility obligations.
use brake::{Format, Level};
let base = brake::parse(Format::Openapi, "api/openapi.yaml", b"
openapi: 3.1.0
paths:
/payments:
get:
operationId: listPayments
responses:
\"200\": { description: ok }
").expect("base parses");
let head = brake::parse(Format::Openapi, "api/openapi.yaml", b"
openapi: 3.1.0
paths: {}
").expect("head parses");
let changes = brake::compare(&base, &head);
let findings = brake::evaluate(&changes, "payments", Level::WireJson);
assert!(findings.iter().any(|f| f.rule_id == "endpoint-removed"));Re-exports§
pub use crate::check::Options;pub use crate::check::Scope;pub use crate::compare::Change;pub use crate::config::Compatibility as Level;pub use crate::config::Config;pub use crate::contract::Contract;pub use crate::contract::DocumentResolver;pub use crate::contract::FileSystemResolver;pub use crate::contract::InMemoryResolver;pub use crate::contract::SingleDocumentResolver;pub use crate::report::Report;pub use crate::rules::Finding;
Modules§
- baseline
- Resolving a contract’s previous version.
- check
- The orchestration: config → baseline → ingest → compare → rules → report.
- compare
Contract×Contract→Change.- config
- contract
- The normalised contract model.
- demand
- Consumer demand — the third input.
- init
brake init— discover the contracts in a repository and write abrake.tomlthat declares them.- mcp
- The MCP server: the same ruleset, consulted at edit time.
- render
- report
Finding→ verdict, and the exit-code contract.- rules
Change×Level→Finding.- surface
- What each surface can do, and why a surface lacks what it lacks.
Enums§
Constants§
- VERSION
- The version reported by
brake --version, fromCargo.toml.
Functions§
- compare
- Compare two contracts, reporting everything that differs.
- evaluate
- Turn changes into findings at a compatibility level.
- lint
- Structural defects
headintroduces thatbasedoes not already have. - parse
- Ingest one contract artifact from bytes.
- parse_
with_ resolver - Ingest one contract artifact from bytes using a custom
DocumentResolver.
Type Aliases§
- Format
- A contract format brake can ingest.