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
Check · Review · Land · Live done — Landed and live in production.
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 cc21c84
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}.aheadandbehindare null once the repository has more branches than the comparison cap.{REPO}/commits: takesrefandlimit(1 to 100, default 30) and answers a bare array of{oid, parents, author, email, date, subject, body}. An unsafe ref is a 422bad_ref.{REPO}/commits/{oid}: the commit fields plusdiff: {files, additions, deletions}.{REPO}/contents: takespathandref. 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}, plusaskToLiveon a pillar's umbrella.{REPO}/milestones/{number}:{repo, ...milestone, askToLive?, watching?}.watchingappears 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. 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.
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.
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.
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.
The OpenAPI document now describes seven more of a repository's reads.
test/openapi.test.tspasses (9 tests). I couldn't run the type check:tsccouldn't find thebuntype definitions even afterbun install. The forge's check runs on this push.The new GET rows in
src/contract/openapi.tssit right after{REPO}/pulls:{REPO}/branches: a bare array of{name, oid, isDefault, ahead, behind, protected}.aheadandbehindare null once the repository has more branches than the comparison cap.{REPO}/commits: takesrefandlimit(1 to 100, default 30) and answers a bare array of{oid, parents, author, email, date, subject, body}. An unsafe ref is a 422bad_ref.{REPO}/commits/{oid}: the commit fields plusdiff: {files, additions, deletions}.{REPO}/contents: takespathandref. 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}, plusaskToLiveon a pillar's umbrella.{REPO}/milestones/{number}:{repo, ...milestone, askToLive?, watching?}.watchingappears 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, becauseauth: truemarks a route that always requires a token.The new test in
test/openapi.test.tsasserts all seven paths are in the served document, and that thepath,refandlimitquery parameters are described.I left out the
contents/*pathvariant as its own row, sincepathis described as a query on{REPO}/contents. I also left outcommits/{oid}/check, which wasn't on the list.Closes #4846