write json/yaml , generate fake-server and api documents.
- clone this project
- run
npm install
- run
npm link
json2sm -h
: get helpjson2sm -s
: start the fake-server, optional --port , default to 8877json2sm -o
: generate document (markdown), default to ./build/
if you have this:
route : get,/api/user/info #http://localhost:8877/api/user/info
doc: # if you don't want the document, remove 'doc'
type: markdown
path: userInfo/user.md
title: CustomerInfo
params:
userId:
necessary: true # optional ,default to false
desc : device uuid #optional
result:
type: object
properties:
code: 200
data:
type: object
properties:
realName:
desc: user name
faker: name.findName
sex:
desc: '性别 0保密 1男 2女'
type: integer
pattern: !!js/regexp /[0-2]/
isVip:
type: integer
pattern: "(1|0)"
files:
desc: user files
type: array
minItems: 0
maxItems: 3
items:
type: object
properties:
name:
desc: file name
faker: lorem.word
url:
faker: image.imageUrl
for faker
value, check here
for pattern
value, check here
array
,object
,$include
example, please check test
extends
,block
like jade, coming soon
you can cd to the test dir, run json2sm -s -o
, try it!
$extends
,$block
json2sm --watch
- ...