datahub-import-json
v0.0.6
Published
[![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Coverage status][codecov-image]][codecov-url] [![Dependency status][daviddm-image]][daviddm-url]
Downloads
6
Readme
datahub-import-json
Upload all files below the mock file to DataHub
Installment
$ npm i datahub-import-json -g
Usage
$ datahub-import-json test-project -d /Users/xxx/mock/get --method GET
$ datahub-import-json test-project -d /Users/xxx/mock/post --method POST
Configuration
$ datahub-import-json projectName
| param | description | default | | -- | -- | -- | | -s | DataHub server address | http://127.0.0.1:5678 | | -d | mock data directory path | - | | --mockSuffix | set mock file suffix | .json | | --interfaceSuffix | DataHub interface suffix, will replace mockSuffix | .json | | --replacePathWithDynamic | replace path with dynamic, goods/:id.json | /_/ | | --mockRemoveSuffix | remove mockRemoveSuffix, no repalce | - | | --method | DataHub interface method | ALL |
Examples
Import JSON interface
假设项目名为:test-project(建议与仓库名称保持一致) mock 数据文件件路径为:/Users/xxx/mock DataHub server 地址为:http://127.0.0.1:5678/ 想导入的 Mock 文件后缀为:.json 导入后的 Mock 接口后缀为:.html
$ datahub-import-json test-project -d /Users/xxx/mock --interfaceSuffix .html -s http://127.0.0.1:5678
Import js interface
假设项目名为:test-project(建议与仓库名称保持一致) mock 数据文件件路径为:/Users/xxx/mock DataHub server 地址为:http://127.0.0.1:5678/ 想导入的 Mock 文件路径为: /Users/xxx/mock/post/member/xxx.html/data.json /Users/xxx/mock/post/member/xxx.html/data.js 导入后的 Mock 接口路径为:/member/xxx.html
# post 请求
$ datahub-import-json test-project -d /Users/xxx/mock/post/ --mockRemoveSuffix /data.json --method POST -s http://127.0.0.1:5678
# get 请求
$ datahub-import-json test-project -d /Users/xxx/mock/get/ --mockRemoveSuffix /data.json --method GET -s http://127.0.0.1:5678