appirio-tech/auto-config-fake-server

Name: auto-config-fake-server

Owner: Topcoder

Description: Create a Sinon fake server with a Swagger JSON file.

Created: 2015-04-30 18:37:40.0

Updated: 2017-02-20 07:23:31.0

Pushed: 2016-01-22 21:58:30.0

Homepage: null

Size: 163

Language: CoffeeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

auto-config-fake-server

Build Status Coverage Status

Create a Sinon fake server with a Swagger JSON file. Requests that match the API scheme, host, and base path will be stubbed while others will be ignored.

Install
r install auto-config-fake-server --save-dev

Then add a <script> to your index.html:

ipt src="/bower_components/sinon/index.js"></script>
ipt src="/bower_components/auto-config-fake-server/dist/auto-config-fake-server.js"></script>
 gulp task generated fixtures -->
ipt src="/scripts/json-fixtures.js"></script>
Usage
ConfigFakeServer.init();
ConfigFakeServer.fakeServer.respondImmediately = true; // docs are at http://sinonjs.org/docs
ConfigFakeServer.consume(swaggerJSONObject); // schema should be mocked now
AutoConfigFakeServer

A singleton style object in the window scope.

.init()

This method will create a fakeServer instance that can be referenced with AutoConfigFakeServer.fakeServer. Although fakeServer is active, no http request will be stopped.

.consume(swaggerJSONObject)

The swaggerJSONObject should be an object generated from a swagger schema. It can also be an array of swaggerJSONObject. You may call this method multiple times for different swagger schemas. If you have a json file, you may want to use a gulp/grunt task to turn it into a fixture (https://www.npmjs.com/package/gulp-fixtures2js).

.restore()

This method will restore the fakeServer instance and unmocked all http requests.

Future Ideas
Development
License

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.