jsonSchema-decorator
a decorator for jsonSchema
Usage
Install code:
npm install jsonschema-decorator
You need to establish a folder in your project root dir:
$/projectRootDir mkdir mock-decoratorschmod -R 777 mock-decorators
or you can use package.json
to config a folder that jsonSchema will read:
// package.json
Then, you can create js schema roles in dirctory mock-decorator,eg:
mock-decorator/----common/(write common rules in here) | |--schema.js(write unique rules in js files) |--folders/(you can also create more folders to save js files) | |--otherschema.js(other unique rules)
There is and example for jsonschema-decorator:
//schema.js'use strict';;//This is a common schema exports = moduleexports = //This is the unique schema "id": "/jsontest" "type": "object" "properties": "test": "type": "boolean" "required": "true" "name": "type": "string" "required": "true" "params": "$ref": "/jsonTestParam" //index.jsconst jd = ;@jdjsontest { thisval = test:true name:'xtx' params: sex:'male' age:25 }router;
for more example,please see the test case
LICENSE
MIT