Repository navigation
feat: multi-language API clients (Node.js, Python, Go, Rust) from one OpenAPI spec - #63
Draft
EastSun5566 wants to merge 16 commits into
Draft
EastSun5566 wants to merge 16 commits into
EastSun5566 wants to merge 16 commits into
Conversation
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
from
September 27, 2026 17:49
54498c7 to
dfe110d
Compare
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
2 times, most recently
from
September 29, 2026 05:36
063182d to
0a34b93
Compare
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
from
October 6, 2026 11:03
0a34b93 to
e43ba59
Compare
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
from
November 6, 2026 16:06
e43ba59 to
70ab3bb
Compare
Yukaii
force-pushed
the
feature/dev-3165-python-spike
branch
from
November 20, 2026 07:37
70ab3bb to
edaf345
Compare
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
from
December 2, 2026 21:50
edaf345 to
c4c879e
Compare
EastSun5566
marked this pull request as ready for review
December 3, 2026 10:33
Move the OpenAPI spec to the repository root (spec/) so every language client generates from the same file. Make the root a pnpm workspace for the JavaScript packages only (nodejs and examples/*), with one lockfile seeded from the previous nodejs lockfile so resolved versions do not change. Rename the Node.js CI workflow and add path filters, so each language's workflows run only for its own changes. Prefix release tags per language; npm releases now use nodejs-v* tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the patched @hey-api/openapi-python spike. openapi-python-client generates an httpx2 + attrs client that separates omitted fields (UNSET) from explicit nulls, types the If-None-Match header, and serializes multipart uploads, which the previous generator needed patches for. scripts/codegen.py also generates API and AsyncAPI with one typed method per operation, returning only the success body. Retries and error wrapping run in an httpx2 transport and response hook, so every operation gets them. The package is named hackmd-api to match @hackmd/api. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy the progenitor-based client from EastSun5566/hackmd-api-client-rs (b33fa75) into rust/, renamed to hackmd-api to match @hackmd/api. The original repository and crate are left as they are. xtask now generates from the shared ../spec/hackmd-openapi.json; the spec download moved to the root justfile. That spec is older than the one the original crate used, so add_notes_to_folder, add_notes_to_team_folder and get_trash_note are removed until the shared spec is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add github.com/hackmdio/api-client/go (package hackmd), generated from the shared spec with oapi-codegen v2.8.2, pinned through the go.mod tool directive. ClientWithResponses has a typed method for every operation. hackmd.New wraps the generated client's HTTP doer to add the bearer token, retries with backoff for idempotent methods, and *APIError for 4xx/5xx. Nullable fields use nullable.Nullable[T], so a request can leave a field out or clear it with null. overlay.yaml renames the duplicate User.Teams property and names the create-note option types, without changing the shared spec. Helpers cover the create-note union body, which the generated request type does not serialize, and multipart image uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a root justfile that pulls the spec, regenerates and checks every client, and docs/conformance.md, which lists the behavior each client adds on top of its generated code and the known gaps in the Rust port. The root README now lists all four clients; add a Python example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Retry only GET, PUT and DELETE. POST and PATCH (creates, updates, pings, uploads) are sent once, so a write is never applied twice. - Stop retrying 429s once x-ratelimit-userremaining is 0. The rate-limit fields are now Option<u32>, so a missing header no longer reads as 0. - Wait base_delay * 2^n from the first retry, matching Node.js. - Keep response bodies out of error messages; they are in a new body field instead. - Add get_note_conditional and get_team_note_conditional, which send If-None-Match and return Conditional::NotModified on 304. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Go gets live tests behind the e2e build tag and Rust gets ignored tests in tests/live.rs. Both cover reads, a 404, the note lifecycle (ETag 304, clearing a nullable field, image upload) and a folder lifecycle, and skip without HACKMD_ACCESS_TOKEN. Folder deletes are eventually consistent: a deleted folder stays listed for a second or two. The Node.js folder test asserted it was gone immediately and failed every time, so it now waits for the delete to land. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EastSun5566
force-pushed
the
feature/dev-3165-python-spike
branch
from
December 3, 2026 12:22
cbdc03b to
e44b0dc
Compare
package.json declares engines >=22, but CI only ran Node 24. Test the minimum (22), the version that builds the npm release (24) and the latest (26), like Python CI tests 3.11 and 3.14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EastSun5566
marked this pull request as draft
December 4, 2026 06:23
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Turn the repository into a multi-language monorepo: every client is generated from one OpenAPI spec with the most mature generator for its language. This is still an experiment; nothing new is published.
@hackmd/api(unchanged)hackmd-api@hey-api/openapi-pythonspike)github.com/hackmdio/api-client/gohackmd-api(new crate name)hackmd-apiis unused on both PyPI and crates.io (hackmdis taken on crates.io), so it matches@hackmd/apieverywhere.Linked issue
Changes
nodejs/spec/tospec/. The root is a pnpm workspace for JS only (nodejs,examples/*), with one lockfile seeded from the oldnodejslockfile so Node dependency versions do not change. A rootjustfilerunsspec-pull/codegen/check/check-generatedacross all clients.nodejs-ci,python-ci,go-ci,rust-ci), each limited to its directory plusspec/. Each checks that regenerated code matches what is committed.nodejs-v*instead ofv*;publish.ymlandnodejs/AGENTS.mdare updated. Release notes still start from the previous stable tag, oldv*or newnodejs-v*. Develop pre-releases run only whennodejs/,spec/or the lockfile change.UNSET) fromNone, typesIf-None-Match, and handles multipart, so the hey-api patches are no longer needed.scripts/codegen.pyalso generatesAPI/AsyncAPIwith one typed method per operation (59). Retries and error wrapping run at the httpx2 transport layer, so every operation gets them. 19 offline tests pass; mypy strict passes; tested on 3.11 and 3.14.hackmd.New(token, opts...)wraps the generatedClientWithResponseswith auth, retries and*APIError. Nullable fields usenullable.Nullable[T].overlay.yamlfixes Go-only naming issues (duplicateUser.Teams) without touching the shared spec. Helpers cover the create-note union body, which oapi-codegen does not serialize, and multipart uploads.../spec. That spec is older than the one the original crate used, soadd_notes_to_folder,add_notes_to_team_folderandget_trash_notewere removed for now. The original repository is unchanged. Then aligned with the other clients: POST/PATCH are no longer retried, retries stop when the rate-limit quota is 0, error messages no longer include the response body (now in abodyfield), andget_note_conditional/get_team_note_conditionalhandle ETags. The README lists the migration fromhackmd-api-client-rs0.4.Known gaps / follow-ups
Testing
just checkpasses locally: Node 122 tests plus build/lint/typecheck/docs; Python ruff, mypy, 19 tests; Go vet and tests (also with-race); Rust fmt, clippy, 43 tests, examples and docs.just check-generated: all four clients regenerate with no diff.go/live_test.go,e2ebuild tag) and Rust (rust/tests/live.rs,#[ignore]) live tests are new; both skip without a token.x-ratelimit-*headers.🤖 Generated with Claude Code