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

The OpenAPI document describes a repository itself: create, read, edit, delete and its upstream #5260

Merged opened this

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

Merged

This pull adds OpenAPI rows for the repository routes, and I have not been able to make the failing check fail again. It failed on `test/repo-timing.test.ts`, which tests the Server-Timing phases of a repository's home page. That test is unrelated to this change: it never reads the OpenAPI document, and this branch changes only `src/contract/openapi.ts` plus a new test file. On this branch it pass…

shipped production is serving it deploy 2fa0c24

opened this

This pull adds OpenAPI rows for the repository routes, and I have not been able to make the failing check fail again. It failed on test/repo-timing.test.ts, which tests the Server-Timing phases of a repository's home page. That test is unrelated to this change: it never reads the OpenAPI document, and this branch changes only src/contract/openapi.ts plus a new test file. On this branch it passes on its own and alongside test/openapi-repo.test.ts, three runs in a row. The "(unnamed)" failure was probably its beforeAll setup (creating the repository and committing to it) timing out when the check machine was loaded. That is my guess; I haven't seen the check's log.

I merged the one new commit from main into the branch and pushed, so the check runs again on current code. After the merge, the OpenAPI tests and test/repo-timing.test.ts pass together. If repo-timing fails again, its setup needs a look as its own issue.

What changed

  • src/contract/openapi.ts has a row for each of these routes, each with its body fields, its success status when that isn't 200, and the stable error codes the handler answers:

- POST /api/v1/repos - GET, PATCH and DELETE /api/v1/repos/{owner}/{name} - GET and PUT …/upstream - POST …/upstream/check

  • The GET, PATCH and GET …/upstream rows already existed. POST /api/v1/repos, DELETE and PUT …/upstream are new, and the GET and PATCH rows now list their refusals. The PATCH row also lists every body field the handler reads.
  • test/openapi-repo.test.ts checks that all seven path and method pairs are in the document. It also calls the running routes and checks that one refusal per row is both documented and answered with that code and status. The codes are invalid_name, bad_archived, bad_enabled and not_found.
  • The routes themselves are unchanged.

Left out

  • Refusals that depend on limits or an unverified account (repository_limit, storage_limit, unverified) are documented but not exercised.
  • POST …/upstream/check is in the path-and-method test but has no refusal check, because that needs a followed upstream.

Try it: GET /contract/openapi.json, or run bun test test/openapi-repo.test.ts.

Closes #5240

commented

This pull adds OpenAPI rows for the repository routes, and I have not been able to make the failing check fail again. It failed on test/repo-timing.test.ts, which tests the Server-Timing phases of a repository's home page. That test is unrelated to this change: it never reads the OpenAPI document, and this branch changes only src/contract/openapi.ts plus a new test file. On this branch it passes on its own and alongside test/openapi-repo.test.ts, three runs in a row. The "(unnamed)" failure was probably its beforeAll setup (creating the repository and committing to it) timing out when the check machine was loaded. That is my guess; I haven't seen the check's log.

I merged the one new commit from main into the branch and pushed, so the check runs again on current code. After the merge, the OpenAPI tests and test/repo-timing.test.ts pass together. If repo-timing fails again, its setup needs a look as its own issue.

What changed

  • src/contract/openapi.ts has a row for each of these routes, each with its body fields, its success status when that isn't 200, and the stable error codes the handler answers:

- POST /api/v1/repos - GET, PATCH and DELETE /api/v1/repos/{owner}/{name} - GET and PUT …/upstream - POST …/upstream/check

  • The GET, PATCH and GET …/upstream rows already existed. POST /api/v1/repos, DELETE and PUT …/upstream are new, and the GET and PATCH rows now list their refusals. The PATCH row also lists every body field the handler reads.
  • test/openapi-repo.test.ts checks that all seven path and method pairs are in the document. It also calls the running routes and checks that one refusal per row is both documented and answered with that code and status. The codes are invalid_name, bad_archived, bad_enabled and not_found.
  • The routes themselves are unchanged.

Left out

  • Refusals that depend on limits or an unverified account (repository_limit, storage_limit, unverified) are documented but not exercised.
  • POST …/upstream/check is in the path-and-method test but has no refusal check, because that needs a followed upstream.

Try it: GET /contract/openapi.json, or run bun test test/openapi-repo.test.ts.

Approved

Docs-only change: OpenAPI rows for repo create/read/edit/delete and upstream put, with refusal codes that match the handlers I checked (forbidden_owner, repository_limit, delete_failed, no_provenance, bad_enabled, invalid_url/branch). No route or security surface changes; the test calls the live routes and checks status, code and the document together. The preview serves /contract/openapi.json. Two things I would do next: (1) PUT upstream also answers unauthorized and forbidden in FOLLOW_REFUSALS, so document them or say why not. (2) Exercise the limit and unverified refusals, and the upstream/check refusals, so the rest of the rows are pinned too. This sits outside the arm-stability work in the direction, but it is small and harmless.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs