Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reeli/swagger-faker
Generate mocker services automatically through Swagger or OpenAPI.
https://github.com/reeli/swagger-faker
faker mock-data-generator swager swagger-faker
Last synced: about 1 month ago
JSON representation
Generate mocker services automatically through Swagger or OpenAPI.
- Host: GitHub
- URL: https://github.com/reeli/swagger-faker
- Owner: reeli
- Created: 2019-07-25T03:10:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-23T08:41:20.000Z (over 1 year ago)
- Last Synced: 2024-11-29T15:52:37.288Z (about 1 month ago)
- Topics: faker, mock-data-generator, swager, swagger-faker
- Language: TypeScript
- Homepage: https://reeli.github.io/swagger-faker/
- Size: 949 KB
- Stars: 45
- Watchers: 3
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swagger Faker
![Build Status](https://github.com/reeli/swagger-faker/actions/workflows/deploy.yml/badge.svg)
[![codecov](https://codecov.io/gh/reeli/swagger-faker/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/reeli/swagger-faker)
[![License](https://img.shields.io/npm/l/swagger-faker.svg?style=flat-square)](https://npmjs.org/package/@ts-tool/swagger-faker)
[![NPM](https://img.shields.io/npm/v/swagger-faker.svg?style=flat-square)](https://npmjs.org/package/@ts-tool/swagger-faker)Swagger Faker is a tool which can help you generate fake data from your swagger.json file, then it will start a mock server automatically with the generated fake data.
## How to Use
1. Install
```shell
npm i swagger-faker -g
```2. Init config file by command:
```shell
swagger-faker init
```Then it will generate a config file `swagger-faker.config.json` in current path, update that config file:
```json
{
"sourcePaths": ["./source/openapi.json"],
"outputFolder": "mock-server",
"timeout": 180000,
"port": 8081
}
```- **sourcePaths**: `required`, put your swagger/openapi file path here. Either local path(eg. "./source/openapi.json") or remote path(eg. https://petstore.swagger.io/v2/swagger.json) is supported. Valid format: json, yaml, yml.
- **outputFolder**: `optional`
- **timeout**: `optional`,
- **port**: `optional`3. Generate fake data
```shell
swagger-faker gen
```4. Start the mock server
```shell
swagger-faker run
```## Examples
```shell
git clone https://github.com/reeli/swagger-faker-examples.git
cd swagger-faker-examples
npm install
npm start
```Then you'll see:
1. A `mock-server` folder has been generated in your current path, and all mock data is setting in `mock-server/data` folder, you can customize them if needed.
2. A mock server has been started in `http://localhost:8081`, you can open your browser and visit one of the mock API by `http://localhost:8081/api/v2/store/order/1` (The mock data is setting in: `mock-server/data/getOrderById.json`)