JSPM

express-gateway-plugin-openapi3-mock-server

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q21145F
  • License Beerware

A plugin which provides a mock server based on an OpenAPI 3 specification.

Package Exports

  • express-gateway-plugin-openapi3-mock-server

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-gateway-plugin-openapi3-mock-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Express Gateway OpenAPI 3 Mock Server Plugin

This plugin is under active development. Would you meet any problems, please open a new issue after verifying that there isn't one already.

Prerequisites

Please follow the instructions on Express Gateway's Getting started page.

Also please take a look at how plugins are installed and enabled.

Installation

eg plugin install express-gateway-plugin-openapi3-mock-server

Configuration

You can use samples/base-paths.yml for testing purposes. If so, please create a definitions folder in the project root and copy the sample YAML there.

system.config.yml

# some config in front of the plugins section

plugins:
  express-gateway-plugin-openapi3-mock-server:
    definitionFile: 'definitions/yourdefinition.yml' # The file containing your API's specification

# some config after the plugins section

gateway.config.yml (A barebone example, if nothing else is used.)

http:
  port: 80
apiEndpoints:
  api:
    host: '*'
policies:
  - mock
pipelines:
  api:
    apiEndpoints:
        - api
    policies:
        - mock:
          - action

The above configuration disables the Admin CLI and will do nothing but provide a dummy responder based on your OpenAPI specification.

Features

  • Endpoints with appropriate request types are parsed and the first response example is used as a response body.
  • HTTP and apiKey auth header check support

To do

  • Accept header checks to return appropriate response example
  • X-* headers for testing error responses
  • X-* headers for response example selection
  • Input parameter validation
  • Generators for random response data based on provided schema