Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generate a tab delimited table of endpoints on a Swagger-described API
#!/usr/bin/env node
For Swagger 1.2 docs format.
Hardcode the base path in the urlFor() function.
Assumes Node 6+.
const rp = require('request-promise');
const urlFor = path => `${path}`;
function logGroup(groupDoc) {
for (const api of groupDoc.apis) {
for (const operation of api.operations) {
console.log(api.path, '\t', operation.httpMethod, '\t', operation.summary);
function fetchAndLogGroup(groupDocPath) {
.then(str => JSON.parse(str))
function walkRoot(rootDoc) {
const groupPromises = => fetchAndLogGroup(api.path));
return Promise.all(groupPromises);
function fetchAndLogRoot() {
.then(str => JSON.parse(str))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.