Giter Site home page Giter Site logo

mocker-dsl-core's Introduction

MOCKER-DSL-CORE

通过api-mocker的schema与请求的参数,生成对应的返回结果

How to use

npm install mocker-dsl-core --save

API

  • buildExampleFromSchema: 通过mock.js将schema生成mock数据
  • renderer: 通过请求参数,生成对应返回结果

若希望只引用单个api文件,请引用lib目录,如:

var buildExample = require('mocker-dsl-core/lib/buildExampleFromSchema')

renderer 模板语法

所有的value中包含有 ${...} 的 value,其括号内内容都会识别为模板语言进行编译。例如:

// example of schema
{
  test: "${name} render success"
}

// GET {url}?name=dxy

// response
{
  test: "dxy render success"
}
  • 目前模板语言所支持的变量类型为: string, 例如上例中的name会被当成string进行求值。符号表为请求所传入的参数。
  • 模板语法天然支持深层次嵌套使用,但暂不支持数组嵌套的数据。

mocker-dsl-core's People

Contributors

wuomzfx avatar wangqiang0121 avatar lizhiyao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.