Generate TypeScript SDK clients from OpenAPI 3.x schemas. The project ships a reusable core generator, a CLI package that works with npx, docs on GitHub Pages, a demo app, and production-style GitHub automation for CI and releases.
npm install --save-dev api-sdk-generatoror run it directly:
npx api-sdk-generator generate --url https://api.example.com/openapi.json --output ./generatedGenerate from a local file:
npx api-sdk-generator generate --file ./openapi.json --output ./generatedGenerate from a URL:
npx api-sdk-generator generate --url https://api.example.com/openapi.json --output ./generatedWorkspace example:
pnpm --filter api-sdk-generator generate --file apps/demo/openapi.json --output apps/demo/generatedapi-sdk-generator generate \
--file ./openapi.json \
--output ./generated \
--name ExampleSdk \
--base-url https://api.example.com \
--clean \
--verboseSupported options:
--url <url>--file <path>--output <path>--name <sdkName>--base-url <baseUrl>--clean--verbose
import { createClient } from './generated';
const client = createClient({
baseUrl: 'https://api.example.com',
headers: {
Authorization: 'Bearer token',
},
});
const user = await client.getUserById({ id: '123' });pnpm install
pnpm lint
pnpm typecheck
pnpm test
pnpm buildKey workspaces:
packages/core: generator enginepackages/cli: CLI package published asapi-sdk-generatorapps/docs: VitePress documentationapps/demo: sample OpenAPI schema and generated SDK usage
This repository uses Changesets.
- Add a changeset with
pnpm changeset. - Merge the change into
main. - Merge the automated release PR opened by
changesets/action. - The workflow publishes to npm, updates changelogs, and creates GitHub Releases.
- Add
NPM_TOKENunderSettings -> Secrets and variables -> Actions. - Under
Settings -> Actions -> General -> Workflow permissions, enableAllow GitHub Actions to create and approve pull requests. - The
release.ymlworkflow publishesapi-sdk-generatorand@minkinpackages/api-sdk-generator-core. - npm provenance is enabled through
publishConfig.provenanceand workflowid-token: write.
- GitHub Packages for npm requires scoped package names.
package-github.ymlpublishes@minkinpackages/api-sdk-generator-coretonpm.pkg.github.com.- If you need the CLI there as well, publish a scoped distribution such as
@minkinad/api-sdk-generator.
- GitHub Pages docs: https://minkinad.github.io/api-sdk-generator/
- Enable Pages in
Settings -> Pagesand chooseGitHub Actionsas the source.
NPM_TOKENGITHUB_TOKENis provided automatically by GitHub Actions
- Add
NPM_TOKEN. - Enable
Allow GitHub Actions to create and approve pull requestsunderSettings -> Actions -> General -> Workflow permissions. - Enable GitHub Pages with GitHub Actions.
- Merge the initial changeset on
main. - Merge the release PR created by Changesets.
Contribution guide: CONTRIBUTING.md
Full documentation: apps/docs