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

The OpenAPI document describes the admin's writes: a capacity setting, a limit and a team #5133

opened this

Merged 39d 0h ago, live in production

The OpenAPI document now describes three admin writes: PUT /api/v1/admin/capacity/{key}, PUT /api/v1/admin/limits/{key} and PUT /api/v1/admin/teams/{slug}. test/openapi.test.ts passes and tsc --noEmit is clean; I did not run the rest of the suite.

Notes

opened this

The OpenAPI document now describes three admin writes: PUT /api/v1/admin/capacity/{key}, PUT /api/v1/admin/limits/{key} and PUT /api/v1/admin/teams/{slug}. test/openapi.test.ts passes and tsc --noEmit is clean; I did not run the rest of the suite.

What changed: each new row sits directly after its GET row in src/contract/openapi.ts, and I did not touch any GET row. Each has auth: true and the body fields its handler reads:

  • Capacity: value (string or null).
  • Limits: value (integer or null).
  • Teams: charter, dial and members.

Key lists: the capacity and limit rows build their allowed keys from CAPACITY_KEYS and LIMIT_KEYS, imported from src/core/capacity.ts and src/settings/limits.ts. They are not copied. Adding a key there updates the document by itself.

Refusals, by the stable error codes the handlers answer:

  • Capacity: not_found, no_such_setting, invalid_value, no_credential.
  • Limits: not_found, no_such_limit, out_of_bounds.
  • Teams: invalid_body, not_found, bad_dial, bad_charter, over_100, bad_member.

Test: a new test in test/openapi.test.ts asserts all three PUT paths are in the served document. It checks that each has security and a request body, and that the capacity and limit rows name real keys.

Left out: no success status is set on the new rows, because each handler answers a plain 200. There are no response schemas, because the existing rows don't have them either.

To try it, run bun test test/openapi.test.ts, or fetch /contract/openapi.json and look under /api/v1/admin/.

Closes #5116

commented

The OpenAPI document now describes three admin writes: PUT /api/v1/admin/capacity/{key}, PUT /api/v1/admin/limits/{key} and PUT /api/v1/admin/teams/{slug}. test/openapi.test.ts passes and tsc --noEmit is clean; I did not run the rest of the suite.

What changed: each new row sits directly after its GET row in src/contract/openapi.ts, and I did not touch any GET row. Each has auth: true and the body fields its handler reads:

  • Capacity: value (string or null).
  • Limits: value (integer or null).
  • Teams: charter, dial and members.

Key lists: the capacity and limit rows build their allowed keys from CAPACITY_KEYS and LIMIT_KEYS, imported from src/core/capacity.ts and src/settings/limits.ts. They are not copied. Adding a key there updates the document by itself.

Refusals, by the stable error codes the handlers answer:

  • Capacity: not_found, no_such_setting, invalid_value, no_credential.
  • Limits: not_found, no_such_limit, out_of_bounds.
  • Teams: invalid_body, not_found, bad_dial, bad_charter, over_100, bad_member.

Test: a new test in test/openapi.test.ts asserts all three PUT paths are in the served document. It checks that each has security and a request body, and that the capacity and limit rows name real keys.

Left out: no success status is set on the new rows, because each handler answers a plain 200. There are no response schemas, because the existing rows don't have them either.

To try it, run bun test test/openapi.test.ts, or fetch /contract/openapi.json and look under /api/v1/admin/.

commented

I merged main into this branch and pushed it. The only conflict was in test/openapi.test.ts, where both sides had added tests at the same spot. I kept all of them: my admin-writes test (capacity setting, limit, team) and the three tests from main (sign-ins, code writes, the contents refusals).

test/openapi.test.ts passes (17 tests) and bun x tsc --noEmit is clean. I didn't run the full suite; the forge's check runs it on this push.

The OpenAPI document itself is unchanged by the merge.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs