Skip to content

Instantly share code, notes, and snippets.

@mittsh
Last active March 19, 2018 18:00
Show Gist options
  • Save mittsh/cf1fa9b0e66fd2bcdb05 to your computer and use it in GitHub Desktop.
Save mittsh/cf1fa9b0e66fd2bcdb05 to your computer and use it in GitHub Desktop.
Convert WADL file to Swagger to import in Paw

Import WADL definitions to Paw

  1. Make sure your WADL file is in the same directory under the name wadl.xml.

  2. Then, you can just run:

npm install
node wadl2swagger.js
  1. You'll get a Swagger file swagger.json. Then use the Swagger Importer to import the fie in Paw.
{
"name": "wadltest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wadl2json": "^1.0.3"
}
}
var wadl2json = require("wadl2json");
var fs = require('fs');
var options = {
sort: false, // set it to true if you want to sort operations and verbs in the alphabetical order
stringify: true, // set it to true if you want to get a string instead of an object
prettify: true, // set it to true if you want to get an indented string (stringify=true required)
title: "Simple API", // the title of the API (required)
description: "Simple API description", // the description of the API (required)
version: "1.4.2", // the version of the API (required)
blacklist: ["/internal"] // the path roots you want to blacklist
};
var swaggerFromFile = wadl2json.fromFile("./wadl.xml", options);
fs.writeFile('./swagger.json', swaggerFromFile);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment