OpenAPI Mock Server

可生成随机数据的 OpenAPI 模拟服务器。「OpenAPI mock server with random data generation」

Github星跟蹤圖

OpenAPI Mock Server

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

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

If you want to reference a local file in docker compose:

  • you must first mount the host dir into container - ./openapi:/etc/openapi
  • only then can you reference it
version: '3.0'

services:
  openapi_mock:
    container_name: openapi_mock
    image: muonsoft/openapi-mock
    volumes:
    - ./openapi:/etc/openapi
    environment:
      OPENAPI_MOCK_SPECIFICATION_URL: '/etc/openapi/petstore.yaml'
    ports:
      - "8080:8080"

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
派生數56
提交數335
已啟用問題?
問題數43
打開的問題數19
拉請求數36
打開的拉請求數2
關閉的拉請求數14
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?