Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>YAPI-MOCK助手New to Visual Studio Code? Get it now.
YAPI-MOCK助手

YAPI-MOCK助手

Hidetoxic

|
185 installs
| (1) | Free
Yapi mock server and proxy in vscode
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Yapi-mock助手

通过Yapi-mock代理数据

使用指南

  • 1.安装Yapi-mock助手
  • 2.在项目根目录内创建yapi-mock.config.json
  • 3.启动插件

配置文件参数

参数

名称 类型 是否必须 备注
baseUrl String 是 yapi地址
apiMap Array 否 yapi项目Api信息映射,配置项见apiMapItem
proxy Object 是 yapi代理地址信息,配置项见proxy

apiMapItem

名称 类型 是否必须 备注
projectId String/Number 是 yapi项目id
apiPrefix String/Array 是 当前项目内所包含的固定api前缀
token String 是 当前项目的openApi的Token

proxy

名称 类型 是否必须 备注
port Number 是 mock服务启动端口
targets Array 否 代理地址信息,配置项见targets

targets

|名称|类型|是否必须|备注| |-|-|-|-| |name|String|是|代理环境的名称| |target|String|是|代理环境的地址| |default|Boolean|否|默认代理(在多项中配置优先取第一个)|

配置文件示例

{
    "baseUrl": "https://yapi.example.com",
    "apiMap": [
        {
            "projectId": 1,
            "apiPrefix": "/example1",
            "token": "example1TokenString"
        },
        {
            "projectId": 2,
            "apiPrefix": ["/example2","/example3"],
            "token": "example2TokenString"
        }
    ],
    "proxy": {
        "targets":[
            {
                "name": "开发环境",
                "target": "https://dev.example.com"
            },
            {
                "name": "测试环境",
                "target": "https://test.example.com"
            },
            {
                "name": "生产环境",
                "target": "https://prod.example.com"
             }
        ],
        "port": 10240
    }
}

功能集合

1.yapi-typescript生成接口定义

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft