Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.
/ mirage-openapi Public archive

Mock OpenAPI responses in ember-cli-mirage

Notifications You must be signed in to change notification settings

jlegrone/mirage-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mirage-openapi

npm version Build Status codecov

WARNING: This is a work in progress and is not yet meant for real-world use. Please feel free to file an issue or open a pull request if you come across any bugs.

mirage-openapi is a plugin for ember-cli-mirage that consumes openAPI/swagger documentation and mocks endpoints at runtime.

This package pairs well with ember-cli-openapi-generate.

Install

$ npm install --dev mirage-openapi

You'll also need to install ember-browserify and ember-cli-mirage if not already present:

$ ember install ember-browserify ember-cli-mirage

Usage Examples

Consume swagger schema:

// ./mirage/config.js

import mirageOpenAPI from 'npm:mirage-openapi';

export default function() {
  mirageOpenAPI({
    server: this,
    configs: [{
      definition: "http://petstore.swagger.io/v2/swagger.json",
      namespace: "http://petstore.swagger.io/v2"
    }]
  });
}

Override routes defined in swagger schema:

// ./mirage/config.js

import mirageOpenAPI from 'npm:mirage-openapi';

export default function() {
  // Custom handler for /pet/:id route
  this.get("/pet/:id", function(schema, request) {
    return schema.pets.find(request.params.id);
  });

  mirageOpenAPI({
    server: this,
    configs: [{
      definition: "http://petstore.swagger.io/v2/swagger.yaml",
      namespace: "/"
    }]
  });
}

About

Mock OpenAPI responses in ember-cli-mirage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published