GithubHelp home page GithubHelp logo

smock's Introduction

JDCFE SMock

分析需要mock的文档,例如swagger文档,输出相应的mock数据,并启动node服务,供前端开发时调试使用,提高前端开发效率,支持跨域访问

安装

npm install jdcfe-smock -g

初始化SMock.json文件

1. 在对应的项目根目录下执行smock init命令
2. 按照提示输入相应的配置,如果不知道请一路填空
3. 检查SMock.json里的配置是否正确

参数说明

Attributes forma describe
host string 需要mock的文档地址ip或者域名
domain string 需要mock的文档访问域名。一般和host配合使用,如果文档是IP不能直接访问的形式,那么此处需要传入相应的值
path string 需要mock的文档数据请求路径,在swagger文档页面可以找到,如:/v2/api-docs
port integer 需要mock的文档地址端口号, 默认80,如果协议配置为https,此参数则变为443
projectName string 项目名,默认值swaggermock
mockPort string 本地mock服务启动后的端口,默认为3000
customProtocol string swagger文档支持的协议请求 http/https

运行

1. 在项目根目录下执行smock run
2. 在项目中调用mock服务

使用说明

访问如下形式的真实地址,即可看到模拟数据,端口默认为3000,可配置为其他值

http://127.0.0.1:3000/xxx/xxx/xxx.do

所有的接口路径请求,都生成在${projectName}/urlsReal.js里

smock's People

Watchers

 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.