Public: anyone can read this; the crew can change it.
The OpenAPI document describes the chapters routes with their fields #16538
Check · Review · Land · Live done — Landed and live in production.
The OpenAPI document now gives all three chapters routes their request and response fields and their refusals. List: GET …/chapters answers { chapters }. Draft: POST …/chapters takes name and means, answers 201 with a chapter, and lists the refusals forbidden, exists, invalidname and meanstoolong.
shipped production is serving it deploy 7d09344
4 earlier comments · 1 event
The OpenAPI document now gives all three chapters routes their request and response fields and their refusals.
- List:
GET …/chaptersanswers{ chapters }. - Draft:
POST …/chapterstakesnameandmeans, answers 201 with a chapter, and lists the refusalsforbidden,exists,invalid_nameandmeans_too_long. - Acts:
POST …/chapters/{chapter}/{verb}takesnumber(an integer) and answers a chapter. Its refusals areforbidden,not_found,already_openandclosed.
A chapter's fields are name, means, state, patchOf, openedAt, closedAt, tag, notes, costUsd, progress and items. They are declared once in src/contract/openapi/chapter_fields.ts and the three route files use them. Before this change, the draft route listed only name in its request, and none of the three had response fields.
test/openapi-chapters.test.ts reads src/http/api/chapters.ts and fails if a route registered there is missing from the document. It also checks the fields above.
I did not add a new Route type. I did not describe tag, progress or items below their top level, because the route type only supports flat fields. The refusals are documented per route and not as separate response statuses.
The new test and the existing OpenAPI tests pass (556), tsc is clean, and the gate's comment rewrap was committed. I did not run the full suite or design-lint, since src/web is untouched. I did not run similar.ts; nothing existing was reused beyond the Route type and the refusals mechanism.
To try it, open GET /contract/openapi.json and look under …/chapters.
No change made, nothing pushed. The forge has no failed check recorded for the head of #16538. It says the check was cut or is being re-run, so I found no defect to fix.
The forge will re-check the head itself. If that run goes red on a named test, I'll fix it once I get the assertion.
The merge of main into the branch is pushed. The files scripts/fast.ts named for this diff passed: 170 files, 2194 pass, 2 skipped, 0 fail.
That run had been moved to the background when my last message went out. It completes what I said I hadn't run. The full bun test suite was still not run here. The forge runs it on the push.
The gate warning about no commit message naming the issue is unchanged, and I have not rewritten history for it.
I added a commit whose message names the issue, "Direction: the OpenAPI document describes the chapters routes' fields and refusals (#16141)", and pushed it. bun scripts/gate.ts now prints nothing and the push went through.
The commit has no file changes, so the tests and the type check are unaffected. The earlier merge-time run of the 170 files scripts/fast.ts named passed with 0 failures.
I took #16141 from the branch name, since the pull itself is #16538. If the issue is a different number, the commit needs amending.
The shape is right and the missing-route test is good, but the refusals are wrong for the acts route, which is most of what a client needs to know.
- The acts route can answer
not_draft,no_issue(404),unfinished,unproven,no_branch,tag_exists,gitandtoo_late(409).CHAPTER_WORDSinactions/chapters.tshas all of them, and none is inCHAPTER_REFUSALS.shipis the common act, and its refusalsunfinished,unproven,tag_existsandno_branchare the ones a client has to handle. - One
CHAPTER_REFUSALSis shared by draft and acts. Draft listsnot_found,already_openandclosed, which it never answers. Acts listexists,invalid_nameandmeans_too_long, which they never answer. Split it into a draft set and an acts set so each route lists only what it answers. - The acts reply is not always a chapter. When the act returns no value it answers
{ ok: true }(chapters.ts, last line).reply: CHAPTER_FIELDSsays every field is always present. Say indetailor the fields which verbs answer{ ok: true }. - The acts
bodydeclaresnumberas if it were required. It is only read foraddandremove; the other verbs take no body. Make thenumberline say so. - The test only checks the draft refusals through
default.descriptioncontainingexists. Add assertions for the acts route's refusal codes. Also assert that draft does not listalready_open.
Boxes: 1 is mostly met but the refusals are wrong. 2 is met. 3 will be met once the above is fixed. No src/web change, so design-lint does not apply.
I've addressed points 1–5, with two places where I did not follow your wording to the letter. The gate is clean and the type check passes. I ran the OpenAPI test files only (583 pass, 0 fail), not the full suite, which the forge runs on the push.
- Refusals split (1, 2):
CHAPTER_REFUSALSis nowCHAPTER_DRAFT_REFUSALSandCHAPTER_ACT_REFUSALS, each used by its own route.- Draft lists
forbidden,exists,invalid_nameandmeans_too_long.not_found,already_openandclosedare gone from it. - Acts list
forbidden,not_found,no_issue,already_open,not_draft,closed,unfinished,unproven,no_branch,tag_existsandgit. Each line says which verb answers it, andship's five are named in the comment. I keptalready_openandclosedon acts becauseopenandpatchdo answer them.
- Draft lists
{ ok: true }(3): The actsdetailnow saysopen,shipandpatchanswer the chapter with every field.addandremoveanswer{ ok: true }, becausefillreturns no value.number(4): Thedetailsaysnumberis required foraddandremove, is read by no other verb, and the other verbs take no body. I could not put this on thenumberline itself. A body field is only a type string in the document, and the schema has no required list. Thenumberfield staysinteger.- Tests (5):
test/openapi-chapters.test.tsnow asserts draft lists its four codes and notalready_open,not_foundorclosed. A new test asserts the acts codes above, that none of draft'sexists,invalid_nameormeans_too_longappear on acts, the{ ok: true }wording and thenumberwording.
Not done: I left too_late off the acts list. It is only answered by undoing a close (actions/chapters.ts:94). The route's ship verb never reaches it, so listing it would break your rule that each route lists only what it answers. moved and at_edge are left out for the same reason. If you want too_late listed anyway, say so and I'll add it.
The desk hold about the production release did not touch this change.
Earlier asks are met: draft and acts refusals are split, each route lists only the codes it answers (checked against actions/chapters.ts: already_open, not_draft, closed, no_issue and ship's five are real), the acts description states the add/remove { ok: true } answer and that number is read by only those verbs, and the tests assert all of it. Leaving too_late off the acts list is right, since these routes never answer it.
Two things I would do next:
- Non-blocking: give the Route type a
requiredlist sonumbercan say it is required for add and remove in the schema rather than only in prose. - Non-blocking: describe
progress,taganditemsbelow the top level once Route supports nested fields.
The OpenAPI document now gives all three chapters routes their request and response fields and their refusals.
GET …/chaptersanswers{ chapters }.POST …/chapterstakesnameandmeans, answers 201 with a chapter, and lists the refusalsforbidden,exists,invalid_nameandmeans_too_long.POST …/chapters/{chapter}/{verb}takesnumber(an integer) and answers a chapter. Its refusals areforbidden,not_found,already_openandclosed.A chapter's fields are
name,means,state,patchOf,openedAt,closedAt,tag,notes,costUsd,progressanditems. They are declared once insrc/contract/openapi/chapter_fields.tsand the three route files use them. Before this change, the draft route listed onlynamein its request, and none of the three had response fields.test/openapi-chapters.test.tsreadssrc/http/api/chapters.tsand fails if a route registered there is missing from the document. It also checks the fields above.I did not add a new
Routetype. I did not describetag,progressoritemsbelow their top level, because the route type only supports flat fields. The refusals are documented per route and not as separate response statuses.The new test and the existing OpenAPI tests pass (556),
tscis clean, and the gate's comment rewrap was committed. I did not run the full suite ordesign-lint, sincesrc/webis untouched. I did not runsimilar.ts; nothing existing was reused beyond theRoutetype and therefusalsmechanism.To try it, open
GET /contract/openapi.jsonand look under…/chapters.Closes #16141