Merge branch 'develop' of github.com:getinsomnia/insomnia into develop

This commit is contained in:
Gregory Schier 2018-01-17 11:21:03 +07:00
commit b7c9baa4c7
12 changed files with 4150 additions and 1108 deletions

1026
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1989,7 +1989,6 @@
"requires": {
"anymatch": "1.3.2",
"async-each": "1.0.1",
"fsevents": "1.1.3",
"glob-parent": "2.0.0",
"inherits": "2.0.3",
"is-binary-path": "1.0.1",
@ -5022,81 +5021,197 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz",
"integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==",
"optional": true,
"fstream": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
"requires": {
"nan": "2.5.1",
"node-pre-gyp": "0.6.39"
"graceful-fs": "4.1.11",
"inherits": "2.0.3",
"mkdirp": "0.5.1",
"rimraf": "2.6.2"
}
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"gauge": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
"integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
"requires": {
"aproba": "1.2.0",
"console-control-strings": "1.1.0",
"has-unicode": "2.0.1",
"object-assign": "4.1.1",
"signal-exit": "3.0.2",
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wide-align": "1.1.2"
}
},
"generate-function": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
"integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ="
},
"generate-object-property": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
"integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
"requires": {
"is-property": "1.0.2"
}
},
"get-caller-file": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz",
"integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U="
},
"get-stdin": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
"integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4="
},
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
},
"getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"requires": {
"assert-plus": "1.0.0"
}
},
"github-from-package": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"glob-base": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz",
"integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=",
"requires": {
"glob-parent": "2.0.0",
"is-glob": "2.0.1"
}
},
"glob-parent": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz",
"integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
"requires": {
"is-glob": "2.0.1"
}
},
"global": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz",
"integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=",
"requires": {
"min-document": "2.19.0",
"process": "0.5.2"
}
},
"global-dirs": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz",
"integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=",
"requires": {
"ini": "1.3.5"
}
},
"globals": {
"version": "9.18.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
"integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ=="
},
"globby": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
"integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=",
"requires": {
"array-union": "1.0.2",
"arrify": "1.0.1",
"glob": "7.1.2",
"object-assign": "4.1.1",
"pify": "2.3.0",
"pinkie-promise": "2.0.1"
}
},
"got": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz",
"integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=",
"requires": {
"create-error-class": "3.0.2",
"duplexer3": "0.1.4",
"get-stream": "3.0.0",
"is-redirect": "1.0.0",
"is-retry-allowed": "1.1.0",
"is-stream": "1.1.0",
"lowercase-keys": "1.0.0",
"safe-buffer": "5.1.1",
"timed-out": "4.0.1",
"unzip-response": "2.0.1",
"url-parse-lax": "1.0.0"
},
"dependencies": {
"abbrev": {
"version": "1.1.0",
"bundled": true,
"optional": true
},
"ajv": {
"version": "4.11.8",
"bundled": true,
"optional": true,
"requires": {
"co": "4.6.0",
"json-stable-stringify": "1.0.1"
}
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true
},
"aproba": {
"version": "1.1.1",
"bundled": true,
"optional": true
},
"are-we-there-yet": {
"version": "1.1.4",
"bundled": true,
"optional": true,
"requires": {
"delegates": "1.0.0",
"readable-stream": "2.2.9"
}
},
"asn1": {
"version": "0.2.3",
"bundled": true,
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"bundled": true,
"optional": true
},
"asynckit": {
"version": "0.4.0",
"bundled": true,
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"bundled": true,
"optional": true
},
"aws4": {
"version": "1.6.0",
"bundled": true,
"optional": true
},
"balanced-match": {
"version": "0.4.2",
"bundled": true
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"bundled": true,
"optional": true,
"unzip-response": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz",
"integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c="
}
}
},
"graceful-fs": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"graphql": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-0.10.5.tgz",
"integrity": "sha512-Q7cx22DiLhwHsEfUnUip1Ww/Vfx7FS0w6+iHItNuN61+XpegHSa3k5U0+6M5BcpavQImBwFiy0z3uYwY7cXMLQ==",
"requires": {
"iterall": "1.1.3"
}
},
"graphql-config": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/graphql-config/-/graphql-config-1.0.8.tgz",
"integrity": "sha512-lVw5rOoy7WVC8/ezfXoT3MsqiXKFl4xZlzmbkt3IzEV0X5C0IjAR/YAlLNorwVKDrm6o2/F7vTtrC0A6Yhm6xQ==",
"requires": {
"graphql": "0.11.7",
"graphql-request": "1.4.0",
"js-yaml": "3.10.0",
"minimatch": "3.0.4",
"rimraf": "2.6.2"
},
"dependencies": {
"graphql": {
"version": "0.11.7",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-0.11.7.tgz",
"integrity": "sha512-x7uDjyz8Jx+QPbpCFCMQ8lltnQa4p4vSYHx6ADe8rVYRTdsyhCJbvSty5DAsLVmU6cGakl+r8HQYolKHxk/tiw==",
"requires": {
"tweetnacl": "0.14.5"
}
@ -8193,12 +8308,6 @@
"integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=",
"dev": true
},
"nan": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.5.1.tgz",
"integrity": "sha1-1bAWkSUzJql6K77p5hxV2NYDUeI=",
"optional": true
},
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",

View File

@ -7,7 +7,8 @@ const importers = [
require('./src/importers/postman'),
require('./src/importers/postman-env'),
require('./src/importers/har'),
require('./src/importers/curl')
require('./src/importers/curl'),
require('./src/importers/swagger2')
];
module.exports.convert = async function (contents) {

View File

@ -1,7 +1,17 @@
{
"requires": true,
"name": "insomnia-importers",
"version": "1.5.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"argparse": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
"integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
"requires": {
"sprintf-js": "1.0.3"
}
},
"array-filter": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
@ -17,16 +27,82 @@
"resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
"integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys="
},
"call-me-maybe": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
"integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms="
},
"commander": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.12.1.tgz",
"integrity": "sha512-PCNLExLlI5HiPdaJs4pMXwOTHkSCpNQ1QJH9ykZLKtKEyKu3p9HgmH5l97vM8c0IUz6d54l+xEu2GG9yuYrFzA=="
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
},
"format-util": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.3.tgz",
"integrity": "sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU="
},
"js-yaml": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
"requires": {
"argparse": "1.0.9",
"esprima": "4.0.0"
}
},
"json-schema-ref-parser": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-4.0.4.tgz",
"integrity": "sha512-jbED8wPzWeGipggE2d7oM1kohCSZpscU+kBkkF+vjqI683y72hcPRGI/Ql1OqYK3MOnSQp+t1ZcHdQQ/MRF4UQ==",
"requires": {
"call-me-maybe": "1.0.1",
"debug": "3.1.0",
"js-yaml": "3.10.0",
"ono": "4.0.2"
}
},
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM="
},
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"ono": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.2.tgz",
"integrity": "sha512-EFXJFoeF+KkZW4lwmcPMKHp2ZU7o6CM+ccX2nPbEJKiJIdyqbIcS1v6pmNgeNJ6x4/vEYn0/8oz66qXSPnnmSQ==",
"requires": {
"format-util": "1.0.3"
}
},
"shell-quote": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz",
@ -37,6 +113,51 @@
"array-reduce": "0.0.0",
"jsonify": "0.0.0"
}
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"swagger-methods": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/swagger-methods/-/swagger-methods-1.0.4.tgz",
"integrity": "sha512-xrKFLbrZ6VxRsg+M3uJozJtsEpNI/aPfZsOkoEjXw8vhAqdMIqwTYGj1f4dmUgvJvCdZhV5iArgtqXgs403ltg=="
},
"swagger-parser": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/swagger-parser/-/swagger-parser-4.0.1.tgz",
"integrity": "sha512-LV2OXOcwtzboCFKPQMkMlkzisy0YLMx5mYF8rSQp65jAOvGhxD8QpAFEC/Sm0XUUawnUDEjCjv0WNKt9XW/Oog==",
"requires": {
"call-me-maybe": "1.0.1",
"debug": "3.1.0",
"json-schema-ref-parser": "4.0.4",
"ono": "4.0.2",
"swagger-methods": "1.0.4",
"swagger-schema-official": "2.0.0-bab6bed",
"z-schema": "3.19.0"
}
},
"swagger-schema-official": {
"version": "2.0.0-bab6bed",
"resolved": "https://registry.npmjs.org/swagger-schema-official/-/swagger-schema-official-2.0.0-bab6bed.tgz",
"integrity": "sha1-cAcEaNbSl3ylI3suUZyn0Gouo/0="
},
"validator": {
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-9.2.0.tgz",
"integrity": "sha512-6Ij4Eo0KM4LkR0d0IegOwluG5453uqT5QyF5SV5Ezvm8/zmkKI/L4eoraafZGlZPC9guLkwKzgypcw8VGWWnGA=="
},
"z-schema": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.19.0.tgz",
"integrity": "sha512-V94f3ODuluBS4kQLLjNhwoMek0dyIXCsvNu/A17dAyJ6sMhT5KkJQwSn07R0naByLIXJWMDk+ruMfI/3G3hS4Q==",
"requires": {
"commander": "2.12.1",
"lodash.get": "4.4.2",
"lodash.isequal": "4.5.0",
"validator": "9.2.0"
}
}
}
}

View File

@ -17,6 +17,7 @@
},
"dependencies": {
"commander": "^2.9.0",
"shell-quote": "^1.6.1"
"shell-quote": "^1.6.1",
"swagger-parser": "^4.0.1"
}
}

View File

@ -0,0 +1,318 @@
{
"_type": "export",
"__export_format": 3,
"__export_date": "2018-01-09T23:32:46.908Z",
"__export_source": "insomnia.importers:v0.1.0",
"resources": [
{
"_type": "workspace",
"_id": "__WORKSPACE_1__",
"parentId": null,
"name": "Swagger Petstore 1.0.0",
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
},
{
"parentId": "__WORKSPACE_1__",
"name": "Base environment",
"data": {
"base_url": "{{ scheme }}://{{ host }}{{ base_path }}"
},
"_type": "environment",
"_id": "__ENV_1__"
},
{
"parentId": "__ENV_1__",
"name": "Swagger env",
"data": {
"base_path": "/v2",
"scheme": "http",
"host": "petstore.swagger.io"
},
"_type": "environment",
"_id": "__ENV_2__"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Add a new pet to the store",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
"text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "addPet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Update an existing pet",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
"text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}"
},
"method": "PUT",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updatePet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Finds Pets by status",
"url": "{{ base_url }}/pet/findByStatus",
"body": {},
"method": "GET",
"parameters": [
{
"name": "status",
"disabled": false,
"value": [
"available"
]
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "findPetsByStatus"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Finds Pets by tags",
"url": "{{ base_url }}/pet/findByTags",
"body": {},
"method": "GET",
"parameters": [
{
"name": "tags",
"disabled": false,
"value": [
"string"
]
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "findPetsByTags"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Find pet by ID",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getPetById"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Updates a pet in the store with form data",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Deletes a pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [
{
"name": "api_key",
"disabled": true,
"value": "string"
}
],
"authentication": {},
"_type": "request",
"_id": "deletePet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "uploads an image",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Returns pet inventories by status",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getInventory"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Place an order for a pet",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "placeOrder"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Find purchase order by ID",
"url": "{{ base_url }}/store/order/{{ orderId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getOrderById"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Delete purchase order by ID",
"url": "{{ base_url }}/store/order/{{ orderId }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "deleteOrder"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Create user",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Creates list of users with given input array",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUsersWithArrayInput"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Creates list of users with given input array",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUsersWithListInput"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Logs user into the system",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
"parameters": [
{
"name": "username",
"disabled": false,
"value": "string"
},
{
"name": "password",
"disabled": false,
"value": "string"
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "loginUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Logs out current logged in user session",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "logoutUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Get user by user name",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getUserByName"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Updated user",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updateUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Delete user",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "deleteUser"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,318 @@
{
"_type": "export",
"__export_format": 3,
"__export_date": "2018-01-09T23:32:54.091Z",
"__export_source": "insomnia.importers:v0.1.0",
"resources": [
{
"_type": "workspace",
"_id": "__WORKSPACE_1__",
"parentId": null,
"name": "Swagger Petstore 1.0.0",
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
},
{
"parentId": "__WORKSPACE_1__",
"name": "Base environment",
"data": {
"base_url": "{{ scheme }}://{{ host }}{{ base_path }}"
},
"_type": "environment",
"_id": "__ENV_1__"
},
{
"parentId": "__ENV_1__",
"name": "Swagger env",
"data": {
"base_path": "/v2",
"scheme": "http",
"host": "petstore.swagger.io"
},
"_type": "environment",
"_id": "__ENV_2__"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Add a new pet to the store",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
"text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "addPet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Update an existing pet",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
"text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}"
},
"method": "PUT",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updatePet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Finds Pets by status",
"url": "{{ base_url }}/pet/findByStatus",
"body": {},
"method": "GET",
"parameters": [
{
"name": "status",
"disabled": false,
"value": [
"available"
]
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "findPetsByStatus"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Finds Pets by tags",
"url": "{{ base_url }}/pet/findByTags",
"body": {},
"method": "GET",
"parameters": [
{
"name": "tags",
"disabled": false,
"value": [
"string"
]
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "findPetsByTags"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Find pet by ID",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getPetById"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Updates a pet in the store with form data",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Deletes a pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [
{
"name": "api_key",
"disabled": true,
"value": "string"
}
],
"authentication": {},
"_type": "request",
"_id": "deletePet"
},
{
"parentId": "__WORKSPACE_1__",
"name": "uploads an image",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Returns pet inventories by status",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getInventory"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Place an order for a pet",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "placeOrder"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Find purchase order by ID",
"url": "{{ base_url }}/store/order/{{ orderId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getOrderById"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Delete purchase order by ID",
"url": "{{ base_url }}/store/order/{{ orderId }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "deleteOrder"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Create user",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Creates list of users with given input array",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUsersWithArrayInput"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Creates list of users with given input array",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createUsersWithListInput"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Logs user into the system",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
"parameters": [
{
"name": "username",
"disabled": false,
"value": "string"
},
{
"name": "password",
"disabled": false,
"value": "string"
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "loginUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Logs out current logged in user session",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "logoutUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Get user by user name",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "getUserByName"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Updated user",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "updateUser"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Delete user",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "DELETE",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "deleteUser"
}
]
}

View File

@ -0,0 +1,101 @@
swagger: "2.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
host: petstore.swagger.io
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
type: integer
format: int32
responses:
"200":
description: A paged array of pets
headers:
x-next:
type: string
description: A link to the next page of responses
schema:
$ref: '#/definitions/Pets'
default:
description: unexpected error
schema:
$ref: '#/definitions/Error'
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
"201":
description: Null response
default:
description: unexpected error
schema:
$ref: '#/definitions/Error'
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
type: string
responses:
"200":
description: Expected response to a valid request
schema:
$ref: '#/definitions/Pets'
default:
description: unexpected error
schema:
$ref: '#/definitions/Error'
definitions:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: '#/definitions/Pet'
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string

View File

@ -0,0 +1,83 @@
{
"_type": "export",
"__export_format": 3,
"__export_date": "2018-01-09T23:33:12.799Z",
"__export_source": "insomnia.importers:v0.1.0",
"resources": [
{
"_type": "workspace",
"_id": "__WORKSPACE_1__",
"parentId": null,
"name": "Swagger Petstore 1.0.0",
"description": ""
},
{
"parentId": "__WORKSPACE_1__",
"name": "Base environment",
"data": {
"base_url": "{{ scheme }}://{{ host }}{{ base_path }}"
},
"_type": "environment",
"_id": "__ENV_1__"
},
{
"parentId": "__ENV_1__",
"name": "Swagger env",
"data": {
"base_path": "/v1",
"scheme": "http",
"host": "petstore.swagger.io"
},
"_type": "environment",
"_id": "__ENV_2__"
},
{
"parentId": "__WORKSPACE_1__",
"name": "List all pets",
"url": "{{ base_url }}/pets",
"body": {
"mimeType": "application/json"
},
"method": "GET",
"parameters": [
{
"name": "limit",
"disabled": true,
"value": 0
}
],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "listPets"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Create a pet",
"url": "{{ base_url }}/pets",
"body": {
"mimeType": "application/json"
},
"method": "POST",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "createPets"
},
{
"parentId": "__WORKSPACE_1__",
"name": "Info for a specific pet",
"url": "{{ base_url }}/pets/{{ petId }}",
"body": {
"mimeType": "application/json"
},
"method": "GET",
"parameters": [],
"headers": [],
"authentication": {},
"_type": "request",
"_id": "showPetById"
}
]
}

View File

@ -0,0 +1,283 @@
const SwaggerParser = require('swagger-parser');
const SUPPORTED_SWAGGER_VERSION = '2.0';
const MIMETYPE_JSON = 'application/json';
const SUPPORTED_MIME_TYPES = [MIMETYPE_JSON];
const WORKSPACE_ID = '__WORKSPACE_1__';
module.exports.id = 'swagger2';
module.exports.name = 'Swagger 2.0';
module.exports.description = 'Importer for Swagger 2.0 specification (json/yaml)';
module.exports.convert = async function (rawData) {
//validate
const document = await parseDocument(rawData);
if(!document || document.swagger !== SUPPORTED_SWAGGER_VERSION) {
return null;
}
//import
const workspace = {
_type: 'workspace',
_id: WORKSPACE_ID,
parentId: null,
name: `${document.info.title} ${document.info.version}`,
description: document.info.description || ''
};
const baseEnv = {
_type: 'environment',
_id: '__ENV_1__',
parentId: '__WORKSPACE_1__',
name: 'Base environment',
data: {
base_url: '{{ scheme }}://{{ host }}{{ base_path }}'
}
};
const swaggerEnv = {
_type: 'environment',
_id: '__ENV_2__',
parentId: baseEnv._id,
name: 'Swagger env',
data: {
base_path: document.basePath || '',
scheme: (document.schemes || ["http"])[0],
host: document.host || ''
}
}
const endpoints = parseEndpoints(document);
return [
workspace,
baseEnv,
swaggerEnv,
...endpoints
];
};
/**
* Parse string data into swagger 2.0 object (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object)
*
* @param {string} rawData
*
* @returns {Object|null} Swagger 2.0 object
*/
async function parseDocument(rawData) {
try {
const parser = new SwaggerParser();
const document = unthrowableParseJson(rawData) || SwaggerParser.YAML.parse(rawData);
if(!document) {
return null;
}
const dereferenced = await parser.validate(document);
return dereferenced;
} catch (err) {
return null;
}
function unthrowableParseJson(rawData) {
try {
return JSON.parse(rawData)
} catch(err) {
return null;
}
}
}
/**
* Create request definitions based on swagger document.
*
* @param {Object} document - Swagger 2.0 valid object (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object)
*
* @returns {Object[]} array of insomnia endpoints definitions
*/
function parseEndpoints(document) {
const defaultParent = WORKSPACE_ID;
const globalMimeTypes = document.consumes;
const paths = Object.keys(document.paths);
const endpointsSchemas = paths.map(path => {
const schemasPerMethod = document.paths[path];
const methods = Object.keys(schemasPerMethod);
return methods.map(method => {
return {
...schemasPerMethod[method],
path,
method
}
})
}).reduce((flat, arr) => flat.concat(arr), []); //flat single array
return endpointsSchemas.map((endpointSchema, index) => {
let { path, method, operationId: _id, summary } = endpointSchema;
const name = summary || `${method} ${path}`;
return {
_type: 'request',
_id: endpointSchema.operationId || `__REQUEST_${index}__`,
parentId: defaultParent,
name,
method: method.toUpperCase(),
url: '{{ base_url }}' + pathWithParamsAsVariables(path),
body: prepareBody(endpointSchema, globalMimeTypes),
headers: prepareHeaders(endpointSchema),
parameters: prepareQueryParams(endpointSchema)
}
});
}
/**
* Return path with parameters replaced by insomnia variables
*
* I.e. "/foo/:bar" => "/foo/{{ bar }}"
*
* @param {string} path
* @returns {string}
*/
function pathWithParamsAsVariables(path) {
return path.replace(/{(.+)}/, '{{ $1 }}');
}
/**
* Imports insomnia definitions of query parameters.
*
* @param {Object} endpointSchema - swagger 2.0 endpoint schema
* @returns {Object[]} array of parameters definitions
*/
function prepareQueryParams(endpointSchema) {
const isSendInQuery = p => p.in === 'query';
const parameters = endpointSchema.parameters || [];
const queryParameters = parameters.filter(isSendInQuery);
return convertParameters(queryParameters);
}
/**
* Imports insomnia definitions of header parameters.
*
* @param {Object} endpointSchema - swagger 2.0 endpoint schema
* @returns {Object[]} array of parameters definitions
*/
function prepareHeaders(endpointSchema) {
const isSendInHeader = p => p.in === 'header';
const parameters = endpointSchema.parameters || [];
const headerParameters = parameters.filter(isSendInHeader);
return convertParameters(headerParameters);
}
/**
* Imports insomnia request body definitions, including data mock (if available)
*
* If multiple types are available, the one for which an example can be generated will be selected first (i.e. application/json)
*
* @param {Object} endpointSchema - swagger 2.0 endpoint schema
* @param {string[]} globalMimeTypes - list of mimeTypes available in document globally (i.e. document.consumes)
*
* @return {Object} insomnia request's body definition
*/
function prepareBody(endpointSchema, globalMimeTypes) {
const mimeTypes = endpointSchema.consumes || globalMimeTypes || [];
const isAvailable = m => mimeTypes.includes(m);
const supportedMimeType = SUPPORTED_MIME_TYPES.find(isAvailable);
if(supportedMimeType === MIMETYPE_JSON) {
const isSendInBody = p => p.in === 'body';
const parameters = endpointSchema.parameters || [];
const bodyParameter = parameters.find(isSendInBody);
if(!bodyParameter) {
return {
mimeType: supportedMimeType
}
}
const example = (bodyParameter) ? generateParameterExample(bodyParameter.schema) : undefined;
const text = JSON.stringify(example, null, 2);
return {
mimeType: supportedMimeType,
text
}
}
return {
mimeType: mimeTypes[0] || undefined
};
}
/**
* Converts swagger schema of parametes into insomnia one.
*
* @param {Object[]} parameters - array of swagger schemas of parameters
* @returns {Object[]} array of insomnia parameters definitions
*/
function convertParameters(parameters) {
return parameters.map(parameter => {
const { required, name } = parameter;
return {
name,
disabled: required !== true,
value: generateParameterExample(parameter)
}
})
}
/**
* Generate example value of parameter based on it's schema.
* Returns example / default value of the parameter, if any of those are defined. If not, returns value based on parameter type.
*
* @param {string|Object} schema - Swagger 2.0 parameter definition object
* (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parametersDefinitionsObject) or string with valid parameter type
*
* @returns {*}
*/
function generateParameterExample(schema) {
const typeExamples = {
'string': () => 'string',
'string_email': () => 'user@example.com',
'string_date-time': () => new Date().toISOString(),
'string_byte': () => 'ZXhhbXBsZQ==',
'number': () => 0,
'number_float': () => 0.0,
'number_double': () => 0.0,
'integer': () => 0,
'boolean': () => true,
'object': (schema) => {
const example = {};
const { properties } = schema;
Object.keys(properties).forEach(propertyName => {
example[propertyName] = generateParameterExample(properties[propertyName]);
});
return example;
},
'array': (schema) => {
return [ generateParameterExample(schema.items) ]
}
}
if(typeof schema === 'string') {
return typeExamples[schema];
}
if (schema instanceof Object) {
const { type, format, example, default: defaultValue } = schema;
if (example) {
return example;
}
if (defaultValue) {
return defaultValue;
}
const factory = typeExamples[`${type}_${format}`] || typeExamples[type];
return factory(schema);
}
}