Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>swagger-tsNew to Visual Studio Code? Get it now.
swagger-ts

swagger-ts

zzy-swagger-ts

|
15 installs
| (1) | Free
Swagger TypeScript API 管理工具
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

使用说明

方式 1. 直接在.vscode/settings.json文件中添加如下配置
"swaggerApi.list": [
  {
      "title": "公共数据源",
      "url": "openai.json",
      "base": ""
  }
方式 2. 通过右侧菜单工具图标添加

请求模板生成器 (request.template.js)

  1. 添加遵循openapi规范的接口json文档,自动生成请求模板
  2. 在项目根目录下创建 .vscode 文件夹
  3. 在文件夹内创建 request.template.cjs 文件
  4. 复制以下代码到文件中

模板代码

/**
 * 生成请求模板
 *
 * @param {{
 *  base:基础请求路径
 *  path: 请求路径
 *  method: 请求方式
 *  Params: 路径请求的参数
 *  RequestBody: 请求体参数
 *  Response: 接口返回数据类型
 *  description: 接口描述文字
 *  name: 接口名称
 *  template: 生成的ts文件内容
 * }}
 */
function requestTemplate(api) {
  return requestTemplate = ""
}

module.exports = { requestTemplate }

生成示例

输入配置:

{
  "name": "getUserInfo",
  "base": "api/v1",
  "path": "/user/info",
  "method": "get",
  "Params": [],
  "Response": "UserInfo"
}

输出结果:

export const getUserInfo = async (params: getUserInfo.Params): Promise<getUserInfo.Response> => {
  return http.get('api/v1/user/info', { params })
}

忽略更新注解(@ignore)

  1. 头部增加@ignore注解
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft