koa-swagger-mock

2.0.1 • Public • Published

koa-swagger-mock

build build download

NPM

Introduce

It's a middleware for swagger-mock!

preview this project, do this!

git clone https://github.com/ShanaMaid/koa-swagger-mock

npm install

npm run test

url: localhost:3000/api/pet/1212121212

Usage

npm install koa-swagger-mock -save

Example

const Koa = require('koa');
const app = new Koa();
const KoaSwaggerMock = require('../lib/koa-swagger-mock');
const path = require('path');
const fs = require('fs');


const swagger = JSON.parse(
  fs.readFileSync(path.resolve(__dirname, '../json/example.json'), {encoding: 'utf8'})
);

const koaSwagMock = KoaSwaggerMock({
  swagger,
  prefix: '/api'
});

app.use(koaSwagMock.routes());
app.listen(3000);

this is mock resp!

http://localhost:3000/api/pet/findByStatus mock resp

API

KoaSwaggerMock({...params})

  • swagger - (Object) - (required) - api can be one of the following.

    • A Swagger JSON Object.
  • prefix - (String) - (optional) - url prefix.

    • default is ''

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.1
    501
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.1
    501
  • 2.0.0
    1
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i koa-swagger-mock

Weekly Downloads

111

Version

2.0.1

License

MIT

Unpacked Size

4.26 kB

Total Files

5

Last publish

Collaborators

  • shanamaid