0.1.3 • Published 10 years ago

ali-data-mock v0.1.3

Weekly downloads
4
License
ISC
Repository
gitlab
Last release
10 years ago

数据接口 Mock(river-mock)

by 玄道xuandao.ws@tmall.com

river-mock 为满足数据接口规范(river-spec)的数据定义生成 Mock 数据,充分利用了 JSON Schema 的描述能力。

0. 安装

  1. 安装 tnpm:npm install -g tnpm
  2. 卸载 npm 版 river-mock(如安装过): tnpm uninstall -g river-mock
  3. 安装 river-mock: tnpm install -g river-mock

1. API

  1. schema2mock(schema)

    1. 将普通的 schema 对象进行生成 mock
    2. return {object}
  2. spec2mock(spec, req)

    • 将符合 river-spec 标准的 json 进行生成 mock 数据
    • arguments:
      1. spec{object}
      2. req{string|object},规则如下
        1. 若 req 为空,则返回 response
        2. 若 req 为字符串,则返回 req
        3. 若 req 为对象,则使用算法规则进行匹配
          1. 若 req 为 http request 对象,则自动获取 url、method 与 responseMap 进行匹配
          2. 若 req 位 object时
            • 结构: {query: {search: 'xxx'}, method: 'GET'}
            • query: url 参数列表
            • method: http 请求方法
    • return {object};

2. 参考

  1. responseMap
  2. 随机生成规则

3. 共建

  1. issue
0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago