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.2 to 0.0.3-alpha

lib/check.coffee

4

package.json
{
"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

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