From 0c17343a502a13ec2e27464977c10b975c406346 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Thu, 2 Jul 2026 17:53:33 +0000 Subject: [PATCH] fix(mgmt): version-agnostic OpenAPI drift test + regenerate the 0.5.0 snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The snapshot comparison now normalizes info.version on both sides and compares structurally — a version bump alone can never invalidate the checked-in spec again (the 0.5.0 release tripped on exactly this; the API surface is what drift-control protects). Snapshot regenerated so the docs-site copy shows the current version. Co-Authored-By: Claude Fable 5 --- api/openapi.json | 2 +- crates/punktfunk-host/src/mgmt.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/api/openapi.json b/api/openapi.json index b6bb79c..e4c3496 100644 --- a/api/openapi.json +++ b/api/openapi.json @@ -10,7 +10,7 @@ "name": "MIT OR Apache-2.0", "identifier": "MIT OR Apache-2.0" }, - "version": "0.4.2" + "version": "0.5.0" }, "paths": { "/api/v1/clients": { diff --git a/crates/punktfunk-host/src/mgmt.rs b/crates/punktfunk-host/src/mgmt.rs index 24908b6..ba7edf1 100644 --- a/crates/punktfunk-host/src/mgmt.rs +++ b/crates/punktfunk-host/src/mgmt.rs @@ -2310,11 +2310,17 @@ mod tests { ); let checked_in = include_str!("../../../api/openapi.json"); - // Compare content, not line-ending style: the generated `json` is LF (serde_json), but git - // may check the file out CRLF on Windows. + // Compare STRUCTURALLY with `info.version` normalized on both sides: the served document + // stamps the live crate version, but a version bump alone must never invalidate the + // snapshot — the API *surface* is what drift-control protects (the 0.5.0 release tripped + // on exactly this). Structural comparison also makes line endings a non-issue (git may + // check the file out CRLF on Windows). + let mut generated = doc; + let mut snapshot: serde_json::Value = serde_json::from_str(checked_in).unwrap(); + generated["info"]["version"] = serde_json::json!(""); + snapshot["info"]["version"] = serde_json::json!(""); assert_eq!( - json.trim().replace('\r', ""), - checked_in.trim().replace('\r', ""), + generated, snapshot, "api/openapi.json is stale — regenerate with: \ cargo run -p punktfunk-host -- openapi > api/openapi.json" );