Skip to content

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

Description

@EastSun5566

Why

The Node.js client is handwritten, while the v1 API now has an OpenAPI spec. Maintaining endpoints and types in both places can let the client drift from the server.

Approach

  1. Fix inaccurate server contracts so the spec describes real responses.
  2. Keep a copy of the spec in this repo and generate typed Axios operations from it. Commit the generated files and check regeneration in CI; do not edit them by hand.
  3. Expose those operations at @hackmd/api/raw alongside the existing API class.
  4. Add a small handwritten layer for conveniences such as response unwrapping, retries, and ETag handling. Migrate incrementally without breaking existing users.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions