Skip to content
Document your express/restify rest api and expose to swagger ui.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.jshintrc
.npmignore
CHANGELOG
Gruntfile.js
LICENSE-MIT
README.md
package.json

README.md

swagger-doc

Document your express/restify rest api and expose to swagger ui.

Getting Started

Install the module with: npm install swagger-doc

Example

var restify = require('restify'),
    swagger = require('swagger-doc'),
    server = restify.createServer();


// All configuration is optional. Only server is needed to add swagger routes.
swagger.configure(server, {
	discoveryUrl: "/resources.json",
	version:      "0.1",
	basePath:     "https://api.product.com"
});


// Create a new swagger resource at specified route.
docs = swagger.createResource("/payments");

docs.models.Payment = {...};

// Documents an api, all options are same as in swagger.
docs.get("/payments/{id}", "Gets information about a specific payment", {
	notes: "The information is very sexy.",
	nickname: "getPayment",
	parameters: [
	    {name:"id", description: "Id of payment", required:true, dataType: "string", paramType: "path"}
	]
});

// Another resource
var docs = swagger.createResource("/account", {
    models: {
        Account: {...}
    }
});

// Swagger-doc has express-like api.
docs.post('/account/authenticate', {
    summary: "Authenticates a user"
});

docs.get('/account/user', {
    summary: "Returns the logged in user"
});

docs.delete('/account/user', {
    summary: "Logs out the current user"
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

(Nothing yet)

License

Copyright (c) 2012 Eirikur Nilsson
Licensed under the MIT license.

You can’t perform that action at this time.