Skip to content

mrtnvh/things-you-can-do-with-an-openapi-mocking-server

Repository files navigation

Things you can to with an OpenAPI Mocking Server

Some examples of things you can do in a front end project with Prism, an OpenAPI mocking server.

Requirements

  • Node v10+
  • NPM v6+
  • Docker

Installation

npm install

Run

This example contains 2 processes:

  1. A Nuxt.js (Vue.js framework) application.
  2. A Prism mocking server.

There are several scenario's of how you can run de example code:

1. npm

Start up both processes through npm.

npm run dev:all

Run only the Nuxt.js application.

npm run dev

Run only the Prism mock.

npm run mocks

# With a watcher on the OpenAPI document
npm run mocks:watch

2. Advanced JavaScript

If the default Prism functionality doesn't meet your requirements, you could run Prism programmatically and plugin on the Fastify instance that Prism uses as server.

npm run mocks:advanced

# With a watcher on the OpenAPI document
npm run mocks:advanced:watch

The command will run the mocks/runner.js with Node.

3. Docker

Prism also provides a Docker image on which you can mock your OpenAPI document.

docker run --rm -it -p 4010:4010 -v $(pwd):/tmp stoplight/prism:3 mock -d -h 0.0.0.0 "mocks/prism.js"

Tests

This example uses Cypress for integration/e2e

Start the Cypress UI

npx cypress open

Run Cypress in the CLI

npx cypress run

All Cypress related files are located in the cypress folder.

About

Some examples of things you can do in a front end project with Prism, an OpenAPI mocking server

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published