Osprey Mock Service
Generate an API mock service from a RAML definition using Osprey.
Usage
Global (CLI)
npm install -g osprey-mock-service
Start the service from the CLI. This will automatically use the baseUri
as the path to the mock service. For example, http://example.com/api
will result in http://localhost:{PORT}/api
.
osprey-mock-service -f api.raml -p 3000 --cors
Options
-f
Path to the root RAML definition (E.g./path/to/api.raml
)-p
Port number to bind the server locally--cors
Enable CORS with the API
Locally (JavaScript)
npm install osprey-mock-service --save
The mocking service simply accepts a RAML definition and returns a router that can be mounted into any Connect-style middleware layer or even used with http
. Best used with osprey
to support incoming validation automatically.
const ospreyMockService = const express = const wap = WebApiParserconst path = const osprey = { const app = const fpath = `file://` let model = await wapraml10 model = await wapraml10 app app app}
Additional methods
createServer
Creates a mock service instance with OspreycreateServerFromBaseUri
Creates a mock service with Osprey and uses the base URI pathloadFile
Creates a mock service with Osprey and the base URI path from a RAML file
License
Apache License 2.0