Comparing version 0.0.2 to 0.0.3-alpha
{ | ||
"name": "3c", | ||
"description": "json-schema api-doc mock-server", | ||
"version": "0.0.2", | ||
"version": "0.0.3-alpha", | ||
"author": { | ||
@@ -39,3 +39,3 @@ "name": "baidao" | ||
"restify": "2.8.1", | ||
"z-schema": "*" | ||
"jayschema": "0.2.7" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
## 简介 | ||
* 基于json-s **"c"** hema | ||
* 生成文档do **"c"** | ||
* 生成mo **"c"** k server | ||
* 校验服务器返回数据**"c"** heck | ||
@@ -9,3 +9,3 @@ ## 安装 | ||
``` | ||
npm install 3c --save | ||
(sudo) npm install 3c -g | ||
``` | ||
@@ -43,52 +43,55 @@ | ||
简单的schema可以搞定 暂时不支持比较碉堡的 oneOf allOf $ref..等等 | ||
- 简单的schema可以搞定 | ||
- 暂时不支持比较碉堡的 oneOf allOf $ref..等等 | ||
- 可以设置默认值 default | ||
自带一些特殊的format 方便生成测试数据 | ||
``` | ||
timestamp: { //自带的匹配 timestamp | ||
type: 'string', | ||
format: 'timestamp' | ||
}, | ||
aaa: { //自定义的特殊匹配 | ||
type: 'string', | ||
format: 'aaaaaaa' | ||
} | ||
``` | ||
module.exports = [ | ||
meta: #接口相关基本藐视 | ||
title: 'test' #接口名称 | ||
description: 'just for test' #接口描述 | ||
host: 'http://localhost:1234' | ||
uri: '/test' | ||
method: 'get' | ||
``` | ||
'datetime': | ||
val: new Date _.random(1400000000000, 1800000000000) | ||
'timestamp': -> | ||
val: _.random 1400000000000, 1800000000000 | ||
'email': | ||
pattern: /\w{3,6}\.example\.com\/\w{3,6}/ | ||
'uri': | ||
pattern: /\http:\/\/\w{3,6}\.example\.com\/\w{3,6}/ | ||
'mobile': | ||
pattern: /^18\d{5,9}/ | ||
``` | ||
params: #请求参数 | ||
type: 'object' | ||
properties: | ||
token: | ||
type: 'string' | ||
required: ['token'] | ||
也可以自行 在format.js 添加 | ||
success: #请求成功 | ||
type: 'object' | ||
required: ['array'] | ||
properties: | ||
array: | ||
type: 'array' | ||
minItems: 8 | ||
maxItems: 10 | ||
items: | ||
type: 'object' | ||
required: ['id','name'] | ||
properties: | ||
id: | ||
type: 'integer' | ||
description: 'id' | ||
name: | ||
type: 'string' | ||
description: '姓名' | ||
default: 'hello world' | ||
#### format: 存放特殊的匹配规则 | ||
error: #请求失败 | ||
type: 'object' | ||
properties: | ||
code: | ||
type: 'integer' | ||
msg: | ||
type: 'string' | ||
required: ['code'] | ||
] | ||
对pattern匹配的一个补充 | ||
``` | ||
用来生成Mock数据 | ||
- format.js | ||
``` | ||
module.exports = { | ||
woshinibaba: { | ||
val: 'woshinibaba' //直接采用 数据 | ||
}, | ||
aaaaaaa: { | ||
pattern: "[a-c]" //按照pattern 生成数据 | ||
} | ||
}; | ||
``` | ||
### 生成文档 | ||
@@ -103,9 +106,13 @@ > 3c -d 或者 3c --doc | ||
## Todos | ||
mock server 默认1234端口 | ||
### 数据校验 | ||
> 3c -c 或者 3c --check | ||
对服务器返回数据的校验... | ||
check server 默认4321端口 | ||
浏览器打开 http://localhost:4321 | ||
进行校验 | ||
## Hava fun! |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
21667
19
1
116
+ Addedjayschema@0.2.7
+ Addedjayschema@0.2.7(transitive)
+ Addedwhen@3.1.0(transitive)
- Removedz-schema@*
- Removedcommander@11.1.0(transitive)
- Removedlodash.get@4.4.2(transitive)
- Removedlodash.isequal@4.5.0(transitive)
- Removedvalidator@13.12.0(transitive)
- Removedz-schema@6.0.2(transitive)