{"id":15495919,"url":"https://github.com/hairyf/genapi","last_synced_at":"2026-02-09T07:46:15.411Z","repository":{"id":108369319,"uuid":"604962069","full_name":"hairyf/genapi","owner":"hairyf","description":"API pipeline generator, which is used to convert OpenApi (v2~v3) and any input sources into TS/JS APIs, and currently supports axios, fetch, ky, got, ofetch","archived":false,"fork":false,"pushed_at":"2025-04-19T04:35:53.000Z","size":12223,"stargazers_count":40,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T18:08:31.178Z","etag":null,"topics":["api-generator","generator","javascript","openapi","swagger","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hairyf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-22T06:28:10.000Z","updated_at":"2025-04-19T04:35:57.000Z","dependencies_parsed_at":"2023-03-06T02:45:36.122Z","dependency_job_id":"64313bf6-2e04-40d1-9dcd-29b75a32fdf1","html_url":"https://github.com/hairyf/genapi","commit_stats":{"total_commits":171,"total_committers":6,"mean_commits":28.5,"dds":0.4678362573099415,"last_synced_commit":"6909f59c1740b866fe09e9411715c6bf59a6a787"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyf%2Fgenapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyf%2Fgenapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyf%2Fgenapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hairyf%2Fgenapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hairyf","download_url":"https://codeload.github.com/hairyf/genapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250487528,"owners_count":21438612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-generator","generator","javascript","openapi","swagger","typescript"],"created_at":"2024-10-02T08:20:30.582Z","updated_at":"2026-02-09T07:46:15.405Z","avatar_url":"https://github.com/hairyf.png","language":"TypeScript","readme":"# genapi\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![bundle][bundle-src]][bundle-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\n[![License][license-src]][license-href]\n\n\u003e [中文](./README_CN.md) | **English**\n\u003e [English Docs](http://genapi-docs.vercel.app/)\n\nA lightweight API code generator—only the code you need.\n\n## Features\n\n- 🚀 **Multiple HTTP Clients** - Support for [axios](https://github.com/axios/axios), [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), [ky](https://github.com/sindresorhus/ky), [got](https://github.com/sindresorhus/got), [ofetch](https://github.com/unjs/ofetch), [tanstack-query](https://github.com/TanStack/query), [uni](https://github.com/uni-helper/uni-network)\n- 🔄 **TypeScript \u0026 JavaScript** - Generate both TS and JS APIs with full type definitions\n- 📋 **Schema Mode** - Type-safe fetch APIs with schema-based typing (supports `fetch` and `ofetch` presets)\n- 📖 **Multiple Data Sources** - Support for OpenAPI 2.0/3.x, Swagger and other input sources\n- 🔧 **Interactive CLI** - Use `genapi init` for guided setup with preset selection\n- 🛠️ **Customizable Pipeline** - Flexible pipeline system for customizing the generation process\n- 🔀 **Transform \u0026 Patch** - Batch transform operations and types, or make exact-match modifications\n- 🎭 **Mock Data** - Automatically generate mock methods for each API function (requires `better-mock`)\n- 🌐 **Multiple Services** - Support for projects with multiple API services via `servers` configuration\n- ⚡️ **Type Safety** - Full TypeScript support with type inference and IntelliSense\n- 📦 **Zero Config** - Works out of the box with sensible defaults, customize as needed\n\n## Usage\n\n### Init Project\n\nJust run the following command to init your project:\n\n```bash\n# pnpm (recommended)\npnpm dlx @genapi/core genapi init\n# npx @genapi/core genapi init\n# yarn dlx @genapi/core genapi init\n```\n\nOr install and configure manually:\n\n```bash\npnpm i @genapi/core @genapi/presets -D\n```\n\nCreate `genapi.config.ts`:\n\n```ts\nimport { defineConfig } from '@genapi/core'\nimport { axios } from '@genapi/presets'\n\nexport default defineConfig({\n  preset: axios.ts,\n  input: 'https://petstore3.swagger.io/api/v3/openapi.json',\n  output: {\n    main: 'src/api/index.ts',\n    type: 'src/api/index.type.ts',\n  },\n})\n```\n\nThen run to generate API code like:\n\n```bash\nnpx genapi\n```\n\n```ts\n/*\n * @title Swagger Petstore - OpenAPI 3.0\n * ... other metadata ...\n */\n\nimport type { AxiosRequestConfig } from 'axios'\nimport type * as Types from './index.type'\nimport http from 'axios'\n\n/**\n * @summary Update an existing pet.\n * @description Update an existing pet by Id.\n * @method put\n * @tags pet\n */\nexport function putPet(data?: Types.Pet, config?: AxiosRequestConfig) {\n  const url = '/pet'\n  return http.request\u003cTypes.Pet\u003e({ method: 'put', url, data, ...config })\n}\n\n/**\n * @summary Add a new pet to the store.\n * @description Add a new pet to the store.\n * @method post\n * @tags pet\n */\nexport function postPet(data?: Types.Pet, config?: AxiosRequestConfig) {\n  const url = '/pet'\n  return http.request\u003cTypes.Pet\u003e({ method: 'post', url, data, ...config })\n}\n```\n\nFor more details and features, visit the [documentation site](http://genapi-docs.vercel.app/).\n\n## License\n\n[MIT](./LICENSE) License © [Hairyf](https://github.com/hairyf)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/@genapi/core?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-version-href]: https://npmjs.com/package/@genapi/core\n[npm-downloads-src]: https://img.shields.io/npm/dm/@genapi/core?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[npm-downloads-href]: https://npmjs.com/package/@genapi/core\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/@genapi/core?style=flat\u0026colorA=080f12\u0026colorB=1fa669\u0026label=minzip\n[bundle-href]: https://bundlephobia.com/result?p=@genapi/core\n[license-src]: https://img.shields.io/github/license/hairyf/genapi.svg?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[license-href]: https://github.com/hairyf/genapi/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat\u0026colorA=080f12\u0026colorB=1fa669\n[jsdocs-href]: https://www.jsdocs.io/package/@genapi/core\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhairyf%2Fgenapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhairyf%2Fgenapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhairyf%2Fgenapi/lists"}