npm.io
0.0.15 • Published 10 years ago

miniswagger

Licence
ISC
Version
0.0.15
Deps
4
Vulns
4
Weekly
0
DeprecatedThis package is deprecated

miniswagger

Installation

npm install git+https://github.com/SelfishInc/miniswagger

or

npm install git+ssh://git@github.com:SelfishInc/miniswagger.git

Usage

Works through browserify

var miniswagger = require('miniswagger').default;
Fetching specs from remote server

ready promise is resolved once the API object is constructed:

var Api = new miniswagger.fromUrl('https://spec.selfishbeta.com/selfish/apis');

Api.ready.then(
    function() {
        Api.core.getStory({id: '0689a05650017f80'})
        .then(function(v) {console.log (v); });
    },

    function(error) {
        console.log(error);
    }
);
Using spec from JSON

This is synchronous:

var specs = require('./api-specs').default;
var miniswagger = require('miniswagger').default;
var Api = new miniswagger.fromSpecs(specs);

Api.core.getStory({id: '0689a05650017f80'}).then(
    function(story) {
        console.log(story);
    },
    function(error) {
        console.error(error);
    }
);