Skip to main content

Module contract_diff_api

Module contract_diff_api 

Source
Expand description

Contract diff retrieval API Contract-diff retrieval API.

The contract_diff_middleware already captures every incoming request into the global CaptureManager. Until now there was no HTTP surface to read those captures back out or to run the diff analyser against the deployment’s OpenAPI spec — the audit’s PR-3 gap.

§Endpoints (mounted under /__mockforge/api/contract-diff)

  • GET /captures?limit=<n> → recent captures (default 100, capped 1000)
  • GET /captures/{id} → single capture
  • POST /analyze/{id} → analyse one capture against the spec
  • POST /analyze → analyse the most recent N captures (defaults to 50)
  • DELETE /captures → wipe the in-memory store
  • GET /statistics → simple counters from CaptureManager

Analysis loads the OpenAPI spec from the path the server was started with (spec_path carried in this module’s state). A redeploy with a new spec naturally takes effect on the next request.

Structs§

ContractDiffApiState
Shared state for the contract-diff API. Cloneable.

Functions§

contract_diff_api_router
Build the contract-diff API router. Mount under /__mockforge/api/contract-diff.