swagger - cllu/.rc GitHub Wiki

Swagger 2.0 has only one files, which is a big bonus for me. But the library I use (django-rest-swagger and scalatra-swagger) don't support swagger 2.0 yet. We can use api-spec-converter to convert swagger 1.2 endpoints to swagger 2.0 file.

$ api-spec-converter http://localhost:8000/docs/api-docs/  --from=swagger_1 --to=swagger_2 > swagger.json

Some API endpoints may need authentication, in this case, we need to modify the api-spec-converter to add the authenticated cookie in requests. In /usr/local/lib/node_modules/api-spec-converter/lib/util.js, around line 38:

function readUrl(url, callback) {
  var jar = Request.jar();
  var cookie = Request.cookie('sessionid=ph9ebsee9399j8gld0ze5r7nx3wua5j6');
  jar.setCookie(cookie, url);
  var options = {
    uri: url,
    jar: jar,
    headers: {
      //TODO: allow different types to define different formats.
      'Accept': 'application/json,*/*',
    }
  };
  // the rest
}