Skip to content

test: check the apps' OBP-API calls against a contract - #14

Closed
hongwei1 wants to merge 6 commits into
OpenBankProject:mainfrom
hongwei1:test/obp-api-contract
Closed

hongwei1 wants to merge 6 commits into
OpenBankProject:mainfrom
hongwei1:test/obp-api-contract

Conversation

@hongwei1

Copy link
Copy Markdown
Contributor

This PR adds a contract between the apps and OBP-API, checked by the unit tests without a server. obp-api-contract/contract.json lists the 644 OBP-API calls that the Portal, API Manager, Cohort and the shared package make, each with its verb, path, source file, the text in that file that makes the call, and the response fields the code reads. It also lists the source lines that name an OBP-API path without calling one, such as help text and path helpers. obp-api-contract/snapshot.json is what OBP-API documents for those calls, written by python3 -I obp-api-contract/snapshot.py --base https://k8s.openbankproject.com from the public resource docs. packages/shared/src/lib/server/obp/obpApiContract.test.ts runs with npm run test:unit and fails when a listed call is no longer in its file, when a source line builds an OBP-API path that the contract does not list, when the snapshot was taken for a different list, or when a call reaches no documented endpoint or reads a field the docs leave out. Known gaps are recorded per call in undocumented_endpoint and undocumented_fields (5 endpoints and 83 calls with fields). A gap that OBP-API later documents also fails, so the record shrinks. To check a new OBP-API build, run snapshot.py against it and run the tests.

Not covered yet: the Portal's Berlin Group and UK Open Banking calls, calls through the generic proxy whose path the browser chooses, and records of the Dynamic Entities the apps define themselves.

A literal path segment also matches a documented placeholder, so a call whose own endpoint is gone could match a neighbouring endpoint when the snapshot is retaken, and the tests would pass against the wrong fields. snapshot.py now compares each call's operation with the snapshot.json already on disk: if one differs it lists the calls and writes nothing, unless --accept-rebind is given. A path with no /obp/vX.Y.Z prefix is recorded as missing and unversioned instead of stopping the script. The file is the same in every repository that keeps an OBP-API contract.
…reads

The scan now also sees ${V}/ builders, /obp/v${major}, '/obp/' + version, a '/obp' base constant, any /vN.N.N/ segment, /obp/dynamic-entity paths and .mjs/.cjs/.mts/.cts files. The lines it newly sees are listed under not_calls. contract.json says that scripts outside src are out of scope.
@hongwei1

Copy link
Copy Markdown
Contributor Author

Merged into #15, which carries these commits together with the three call fixes.

@hongwei1 hongwei1 closed this Nov 18, 2026
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