/swagger-mock-file-generator-by-cases

A mock file generator for swagger, help you customize data by cases

Primary LanguageJavaScript

Badges

version NPM downloads Build Status

Install

npm i swagger-mock-file-generator-by-cases -s

API

require('swagger-mock-file-generator-by-cases')(<swaggerFile>, <mockFilePath>[, callback])

Output

The mock file name is converted api path through the '/' symbol.

If api path is 'api/v1/accompany/list', mock file name will be 'api-v1-accompany-list.json'.

Data in cases array will give priority to use example in difinitions, you can customize more data in json file.

{
    "cases": [
        {
            "data": {},
            "message": "success",
            "status": 0
        }
    ]
}

Notice: mockFilePath must be an absolute path string(eg './mock/').

This generator is based on swagger-mock-file-generator,thanks for supporting!