openapi-mock

Swagger mock server with fake data generation support

Github星跟踪图

OpenAPI Mock Server

CI
Scrutinizer Code Quality
Code Coverage
GitHub release (latest by date)

OpenAPI API mock server with random data generation by specified schemas.

  • OpenAPI 3.x support.
  • Load specification from a local file or URL.
  • JSON and YAML format supported.
  • Generates fake response data by provided schemas or by examples.
  • Content negotiation by Accept header.
  • Can be used as standalone application (Linux and Windows) or can be run via Docker container.

Supported features, Feature, Support status, ---, ---, generating xml response, basic support (without xml tags), generating json response, supported, generation of basic types, supported, generation of enums, supported, generation of associative arrays, supported, generation of combined types, supported (without tag not and discriminator), local reference resolving, supported, remote reference resolving, not supported, URL reference resolving, not supported, validating request data, not supported, force using custom response schema, not supported (schema detected automatically), ## Quick start

Download latest binary and run a server.

# runs a local server on port 8080
./openapi-mock serve --specification-url https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml

# to test that the server successfully ran
curl 'http://localhost:8080/v1/pets'

Alternatively, you can use Docker image.

# downloads an image
docker pull muonsoft/openapi-mock

# runs a docker container with exported port 8080
docker run -p 8080:8080 -e "OPENAPI_MOCK_SPECIFICATION_URL=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml" --rm muonsoft/openapi-mock

# to test that the server successfully ran
curl 'http://localhost:8080/v1/pets'

Also, you can use Docker Compose. Example of docker-compose.yml

version: '3.0'

services:
  openapi_mock:
    container_name: openapi_mock
    image: muonsoft/openapi-mock
    environment:
      OPENAPI_MOCK_SPECIFICATION_URL: 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml'
    ports:
      - "8080:8080"

To start up a container run command.

docker-compose up -d

Usage guide

License

This project is licensed under the MIT License - see the LICENSE file for details.

主要指标

概览
名称与所有者muonsoft/openapi-mock
主编程语言Go
编程语言Dockerfile (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-08-21 18:16:27
推送于2024-06-27 19:33:08
最后一次提交2023-03-11 12:19:53
发布数28
最新版本名称v0.3.9 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数505
关注者数8
派生数57
提交数335
已启用问题?
问题数43
打开的问题数19
拉请求数36
打开的拉请求数2
关闭的拉请求数14
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?