Skip to content

feat: explore Python API client codegen - #63

Draft
EastSun5566 wants to merge 8 commits into
feature/dev-3165from
feature/dev-3165-python-spike
Draft

EastSun5566 wants to merge 8 commits into
feature/dev-3165from
feature/dev-3165-python-spike

Conversation

@EastSun5566

@EastSun5566 EastSun5566 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Experiment

Try @hey-api/openapi-python with the same vendored v1 OpenAPI spec used by the Node.js API client. This draft PR is stacked on #62; nothing is published.

  • Generate all 59 raw operations with flat parameters and commit the output under python/src/hackmd_api/generated/. Align codegen / check:generated with Node.js.
  • Add a small API wrapper for profile, teams, history, personal notes/images, personal folders/order, and team note detail. Reuse generated Pydantic models, with ETag/304 handling, bounded retries for reads/PUT/DELETE, and HTTP errors. POST/PATCH are not retried; api.raw keeps the original HTTPX responses.
  • Pin dependencies and temporarily patch hey-api/hey-api#4441 (enum names) and hey-api/hey-api#4290 (flat request parameters/JSON bodies). Additional local changes provide per-request headers/multipart overrides and omit unset model fields while preserving explicit nulls. Remove each patch only after a release provides equivalent behavior; those two PRs alone do not cover all additions.

Result

Synced with the latest #62 contract and regenerated the Python client. Generated-file consistency checks, compilation, and all 19 offline HTTPX tests pass locally on Python 3.13. Tests cover authentication/base URLs, paths/query/JSON, multipart bytes, ETag, retry isolation, errors, nullable team owners, and omitted/string/null note descriptions. Note GET descriptions remain strings.

The previous production read-only live run passed all 5 read-only tests; the 2 mutation workflows were skipped. The new Python suite covers the existing Node live scenarios plus 200 → 304 → changed 200, but Python's full mutation run is still pending explicit authorization. Cleanup tracks created resources and restores folder order; notes go to trash, and uploaded image removal is not guaranteed.

Python CI runs generated-file checks, compilation, and offline tests on Python 3.13 for relevant PRs, including this stack. It uses no API credentials and runs no live tests.

This remains an experiment: raw multipart uploads still need request overrides (tracked in hey-api/hey-api#4443), flat optional arguments do not distinguish omitted values from None, nullable flat parameters may be typed as Any, and generated nullable fields do not fully enforce required-field presence. Use Pydantic bodies through the wrapper or request_overrides to preserve explicit nulls. Grouped parameters, async wrappers, packaging/publication, and custom wrappers for all operations remain out of scope.

@EastSun5566
EastSun5566 added this pull request to stack #64 September 26, 2026 16:54
@EastSun5566
EastSun5566 force-pushed the feature/dev-3165-python-spike branch from 54498c7 to dfe110d Compare September 27, 2026 17:49
@EastSun5566 EastSun5566 changed the title chore: explore Python API client codegen feat: explore Python API client codegen Sep 27, 2026
@EastSun5566
EastSun5566 force-pushed the feature/dev-3165-python-spike branch from 540bca4 to 063182d Compare September 28, 2026 15:20
@EastSun5566
EastSun5566 force-pushed the feature/dev-3165-python-spike branch from 063182d to 0a34b93 Compare September 29, 2026 05:36
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.

1 participant