Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

3c

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

3c - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2-alpha

lib/check.coffee

5

package.json
{
"name": "3c",
"description": "json-schema api-doc mock-server",
"version": "0.0.1",
"version": "0.0.2-alpha",
"author": {

@@ -32,2 +32,3 @@ "name": "baidao"

"dependencies": {
"coffee-script": "1.7.*",
"optimist": "0.6.x",

@@ -39,3 +40,3 @@ "commander": "1.3.x",

"restify": "2.8.1",
"z-schema": "*"
"jayschema": "0.2.7"
},

@@ -42,0 +43,0 @@ "engines": {

103

README.md
## 简介
* 基于json-schema
* 生成文档
* 生成mock server
* 生成文档do **"c"**
* 生成mo **"c"** k server
* 校验服务器返回数据**"c"** heck

@@ -9,3 +9,3 @@ ## 安装

```
npm install varify-interfaces --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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc