Skip to content

test(openapi): guard client SDK route coverage against openapi.json (#310) - #350

Open
phatloi0010 wants to merge 1 commit into
Miracle656:mainfrom
phatloi0010:test/client-route-coverage-guard-310
Open

phatloi0010 wants to merge 1 commit into
Miracle656:mainfrom
phatloi0010:test/client-route-coverage-guard-310

Conversation

@phatloi0010

Copy link
Copy Markdown

Summary

Adds src/__tests__/clientCoverage.test.ts to compare the routes covered by each official client SDK (clients/react-query, clients/go, clients/python) against the committed openapi.json specification.

Closes #310

Changes

  1. src/__tests__/clientCoverage.test.ts:
    • Implemented route extractors for all three client packages:
      • collectReactQueryRoutes(): walks clients/react-query/src/hooks/*.ts for client.<VERB>("<path>") calls.
      • collectGoRoutes(): walks clients/go/<pkg>/*.go for <client>.c.<Verb>(ctx, <path>, ...) calls, normalising url.PathEscape(...) and strconv.FormatInt(..., 10) segments into OpenAPI {param} syntax.
      • collectPythonRoutes(): reads clients/python/wraith/client.py for self._<verb>(...) calls, normalising f-string placeholders ({tx_hash}) to OpenAPI parameter names ({txhash}).
    • Defined SHARED_NON_CLIENT_ROUTES (for x-internal: true routes, operational probes /healthz, /readyz, /metrics, and CSV/Parquet file streams) and KNOWN_UNCOVERED_BY_CLIENT recording today's exact per-client gaps so the check starts green.
    • Implemented evaluateClientCoverage() with bidirectional allow-list enforcement: fails naming both the client and the route when a new spec route is missing from a client, and also fails when a newly-implemented route is left on the allow-list so the allow-list can only shrink.
    • Added unit tests verifying:
      • Each client (react-query, go, python) covers every route in openapi.json not on its allow-list.
      • Extractor anchor assertions (guards the guard) confirming real routes are discovered in each client.
      • Adding a synthetic route to openapi.json fails the check and names both the route and each client (react-query, go, python).
      • Leaving a newly-covered route on the allow-list fails naming the client and route.

Verification

  • npm run typecheck: PASS (0 errors)
  • npx tsc --noEmit: PASS (0 errors)
  • npx jest src/__tests__/clientCoverage.test.ts src/__tests__/openapiCoverage.test.ts: PASS (13/13 tests passing)

This branch has not been deployed

No deployments
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.

Nothing notices when a client falls behind the API

1 participant