{"id":21412850,"url":"https://github.com/hunghg255/swagger-typescript-api-es","last_synced_at":"2025-07-14T02:32:34.145Z","repository":{"id":224515790,"uuid":"762895377","full_name":"hunghg255/swagger-typescript-api-es","owner":"hunghg255","description":"TypeScript API generator via Swagger scheme","archived":false,"fork":false,"pushed_at":"2025-03-04T03:52:33.000Z","size":662,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T12:49:16.689Z","etag":null,"topics":["api","axios","definition","fetch","generate-code","rest-api","swagger","types","typescript"],"latest_commit_sha":null,"homepage":"https://hunghg255.github.io/swagger-typescript-api-es/","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/hunghg255.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-02-25T01:37:00.000Z","updated_at":"2025-03-30T05:50:26.000Z","dependencies_parsed_at":"2024-06-25T12:05:57.109Z","dependency_job_id":"353bab3f-4dc4-47cc-ae12-359389530f39","html_url":"https://github.com/hunghg255/swagger-typescript-api-es","commit_stats":null,"previous_names":["hunghg255/swagger-typescript-api-es"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hunghg255/swagger-typescript-api-es","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fswagger-typescript-api-es","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fswagger-typescript-api-es/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fswagger-typescript-api-es/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fswagger-typescript-api-es/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hunghg255","download_url":"https://codeload.github.com/hunghg255/swagger-typescript-api-es/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunghg255%2Fswagger-typescript-api-es/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265233753,"owners_count":23731825,"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","axios","definition","fetch","generate-code","rest-api","swagger","types","typescript"],"created_at":"2024-11-22T18:16:00.559Z","updated_at":"2025-07-14T02:32:33.199Z","avatar_url":"https://github.com/hunghg255.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/swagger-typescript-api-es\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n\u003cimg src=\"https://api.iconify.design/devicon-plain:swagger-wordmark.svg?color=%2365fb92\" alt=\"logo\" width='150'/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  ESM and TypeScript rewrite of Acacode's\n  \u003ca href=\"https://github.com/acacode/swagger-typescript-api\"\u003eswagger-typescript-api\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/swagger-typescript-api-es\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://badge.fury.io/js/swagger-typescript-api-es.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/swagger-typescript-api-es\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/swagger-typescript-api-es.svg?logo=npm\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=swagger-typescript-api-es\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/swagger-typescript-api-es\" alt=\"Minizip\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hunghg255/swagger-typescript-api-es/graphs/contributors\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://img.shields.io/badge/all_contributors-1-orange.svg\" alt=\"Contributors\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hunghg255/swagger-typescript-api-es/blob/main/LICENSE\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://badgen.net/github/license/hunghg255/swagger-typescript-api-es\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## API\n\n```bash\nnpx swagger-typescript-api-es@latest --help\n```\n\n## CLI\n\n```bash\nnpx swagger-typescript-api-es@latest -u https://petstore.swagger.io/v2/swagger.json -o ./src/api\n```\n\n## Install\n\n```bash\nnpm i swagger-typescript-api-es@latest --save-dev\n```\n\n- Create a file `swagger-typescript-api.config.ts` in the root of the project\n\n```ts\nimport { defaultConfig } from 'swagger-typescript-api-es';\n\nexport default defaultConfig({\n  name: 'api-axios.ts',\n  output: './src/apis/axios-gentype',\n  url: 'http://localhost:5002/api-json',\n  httpClientType: 'axios',\n});\n```\n\n- Options\n\n```ts\n// Options\ninterface IOptions {\n  /**\n   *  name of output typescript api file (default: \"Api.ts\")\n   */\n  name: string;\n  /**\n   * output path of typescript api file (default: \"./\")\n   */\n  output: string;\n  /**\n   * path/url to swagger scheme\n   */\n  url: string;\n  input?: string;\n  spec?: {\n    swagger?: '2.0' | '3.0';\n    info?: {\n      version?: string;\n      title?: string;\n    };\n  };\n  templates?: string;\n  httpClientType?: 'axios' | 'fetch';\n  defaultResponseAsSuccess?: boolean;\n  generateClient?: boolean;\n  generateRouteTypes?: boolean;\n  generateResponses?: boolean;\n  toJS?: boolean;\n  extractRequestParams?: boolean;\n  extractRequestBody?: boolean;\n  extractEnums?: boolean;\n  unwrapResponseData?: boolean;\n  /**\n   * By default prettier config is load from your project\n   */\n  prettier?: {\n    printWidth?: number;\n    tabWidth?: number;\n    trailingComma?: 'all' | string;\n    parser?: 'typescript' | string;\n  };\n  singleHttpClient?: boolean;\n  cleanOutput?: boolean;\n  enumNamesAsValues?: boolean;\n  moduleNameFirstTag?: boolean;\n  generateUnionEnums?: boolean;\n  typePrefix?: string;\n  typeSuffix?: string;\n  enumKeyPrefix?: string;\n  enumKeySuffix?: string;\n  addReadonly?: boolean;\n  sortTypes?: boolean;\n  sortRouters?: boolean;\n  extractingOptions?: {\n    requestBodySuffix?: string[];\n    requestParamsSuffix?: string[];\n    responseBodySuffix?: string[];\n    responseErrorSuffix?: string[];\n  };\n  /** allow to generate extra files based with this extra templates, see more below */\n  extraTemplates?: [];\n  anotherArrayType?: boolean;\n  fixInvalidTypeNamePrefix?: string;\n  fixInvalidEnumKeyPrefix?: string;\n  prettierOptions?: Record\u003cstring, any\u003e;\n  constants?: Record\u003cstring, any\u003e;\n  templateInfos?: any;\n  codeGenConstructs?: (constructs: any) =\u003e Record\u003cstring, any\u003e;\n  primitiveTypeConstructs?: (constructs: any) =\u003e Record\u003cstring, any\u003e;\n  hooks?: {\n    onCreateComponent?: (component: any) =\u003e void;\n    onCreateRequestParams?: (rawType: any) =\u003e void;\n    onCreateRoute?: (routeData: any) =\u003e void;\n    onCreateRouteName?: (routeNameInfo: any, rawRouteInfo: any) =\u003e void;\n    onFormatRouteName?: (routeInfo: any, templateRouteName: any) =\u003e void;\n    onFormatTypeName?: (typeName: any, rawTypeName: any, schemaType: any) =\u003e void;\n    onInit?: (configuration: any) =\u003e void;\n    onPreParseSchema?: (originalSchema: any, typeName: any, schemaType: any) =\u003e void;\n    onParseSchema?: (originalSchema: any, parsedSchema: any) =\u003e void;\n    onPrepareConfig?: (currentConfiguration: any) =\u003e void;\n  };\n}\n```\n\n- Config (file package.json)\n\n```json\n{\n  ...\n  \"scripts\": {\n    ...\n    \"gen-api-types\": \"swagger-typescript-api-es\"\n  },\n  ...\n}\n```\n\n## 📝 License\n\nLicensed under the [MIT License](https://github.com/hunghg255/swagger-typescript-api-es/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunghg255%2Fswagger-typescript-api-es","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhunghg255%2Fswagger-typescript-api-es","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunghg255%2Fswagger-typescript-api-es/lists"}