Skip to content

Commit d057a69

Browse files
authored
Add property-level OpenAPI-to-Rust contract coverage (#83)
Enrich the pinned OpenAPI snapshot with normalized structural schemas and per-operation request and response schema graphs. Add a machine-readable contract for 34 generated and handwritten Rust wire models. hubuum_reconcile now parses the actual Rust structs and fails on field, Serde direction, requiredness, operation reachability, or stale documented-exception drift. Document the intentional point/list projection and runtime/OpenAPI differences, and add regressions for relation cardinalities, import timestamps, and export timings that were previously omitted in v0.0.8. This adds repository validation without changing the public client API, runtime behavior, declared v0.0.9 server target, or MSRV. Closes #65
1 parent 9939b5b commit d057a69

10 files changed

Lines changed: 17632 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on Keep a Changelog, and this project aims to follow Semanti
88

99
### Added
1010

11+
- Add machine-checked property-level reconciliation between pinned OpenAPI
12+
schemas and 34 generated or handwritten Rust wire models, including explicit
13+
point/list projection exceptions and regressions for relation cardinalities,
14+
import timestamps, and export timings.
1115
- Create or update a GitHub Release from the matching dated changelog section
1216
after crate publication, with an idempotent backfill for existing stable tags
1317
and the newest stable release marked as `Latest`.

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/code-generation.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ do not run a procedural macro or a build script.
1313
reconciliation behavior.
1414
- `hubuum_reconcile/src/generate.rs` contains the specification model,
1515
validation, and rendering rules.
16+
- `openapi/operations.json` is the normalized operation and structural schema
17+
inventory generated from the pinned server specification.
18+
- `openapi/model-contract.json` maps relevant OpenAPI schemas to generated and
19+
handwritten Rust wire structs. The reconciler parses the actual Rust source
20+
and verifies field names, Serde behavior, requiredness, and documented
21+
exceptions.
1622
- `src/resources/generated/*.rs` is generated, reviewed, and committed.
1723
- The handwritten files under `src/resources` include the generated output and
1824
continue to own resource-specific behavior.
@@ -60,6 +66,9 @@ CI and the release preflight run `check`, which fails when committed output is
6066
missing or stale. Generation uses the repository's `rustfmt`; it performs no
6167
network access and is not part of `hubuum_client`'s crates.io package.
6268

63-
OpenAPI operation reconciliation remains a separate contract check in
64-
`scripts/openapi-contract.py`. The normalized OpenAPI snapshot does not contain
65-
enough property-level detail to generate these resource models directly.
69+
When the pinned server target changes, update `openapi/operations.json`, update
70+
the affected Rust models and `openapi/model-contract.json`, and document every
71+
intentional omission or projection difference in `openapi/known-gaps.md`. Run
72+
`cargo run -p hubuum_reconcile --locked -- check` to verify both generated
73+
resource files and property-level model reconciliation. Matching endpoint paths
74+
alone is not sufficient evidence that the wire models still match the server.

hubuum_reconcile/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ description = "Repository-local generator for hubuum_client resource code."
1010
[dependencies]
1111
proc-macro2 = "1.0"
1212
quote = "1.0"
13+
serde = { version = "1", features = ["derive"] }
14+
serde_json = "1"
1315
syn = { version = "3", features = ["full"] }

hubuum_reconcile/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![forbid(unsafe_code)]
22

33
mod generate;
4+
mod openapi_contract;
45

56
use std::{
67
env, fs, io,
@@ -34,6 +35,7 @@ fn main() -> Result<(), DynError> {
3435

3536
fn reconcile(mode: Mode) -> Result<(), DynError> {
3637
let root = repository_root()?;
38+
openapi_contract::check(&root)?;
3739
let mut stale = Vec::new();
3840
let mut updated = 0;
3941

0 commit comments

Comments
 (0)