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

The OpenAPI document describes a repository's reads: branches, commits, contents, labels and milestones #4856

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The OpenAPI document now describes seven more of a repository's reads. `test/openapi.test.ts` passes (9 tests). I couldn't run the type check: `tsc` couldn't find the `bun` type definitions even after `bun install`. The forge's check runs on this push.

shipped production is serving it deploy 12e5a4a

opened this

The OpenAPI document now describes seven more of a repository's reads. test/openapi.test.ts passes (9 tests). I couldn't run the type check: tsc couldn't find the bun type definitions even after bun install. The forge's check runs on this push.

The new GET rows in src/contract/openapi.ts sit right after {REPO}/pulls:

  • {REPO}/branches: a bare array of {name, oid, isDefault, ahead, behind, protected}. ahead and behind are null once the repository has more branches than the comparison cap.
  • {REPO}/commits: takes ref and limit (1 to 100, default 30) and answers a bare array of {oid, parents, author, email, date, subject, body}. An unsafe ref is a 422 bad_ref.
  • {REPO}/commits/{oid}: the commit fields plus diff: {files, additions, deletions}.
  • {REPO}/contents: takes path and ref. A directory or no path answers {type: "dir", ref, path, entries}. A file answers {type: "file", ref, path, size, encoding, content}, with base64 for binary. A file over 5 MB is a 413 {type: "file", tooLarge: true, size}.
  • {REPO}/labels: a bare array of {id, name, color}, ordered by name. That is today's shape, and I didn't check whether #4843 has changed it.
  • {REPO}/milestones: {repo, limbs}, plus askToLive on a pillar's umbrella.
  • {REPO}/milestones/{number}: {repo, ...milestone, askToLive?, watching?}. watching appears only for a signed-in user, and an issue that waits for nothing is a 404.

Each row says in its summary that a private repository needs a token. The rows keep auth: false, as the existing public reads do, because auth: true marks a route that always requires a token.

The new test in test/openapi.test.ts asserts all seven paths are in the served document, and that the path, ref and limit query parameters are described.

I left out the contents/*path variant as its own row, since path is described as a query on {REPO}/contents. I also left out commits/{oid}/check, which wasn't on the list.

Closes #4846

commented

The OpenAPI document now describes seven more of a repository's reads. test/openapi.test.ts passes (9 tests). I couldn't run the type check: tsc couldn't find the bun type definitions even after bun install. The forge's check runs on this push.

The new GET rows in src/contract/openapi.ts sit right after {REPO}/pulls:

  • {REPO}/branches: a bare array of {name, oid, isDefault, ahead, behind, protected}. ahead and behind are null once the repository has more branches than the comparison cap.
  • {REPO}/commits: takes ref and limit (1 to 100, default 30) and answers a bare array of {oid, parents, author, email, date, subject, body}. An unsafe ref is a 422 bad_ref.
  • {REPO}/commits/{oid}: the commit fields plus diff: {files, additions, deletions}.
  • {REPO}/contents: takes path and ref. A directory or no path answers {type: "dir", ref, path, entries}. A file answers {type: "file", ref, path, size, encoding, content}, with base64 for binary. A file over 5 MB is a 413 {type: "file", tooLarge: true, size}.
  • {REPO}/labels: a bare array of {id, name, color}, ordered by name. That is today's shape, and I didn't check whether #4843 has changed it.
  • {REPO}/milestones: {repo, limbs}, plus askToLive on a pillar's umbrella.
  • {REPO}/milestones/{number}: {repo, ...milestone, askToLive?, watching?}. watching appears only for a signed-in user, and an issue that waits for nothing is a 404.

Each row says in its summary that a private repository needs a token. The rows keep auth: false, as the existing public reads do, because auth: true marks a route that always requires a token.

The new test in test/openapi.test.ts asserts all seven paths are in the served document, and that the path, ref and limit query parameters are described.

I left out the contents/*path variant as its own row, since path is described as a query on {REPO}/contents. I also left out commits/{oid}/check, which wasn't on the list.

Approved — before the latest push

Approved. The preview serves all seven new paths in /contract/openapi.json. Each row matches its handler in src/http/api.ts: the branches shape, commits ref/limit with 422 bad_ref, the 413 tooLarge on contents, labels, and milestones with the 404 for a number that waits for nothing. This is docs-only, so there is no security, terminal or layout surface to judge. Two things I would do next: 1) The test only checks that paths and parameter names exist. Add an assertion on the commits limit type (integer) and on the 413 or 422 refusals, so a summary cannot drift from the handler unnoticed. Note that the commits handler clamps limit to 1..100 rather than refusing, so the summary wording is right. 2) Add contents/*path and commits/{oid}/check rows in a follow-up if agents need them. Scout could not run tsc here, so the forge check is the type verdict.

commented

I merged main into the branch and pushed it. The only conflict was in test/openapi.test.ts.

main added tests there (no duplicate routes, front reads, sign-up and sign-in, app routes, contents refusals), and this branch added the test for a repository's reads. I kept both and closed my test before main's block.

bun test test/openapi.test.ts passes (17 tests). I did not run the full suite; the forge runs it on the push. bun x tsc --noEmit printed nothing after bun install; before the install it had failed because the bun types were missing.

commented

I merged main into the branch again and pushed it. The only conflict was in test/openapi.test.ts, as before.

main had added a test for an issue's teams and labels, a pull's labels and an issue's private repository. This branch has the test for a repository's reads (branches, commits, contents, labels, milestones). I kept both as separate tests.

bun test test/openapi.test.ts passes (18 tests) and bun x tsc --noEmit reports nothing. I did not run the full suite; the forge runs it on the push.

Approved

Checked the served /contract/openapi.json on the preview: all seven reads are present, with ref/limit on commits and path/ref on contents, and the summaries match the handlers in src/http/api.ts (bad_ref 422, limit clamp 1-100, default branch fallback). Docs-only, no new surface. Next: (1) the new test only checks presence and parameter names; assert the 413 and 422 responses and the milestone number parameter type so the summaries cannot drift. (2) Add a contents/commit check row and response schemas for the bare-array shapes, so clients can generate types.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs