Skip to content

write json, generate fake data server & api documents into markdown.

Notifications You must be signed in to change notification settings

imshenshen/json2SM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON2SM

write json/yaml , generate fake-server and api documents.

Install

  • clone this project
  • run npm install
  • run npm link

Usage

  • json2sm -h : get help
  • json2sm -s : start the fake-server, optional --port , default to 8877
  • json2sm -o : generate document (markdown), default to ./build/

Example

Simplest

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

you will get this: pic and this: pic

for faker value, check here for pattern value, check here

other example

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!

Coming Soon

  • $extends,$block
  • json2sm --watch
  • ...

About

write json, generate fake data server & api documents into markdown.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published