Skip to content

Pin API contract 1.0.0 and check every call against it - #8

Merged
imronreviady merged 1 commit into
mainfrom
openapi-contract
Oct 3, 2026
Merged

imronreviady merged 1 commit into
mainfrom
openapi-contract

Conversation

@imronreviady

Copy link
Copy Markdown
Collaborator

Why

LiveXFace/backend#8: each SDK release must say which API contract it was validated against and prove its calls exist in it.

What changed

  • CONTRACT_VERSION (1.0.0), the contract committed as contract/openapi-1.0.0.json (byte-identical to the backend's docs/openapi.json), a public version constant and a README line on how to move to a new contract.
  • A contract test: every public method is called against a stub; each request's HTTP method and path must match a contract operation and send every required field (images[N] / frame_N count for images[0] / frame_0). A guard fails on a public method the check does not call, and a test ties the constant to the file and the contract's info.version.
  • No change to SDK behaviour; no new dependencies.

Verification

  • Every SDK method maps to a contract operation; no call to a route outside the contract.
  • The check fails when a path is changed to one that does not exist, when a required field is renamed, and when an unchecked public method is added (each tried and reverted).
  • The repository's CI commands pass locally on the matrix versions.

The SDK now states the API contract version it was validated against:
a CONTRACT_VERSION file, a public constant and a README line, with the
contract itself committed under contract/openapi-1.0.0.json (the
backend repository is private, so CI cannot download it).

A contract test calls every public method with a stubbed transport and
checks that each request's method and path exist in the pinned contract
and that every field the contract marks required is sent. A guard fails
when a public method is added without being covered by the check.
@imronreviady
imronreviady merged commit 2047085 into main Oct 3, 2026
2 checks passed
@imronreviady
imronreviady deleted the openapi-contract branch October 3, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant