Skip to content

feat: generate v1 API client from OpenAPI - #62

Open
EastSun5566 wants to merge 35 commits into
developfrom
feature/dev-3165
Open

EastSun5566 wants to merge 35 commits into
developfrom
feature/dev-3165

Conversation

@EastSun5566

@EastSun5566 EastSun5566 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Generate @hackmd/api/raw from the v1 OpenAPI spec with @hey-api/openapi-ts. The existing API class remains the only handwritten convenience layer and delegates to generated operations; users do not need to switch clients.
  • Cover all 59 v1 operations and fix retry isolation.
  • Generate and export an operation registry from the same spec, so the CLI can list, describe, and call raw operations.
  • Derive public response types from OpenAPI, correcting handwritten mistakes such as note createdAt and lastChangedAt being typed as string instead of number.
  • Support nullable team owners and description: null to clear personal/team note metadata. Note GET descriptions remain strings.
  • Sync the vendored spec with the published v1 OpenAPI contract.

Documentation

  • TypeDoc builds a static API reference from the public API and @hackmd/api/raw types (pnpm docs:build).
  • The Pages workflow deploys it on pushes to master. Before the first deployment, set Settings → Pages → Build and deployment → Source: GitHub Actions in this repository.

Related work

Checks

  • Generated-code check, typecheck, lint, 113 unit tests, ESM/CJS build, NodeNext type checks, and TypeDoc pass.
  • All 12 live E2E tests pass against production with HACKMD_E2E_MUTATIONS=1, including Notes CRUD, image upload, and Folder CRUD/order. Live E2E logs. Nullable-description behavior is covered by local tests.

Regeneration

To refresh the client from the published v1 spec, run from nodejs/:

pnpm spec:pull
pnpm codegen
pnpm check:generated

Commit spec/hackmd-openapi.json and src/generated/ together, then rerun CI.

Fixes #61 #60

@EastSun5566 EastSun5566 changed the title feat: generate v1 API client from OpenAPI (DEV-3165) feat: generate v1 API client from OpenAPI Sep 24, 2026
@EastSun5566

Copy link
Copy Markdown
Contributor Author

types gen docs:

Screenshot 2026-09-26 at 1 56 02 AM

@EastSun5566
EastSun5566 added this pull request to stack #64 September 26, 2026 16:54
@EastSun5566
EastSun5566 marked this pull request as ready for review October 6, 2026 10:30
Copilot AI balanced review requested due to automatic review settings October 6, 2026 10:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@EastSun5566

EastSun5566 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

All 12 live E2E tests passed against production (https://api.hackmd.io/v1).

HACKMD_E2E_MUTATIONS=1 pnpm test:e2e --runInBand
PASS tests/e2e/api.e2e.spec.ts (28.081 s)
  HackMD API (live e2e)
    read-only
      ✓ getMe returns the current user profile (730 ms)
      ✓ getNoteList returns an array (548 ms)
      ✓ getTeams returns an array (132 ms)
      ✓ getHistory accepts limit and returns an array (575 ms)
      ✓ getFolderList returns folders when the server exposes /folders (187 ms)
    mutations (optional)
      notes CRUD when HACKMD_E2E_MUTATIONS=1
        ✓ createNote creates a note (587 ms)
        ✓ getNote returns the note (145 ms)
        ✓ updateNote updates title, content, and tags (2225 ms)
        ✓ uploadNoteImage uploads an image to the note (743 ms)
        ✓ getNoteList includes the note (417 ms)
        ✓ deleteNote removes the note (573 ms)
      folders CRUD when HACKMD_E2E_MUTATIONS=1
        ✓ folders: create → get → update → nested folder → list → order round-trip → delete (4004 ms)

Test Suites: 1 passed, 1 total
Tests:       12 passed, 12 total
Snapshots:   0 total
Time:        28.487 s
Ran all test suites.

Folder PATCH returns 202 Accepted, so the test waits up to 15 seconds for persistence before asserting the updated name and description. This E2E-only fix is committed and pushed in 1305fe1.

@EastSun5566
EastSun5566 requested a review from Yukaii October 6, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate the Node.js API client from the v1 OpenAPI spec

2 participants