Public: anyone can read this; the crew can change it.

API shapes: no silent type changes (approvedAt became an object); contract-test responses against openapi.json #17945

opened this in answer to

Merged 22h 13m ago, live in production

GET /api/v1/repos/{o}/{r}/pulls/{n} again returns approvedAt as a date string, or null, as it did before #16761. The {at, head, base, current} object now sits in a new field, approval. approvedAgainst is unchanged.

Notes

opened this

GET /api/v1/repos/{o}/{r}/pulls/{n} again returns approvedAt as a date string, or null, as it did before #16761. The {at, head, base, current} object now sits in a new field, approval. approvedAgainst is unchanged. A typed client decodes the pull again, and one that already read the object switches to approval.

The contract is updated to match: PullDetail declares approvedAt as a string or null and adds approval. The route's description says the same.

  • Contract test: test/support/conforms.ts is a small checker for the schema parts the contract's own helpers write. test/approval-base.test.ts runs it on the real approved-pull answer against the schema openapi() declares. If a field changes type or goes missing, the test fails. test/support/conforms.test.ts shows the checker catches an object where a string is declared.
  • Changelog: docs/features/api-shape-changes.md lists this change and the known bends: next_cursor as number or string, comments as a count or an array, and /user/repos returning a bare array.

Not done:

  • Contract test coverage: it covers only the pull detail route, not every route's samples. I did not wire all route samples into it. Other tests can call the same checker as they gain samples.
  • GET /api/v1/changes: this feed is not built; the doc page is the changelog for now.
  • Other shape bends: I fixed none of them. Each needs its own new field or a version.
  • Terminal screen: no terminal screen shows approvedAt. The commit line says No door: for that reason.

Tests: the approval and OpenAPI tests pass (684 pass), the test/feature* tests pass (120 pass), and tsc is clean. I did not run the full suite.

To try: fetch an approved pull on the preview and check that approvedAt is a string and approval.current is a boolean. Run bun test test/approval-base.test.ts.

Closes #17944

commented

GET /api/v1/repos/{o}/{r}/pulls/{n} again returns approvedAt as a date string, or null, as it did before #16761. The {at, head, base, current} object now sits in a new field, approval. approvedAgainst is unchanged. A typed client decodes the pull again, and one that already read the object switches to approval.

The contract is updated to match: PullDetail declares approvedAt as a string or null and adds approval. The route's description says the same.

  • Contract test: test/support/conforms.ts is a small checker for the schema parts the contract's own helpers write. test/approval-base.test.ts runs it on the real approved-pull answer against the schema openapi() declares. If a field changes type or goes missing, the test fails. test/support/conforms.test.ts shows the checker catches an object where a string is declared.
  • Changelog: docs/features/api-shape-changes.md lists this change and the known bends: next_cursor as number or string, comments as a count or an array, and /user/repos returning a bare array.

Not done:

  • Contract test coverage: it covers only the pull detail route, not every route's samples. I did not wire all route samples into it. Other tests can call the same checker as they gain samples.
  • GET /api/v1/changes: this feed is not built; the doc page is the changelog for now.
  • Other shape bends: I fixed none of them. Each needs its own new field or a version.
  • Terminal screen: no terminal screen shows approvedAt. The commit line says No door: for that reason.

Tests: the approval and OpenAPI tests pass (684 pass), the test/feature* tests pass (120 pass), and tsc is clean. I did not run the full suite.

To try: fetch an approved pull on the preview and check that approvedAt is a string and approval.current is a boolean. Run bun test test/approval-base.test.ts.

commented

I fixed the three places that still described the old shape, so approval is now the only object description. This is wording only, with no code change.

  • docs/features/approval-base.md:10: the how-to now says the pull API carries approval: { at, head, base, current } and approvedAt, the date string of that approval. Both are null when no one's latest verdict approves.
  • src/core/approval_at.ts:33: the comment now says approval carries the same facts as the one-line form.
  • test/approval-base.test.ts:4: the header now says approval.base.

tsc --noEmit is clean, test/approval-base.test.ts passes (4 tests), and scripts/gate.ts --fix left nothing to rewrap. I did not run the full suite. The commit line carries the issue number (#17944). No exports, module-level state, or test inputs changed, so the other check rules are untouched.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs