Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.04 KB

README.md

File metadata and controls

34 lines (26 loc) · 1.04 KB

Inspired by: https://github.com/moander/serve-swagger-editor. Added swagger-ui for hosting too.

Main Feature

  • To allow the Swagger Editor to save the API spec file to the backend (using PUT) instead of using client-side localstorage.
  • The Swagger UI can read the same spec file and render the UI in real time.

Sample Server Code

var http = require('http');
var serveSwagger = require('./serve-swagger'); 

var app = serveSwagger({
  disableNewUserIntro: true,
  useBackendForStorage: true,
  useYamlBackend: true
}, './tmp/myspec.yaml');

var server = http.createServer(app);

server.on('request', function (req, res) {

  res.on('finish', function () {
    console.log(res.statusCode, req.method, req.originalUrl);     
  });
});

server.listen(8080, function () {
  console.log(server.address());
});

With above code, you should be able to access