{"id":44664615,"url":"https://github.com/zhixiaoqiang/yapi2code","last_synced_at":"2026-02-15T00:16:55.622Z","repository":{"id":65571469,"uuid":"559812274","full_name":"zhixiaoqiang/yapi2code","owner":"zhixiaoqiang","description":"一个 VS Code 扩展，支持基于 YAPI 生成 JS/TS/Dart 代码，开箱即用，支持自定义 |  a VS Code extension that generates JS/TS/Dart code based on YAPI. It includes features such as zero configuration, full interface preview, availability for internal network, multiple login methods, high performance...","archived":false,"fork":false,"pushed_at":"2025-08-04T11:53:58.000Z","size":1793,"stargazers_count":20,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-04T12:07:57.933Z","etag":null,"topics":["ts","vscode","vscode-extension","yapi"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=zhixiaoqiang.yapi-to-code","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/zhixiaoqiang.png","metadata":{"files":{"readme":"README.EN.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-10-31T06:24:17.000Z","updated_at":"2025-08-04T11:54:02.000Z","dependencies_parsed_at":"2023-11-19T10:24:57.403Z","dependency_job_id":"b2ee133c-941e-4a2b-96b0-8faf38d1dd5f","html_url":"https://github.com/zhixiaoqiang/yapi2code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhixiaoqiang/yapi2code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhixiaoqiang%2Fyapi2code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhixiaoqiang%2Fyapi2code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhixiaoqiang%2Fyapi2code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhixiaoqiang%2Fyapi2code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhixiaoqiang","download_url":"https://codeload.github.com/zhixiaoqiang/yapi2code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhixiaoqiang%2Fyapi2code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29461601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T22:42:09.113Z","status":"ssl_error","status_checked_at":"2026-02-14T22:42:05.053Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ts","vscode","vscode-extension","yapi"],"created_at":"2026-02-15T00:16:50.694Z","updated_at":"2026-02-15T00:16:55.614Z","avatar_url":"https://github.com/zhixiaoqiang.png","language":"TypeScript","readme":"# YAPI TO CODE\n\n![YAPI TO CODE](https://socialify.git.ci/zhixiaoqiang/yapi2code/image?description=1\u0026descriptionEditable=%E4%B8%80%E4%B8%AA%20VS%20Code%20%E6%89%A9%E5%B1%95%EF%BC%8C%E6%94%AF%E6%8C%81%E5%9F%BA%E4%BA%8E%20YAPI%20%E7%94%9F%E6%88%90%20JS%2FTS%2FDart%20%E4%BB%A3%E7%A0%81%EF%BC%8C%E5%BC%80%E7%AE%B1%E5%8D%B3%E7%94%A8%EF%BC%8C%E6%94%AF%E6%8C%81%E8%87%AA%E5%AE%9A%E4%B9%89\u0026font=Inter\u0026forks=1\u0026issues=1\u0026language=1\u0026name=1\u0026owner=1\u0026pattern=Plus\u0026stargazers=1\u0026theme=Light)\n\n[marketplace.visualstudio](https://marketplace.visualstudio.com/items?itemName=zhixiaoqiang.yapi-to-code)\n\n\u003ccenter\u003e\n\u003ca href=\"./README.md\"\u003e中文\u003c/a\u003e|ENGLISH\n\u003c/center\u003e\n\n## Features\n\n1. 🙈 Zero configuration, ready to use out of the box\n2. 🔥 Full interface preview\n3. ✨ Available for internal network\n4. 😼 Multiple login methods\n5. ⚡️ High performance\n6. ✍️ Supports js configuration for custom output\n7. ⚡️ Rapid development experience - Rspack\n8. ...\n\n## TODO\n\n- [x] 1. Customizable template generation \u0026 template switch preview\n- [ ] 2. Optional project group - Speed up requests \u0026 improve performance\n- [ ] 3. Asynchronous request loading\n- [ ] 4. Optimize page performance\n- [ ] 5. Support for custom parsing\n- [x] 6. Replace yarn with pnpm\n- [x] 7. Migrate to Rspack\n- [ ] 8. Replace function type detection from `typescript` to `ts-morph`, effectively reducing 90% of the volume\n- [ ] 9. Support for detecting interface definition updates\n- [ ] ...\n\n## Login to YAPI\n\nFor the first time use, enter the service address \u0026 account password of YAPI to log in.\n\n\u003cimg src=\"./public/login.png\" width=\"300\" alt=\"\"/\u003e\n\n## Usage\n\nAfter logging in, vscode has the ability to access YAPI interfaces and can automatically convert any interface into a type.\n\n#### Code Diagnosis Function\n\nYapi To Code warns of undefined parameter types or return value types in the document in a wavy form, and can directly add interface types to the project through quick fixes.\n\n\u003cimg src=\"https://qnm.hunliji.com/FnOC3c1bW5bzpRu23iArFXKTrMZH\" width=\"800\" alt=\"\"/\u003e\n\n#### Interface Browser\n\nYapi To Code also provides an interface preview function. You can preview the interface type by searching and selecting the interface, and then copy the type to the project.\n\n\u003cimg src=\"https://qnm.hunliji.com/FtK9IFJlRvKdPCA4jLNoEXs1xyKO\" width=\"800\" alt=\"\"/\u003e\n\n##### Open in New Window\n\nBy default, interfaces are previewed in the same window. If you need to preview in a new window, you can click on the following Icon:\n\n\u003cimg src=\"./public/api-blank.png\" width=\"300\" alt=\"\"/\u003e\n\n##### Refresh \u0026 Clear Directives\n\nSometimes, when certain interfaces are updated, you may need to refresh specific interfaces. Right-click on the tree to perform a re-request operation.\n\nThe clear operation only deletes the content of child items permanently.\n\n\u003cimg src=\"./public/tree-contextMenu.png\" width=\"300\" alt=\"\"/\u003e\n\n#### Custom Rendering\n\nWorkspace configuration: You can modify the output fields, the position of the type filling, etc.\n\n\u003cimg src=\"./public/config.png\" width=\"300\" alt=\"\" /\u003e\n\n\u003c/br\u003e\n\nConfig file：`yapi-to-code.config.cjs` **priority**\n\n```js\nmodule.exports = () =\u003e {\n return {\n  /** 域名：优先取工作区缓存的域名(登录成功的域名) */\n  host: 'http://yapi.internal.com',\n  /** banner 头部内容，可以填写导入的请求实例等 */\n  banner: '',\n  /** 生成 res 包含的属性，默认 all, 可指定为 data、custom\n   * 'all' | 'data' | 'custom' \n   */\n  responseKey: 'all',\n  /** 生成 res 指定的属性值，仅当 responseKey 选择 custom 是有效，默认 data, 可指定为任意 key(支持链式：data.result) */\n  responseCustomKey: 'data',\n  /** resDataTypeContent 放置的位置是外层的 Promise\u003cT\u003e 还是作为请求方法的泛型 post\u003cT\u003e\n   * 'outerFunction' | 'fetchMethodGeneric'\n   */\n  responseTypePosition: 'outerFunction',\n  /** 开启自动格式化 */\n  format: false,\n  /** 缩进使用 tab，或者 双空格 */\n  useTab: false,\n  /** 自定义生成 request 方法 */\n  genRequest(\n   {\n    comment,\n    fnName,\n    IReqTypeName,\n    IResTypeName,\n    requestFnName,\n    apiPath,\n   },\n   data\n  ) {\n  const params = IReqTypeName ? `data: ${IReqTypeName}` : ''\n  const dataContent = IResTypeName ? 'data' : ''\n   return (\n    `\\n${comment}\\n\nexport async function ${fnName}(${params}) {\n  return request.${requestFnName}\u003c${IResTypeName}\u003e('${apiPath}', ${dataContent})\n}`\n   )\n  }\n }\n}\n\n```\n\n## Webview \u0026 VS Code Data Flow.png\n\n\u003cimg src=\"./public/webview-vscode-data-flow.png\" alt=\"Webview \u0026 VS Code Data Flow\" /\u003e\n\n## Development Debugging\n\n\u003e Dependencies on src/server src/webview resources are required\n\n### Compile Pre-Dependencies\n\n#### Rspack ⚡️⚡️⚡️\n\n```bash\npnpm i\ncd src/server \u0026\u0026 pnpm start\ncd src/webview \u0026\u0026 pnpm start\n```\n\n### Select Client + Server\n\n\u003cimg src=\"./public/debug.png\" alt=\"debug\" /\u003e\n\n\u003e Tips: Node logs can be viewed in the debug console of the source code editor, and webview logs can be viewed in the invoked editor's devtool.\n\n### Package Release\n\n\u003e Package and publish VS Code Extension through vsce\n\n```bash\npnpm package\n\npnpm pub\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhixiaoqiang%2Fyapi2code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhixiaoqiang%2Fyapi2code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhixiaoqiang%2Fyapi2code/lists"}