From c3b297cb4a85cf0028bdcc98c13c8ad2459e20f0 Mon Sep 17 00:00:00 2001 From: Jorge Date: Sat, 12 Sep 2020 18:27:36 +0200 Subject: [PATCH 1/4] ci: added autorelease steps Closes #71 --- .github/workflows/node.js.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 8971968..b5ce424 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -40,4 +40,24 @@ jobs: - run: npm install - run: npm publish --access public env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Generate changelog + id: changelog + uses: metcalfc/changelog-generator@v0.4.3 + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@master + - name: Create Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.package-version.outputs.current-version }} + release_name: Release ${{ steps.package-version.outputs.current-version }} + body: | + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false \ No newline at end of file From 1d9da470d428b3053761464b7965b294c833e70b Mon Sep 17 00:00:00 2001 From: Jorge Date: Thu, 1 Oct 2020 17:01:14 +0200 Subject: [PATCH 2/4] feat: support postman collection v2 Close #20 --- lib/index.js | 18 +- test/index.spec.js | 353 +++++++++--------- test/resources/input/v2/AuthBasic.json | 101 +++++ test/resources/input/v2/AuthBearer.json | 100 +++++ test/resources/input/v2/DeleteOperation.json | 50 +++ test/resources/input/v2/DepthPathParams.json | 63 ++++ test/resources/input/v2/FolderCollection.json | 150 ++++++++ test/resources/input/v2/GetMethods.json | 80 ++++ test/resources/input/v2/Headers.json | 127 +++++++ test/resources/input/v2/LicenseContact.json | 102 +++++ test/resources/input/v2/MultipleServers.json | 115 ++++++ test/resources/input/v2/NoPath.json | 77 ++++ test/resources/input/v2/NoVersion.json | 30 ++ test/resources/input/v2/ParseStatusCode.json | 138 +++++++ test/resources/input/v2/PathParams.json | 63 ++++ test/resources/input/v2/PostmantoOpenAPI.json | 96 +++++ test/resources/input/v2/SimplePost.json | 37 ++ test/resources/input/{ => v21}/AuthBasic.json | 0 .../resources/input/{ => v21}/AuthBearer.json | 0 .../input/{ => v21}/DeleteOperation.json | 0 .../input/{ => v21}/DepthPathParams.json | 0 .../input/{ => v21}/FolderCollection.json | 0 .../resources/input/{ => v21}/GetMethods.json | 0 test/resources/input/{ => v21}/Headers.json | 0 .../input/{ => v21}/LicenseContact.json | 0 .../input/{ => v21}/MultipleServers.json | 0 test/resources/input/{ => v21}/NoPath.json | 0 test/resources/input/{ => v21}/NoVersion.json | 0 .../input/{ => v21}/ParseStatusCode.json | 0 .../resources/input/{ => v21}/PathParams.json | 0 .../input/{ => v21}/PostmantoOpenAPI.json | 0 .../resources/input/{ => v21}/SimplePost.json | 0 32 files changed, 1526 insertions(+), 174 deletions(-) create mode 100644 test/resources/input/v2/AuthBasic.json create mode 100644 test/resources/input/v2/AuthBearer.json create mode 100644 test/resources/input/v2/DeleteOperation.json create mode 100644 test/resources/input/v2/DepthPathParams.json create mode 100644 test/resources/input/v2/FolderCollection.json create mode 100644 test/resources/input/v2/GetMethods.json create mode 100644 test/resources/input/v2/Headers.json create mode 100644 test/resources/input/v2/LicenseContact.json create mode 100644 test/resources/input/v2/MultipleServers.json create mode 100644 test/resources/input/v2/NoPath.json create mode 100644 test/resources/input/v2/NoVersion.json create mode 100644 test/resources/input/v2/ParseStatusCode.json create mode 100644 test/resources/input/v2/PathParams.json create mode 100644 test/resources/input/v2/PostmantoOpenAPI.json create mode 100644 test/resources/input/v2/SimplePost.json rename test/resources/input/{ => v21}/AuthBasic.json (100%) rename test/resources/input/{ => v21}/AuthBearer.json (100%) rename test/resources/input/{ => v21}/DeleteOperation.json (100%) rename test/resources/input/{ => v21}/DepthPathParams.json (100%) rename test/resources/input/{ => v21}/FolderCollection.json (100%) rename test/resources/input/{ => v21}/GetMethods.json (100%) rename test/resources/input/{ => v21}/Headers.json (100%) rename test/resources/input/{ => v21}/LicenseContact.json (100%) rename test/resources/input/{ => v21}/MultipleServers.json (100%) rename test/resources/input/{ => v21}/NoPath.json (100%) rename test/resources/input/{ => v21}/NoVersion.json (100%) rename test/resources/input/{ => v21}/ParseStatusCode.json (100%) rename test/resources/input/{ => v21}/PathParams.json (100%) rename test/resources/input/{ => v21}/PostmantoOpenAPI.json (100%) rename test/resources/input/{ => v21}/SimplePost.json (100%) diff --git a/lib/index.js b/lib/index.js index 960524b..fe8cb18 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,9 +22,10 @@ async function postmanToOpenApi (input, output, { info = {}, defaultTag = 'defau element = tagged.shift() } const { - request: { url: { path, query, protocol, host }, method, body, description: rawDesc, header }, + request: { url, method, body, description: rawDesc, header }, name: summary, tag = defaultTag, event: events } = element + const { path, query, protocol, host } = scrapeURL(url) domains.add(calculateDomains(protocol, host)) const joinedPath = calculatePath(path, pathDepth) if (!paths[joinedPath]) paths[joinedPath] = {} @@ -250,6 +251,21 @@ function calculateDomains (protocol, hosts) { return protocol + '://' + hosts.join('.') } +/** Support for collection V2 */ +function scrapeURL (url) { + if (typeof url === 'string' || url instanceof String) { + const objUrl = new URL(url) + return { + raw: url, + path: decodeURIComponent(objUrl.pathname).slice(1).split('/'), + query: [], + protocol: objUrl.protocol.slice(0, -1), + host: decodeURIComponent(objUrl.hostname).split('.') + } + } + return url +} + /* Parse domains from operations or options */ function parseServers (domains, serversOpts) { let servers diff --git a/test/index.spec.js b/test/index.spec.js index 51b0283..9e3a5c6 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -8,22 +8,7 @@ const { readFileSync, existsSync, unlinkSync } = require('fs') const OUTPUT_PATH = path.join(__dirname, '/openAPIRes.yml') -const COLLECTION_BASIC = './test/resources/input/PostmantoOpenAPI.json' -const COLLECTION_SIMPLE = './test/resources/input/SimplePost.json' -const COLLECTION_NO_VERSION = './test/resources/input/NoVersion.json' -const COLLECTION_FOLDERS = './test/resources/input/FolderCollection.json' -const COLLECTION_GET = './test/resources/input/GetMethods.json' -const COLLECTION_HEADERS = './test/resources/input/Headers.json' -const COLLECTION_AUTH_BEARER = './test/resources/input/AuthBearer.json' -const COLLECTION_AUTH_BASIC = './test/resources/input/AuthBasic.json' -const COLLECTION_PATH_PARAMS = './test/resources/input/PathParams.json' -const COLLECTION_MULTIPLE_SERVERS = './test/resources/input/MultipleServers.json' -const COLLECTION_LICENSE_CONTACT = './test/resources/input/LicenseContact.json' -const COLLECTION_DEPTH_PATH_PARAMS = './test/resources/input/DepthPathParams.json' -const COLLECTION_PARSE_STATUS_CODE = './test/resources/input/ParseStatusCode.json' -const COLLECTION_NO_PATH = './test/resources/input/NoPath.json' const COLLECTION_NO_OPTIONS = './test/resources/input/NoOptionsInBody.json' -const COLLECTION_DELETE = './test/resources/input/DeleteOperation.json' const EXPECTED_BASIC = readFileSync('./test/resources/output/Basic.yml', 'utf8') const EXPECTED_INFO_OPTS = readFileSync('./test/resources/output/InfoOpts.yml', 'utf8') @@ -55,192 +40,214 @@ describe('Library specs', function () { } }) - it('should work with a basic transform', async function () { - const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, {}) - equal(result, EXPECTED_BASIC) - ok(existsSync(OUTPUT_PATH)) - }) + const TEST_VERSIONS = ['v2', 'v21'] + + TEST_VERSIONS.forEach(function (version) { + describe(`Postman Collection ${version}`, function () { + const COLLECTION_BASIC = `./test/resources/input/${version}/PostmantoOpenAPI.json` + const COLLECTION_SIMPLE = `./test/resources/input/${version}/SimplePost.json` + const COLLECTION_NO_VERSION = `./test/resources/input/${version}/NoVersion.json` + const COLLECTION_FOLDERS = `./test/resources/input/${version}/FolderCollection.json` + const COLLECTION_GET = `./test/resources/input/${version}/GetMethods.json` + const COLLECTION_HEADERS = `./test/resources/input/${version}/Headers.json` + const COLLECTION_PATH_PARAMS = `./test/resources/input/${version}/PathParams.json` + const COLLECTION_MULTIPLE_SERVERS = `./test/resources/input/${version}/MultipleServers.json` + const COLLECTION_LICENSE_CONTACT = `./test/resources/input/${version}/LicenseContact.json` + const COLLECTION_DEPTH_PATH_PARAMS = `./test/resources/input/${version}/DepthPathParams.json` + const COLLECTION_PARSE_STATUS_CODE = `./test/resources/input/${version}/ParseStatusCode.json` + const COLLECTION_NO_PATH = `./test/resources/input/${version}/NoPath.json` + const COLLECTION_DELETE = `./test/resources/input/${version}/DeleteOperation.json` + const COLLECTION_AUTH_BEARER = `./test/resources/input/${version}/AuthBearer.json` + const COLLECTION_AUTH_BASIC = `./test/resources/input/${version}/AuthBasic.json` + + it('should work with a basic transform', async function () { + const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, {}) + equal(result, EXPECTED_BASIC) + ok(existsSync(OUTPUT_PATH)) + }) - it('should work when no save', async function () { - await postmanToOpenApi(COLLECTION_BASIC, null) - }) + it('should work when no save', async function () { + await postmanToOpenApi(COLLECTION_BASIC, null) + }) - it('should work if info is passed as parameter', async function () { - const result = await postmanToOpenApi(COLLECTION_SIMPLE, OUTPUT_PATH, { - info: { - title: 'Options title', - version: '6.0.7-beta', - description: 'Description from options', - termsOfService: 'http://tos.myweb.com' - } - }) - equal(result, EXPECTED_INFO_OPTS) - }) + it('should work if info is passed as parameter', async function () { + const result = await postmanToOpenApi(COLLECTION_SIMPLE, OUTPUT_PATH, { + info: { + title: 'Options title', + version: '6.0.7-beta', + description: 'Description from options', + termsOfService: 'http://tos.myweb.com' + } + }) + equal(result, EXPECTED_INFO_OPTS) + }) - it('should use default version if not informed and not in postman variables', async function () { - const result = await postmanToOpenApi(COLLECTION_NO_VERSION, OUTPUT_PATH, {}) - equal(result, EXPECTED_NO_VERSION) - }) + it('should use "defaultTag" provided by config', async function () { + const result = await postmanToOpenApi(COLLECTION_SIMPLE, OUTPUT_PATH, { defaultTag: 'Custom Tag' }) + equal(result, EXPECTED_CUSTOM_TAG) + }) - it('should use "defaultTag" provided by config', async function () { - const result = await postmanToOpenApi(COLLECTION_SIMPLE, OUTPUT_PATH, { defaultTag: 'Custom Tag' }) - equal(result, EXPECTED_CUSTOM_TAG) - }) + it('should use default version if not informed and not in postman variables', async function () { + const result = await postmanToOpenApi(COLLECTION_NO_VERSION, OUTPUT_PATH, {}) + equal(result, EXPECTED_NO_VERSION) + }) - it('should work with folders and use as tags', async function () { - const result = await postmanToOpenApi(COLLECTION_FOLDERS, OUTPUT_PATH) - equal(result, EXPECTED_FOLDERS) - }) + it('should work with folders and use as tags', async function () { + const result = await postmanToOpenApi(COLLECTION_FOLDERS, OUTPUT_PATH) + equal(result, EXPECTED_FOLDERS) + }) - it('should parse GET methods with query string', async function () { - const result = await postmanToOpenApi(COLLECTION_GET, OUTPUT_PATH) - equal(result, EXPECTED_GET_METHODS) - }) + it('should parse GET methods with query string', async function () { + const result = await postmanToOpenApi(COLLECTION_GET, OUTPUT_PATH) + equal(result, EXPECTED_GET_METHODS) + }) - it('should parse HEADERS parameters', async function () { - const result = await postmanToOpenApi(COLLECTION_HEADERS, OUTPUT_PATH) - equal(result, EXPECTED_HEADERS) - }) + it('should parse HEADERS parameters', async function () { + const result = await postmanToOpenApi(COLLECTION_HEADERS, OUTPUT_PATH) + equal(result, EXPECTED_HEADERS) + }) - it('should parse global authorization (Bearer)', async function () { - const result = await postmanToOpenApi(COLLECTION_AUTH_BEARER, OUTPUT_PATH) - equal(result, EXPECTED_AUTH_BEARER) - }) + it('should parse path params', async function () { + const result = await postmanToOpenApi(COLLECTION_PATH_PARAMS, OUTPUT_PATH) + equal(result, EXPECTED_PATH_PARAMS) + }) - it('should parse global authorization (Basic)', async function () { - const result = await postmanToOpenApi(COLLECTION_AUTH_BASIC, OUTPUT_PATH) - equal(result, EXPECTED_AUTH_BASIC) - }) + it('should parse servers from existing host in postman collection', async function () { + const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH) + equal(result, EXPECTED_MULTIPLE_SERVERS) + }) - it('should use global authorization by configuration', async function () { - const authDefinition = { - myCustomAuth: { - type: 'http', - scheme: 'bearer', - bearerFormat: 'A resource owner JWT', - description: 'My awesome authentication using bearer' - }, - myCustomAuth2: { - type: 'http', - scheme: 'basic', - description: 'My awesome authentication using user and password' - }, - notSupported: { - type: 'http', - scheme: 'digest', - description: 'Not supported security' - } - } - const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, { auth: authDefinition }) - equal(result, EXPECTED_BASIC_WITH_AUTH) - }) + it('should use servers from options', async function () { + const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH, { + servers: [ + { + url: 'https://awesome.api.sandbox.io', + description: 'Sandbox environment server' + }, + { + url: 'https://awesome.api.io', + description: 'Production env' + } + ] + }) + equal(result, EXPECTED_SERVERS_OPTIONS) + }) - it('should parse path params', async function () { - const result = await postmanToOpenApi(COLLECTION_PATH_PARAMS, OUTPUT_PATH) - equal(result, EXPECTED_PATH_PARAMS) - }) + it('should allow empty servers from options', async function () { + const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH, { servers: [] }) + equal(result, EXPECTED_NO_SERVERS) + }) - it('should parse servers from existing host in postman collection', async function () { - const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH) - equal(result, EXPECTED_MULTIPLE_SERVERS) - }) + it('should parse license and contact from variables', async function () { + const result = await postmanToOpenApi(COLLECTION_LICENSE_CONTACT, OUTPUT_PATH) + equal(result, EXPECTED_LICENSE_CONTACT) + }) - it('should use servers from options', async function () { - const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH, { - servers: [ - { - url: 'https://awesome.api.sandbox.io', - description: 'Sandbox environment server' - }, - { - url: 'https://awesome.api.io', - description: 'Production env' - } - ] - }) - equal(result, EXPECTED_SERVERS_OPTIONS) - }) + it('should use license and contact from options', async function () { + const result = await postmanToOpenApi(COLLECTION_LICENSE_CONTACT, OUTPUT_PATH, + { + info: { + license: { + name: 'MIT', + url: 'https://es.wikipedia.org/wiki/Licencia_MIT' + }, + contact: { + name: 'My Support', + url: 'http://www.api.com/support', + email: 'support@api.com' + } + } + }) + equal(result, EXPECTED_LICENSE_CONTACT_OPT) + }) - it('should allow empty servers from options', async function () { - const result = await postmanToOpenApi(COLLECTION_MULTIPLE_SERVERS, OUTPUT_PATH, { servers: [] }) - equal(result, EXPECTED_NO_SERVERS) - }) + it('should support optional params in license and contact options', async function () { + const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, + { + info: { + license: { + name: 'MIT' + }, + contact: { + name: 'My Support' + } + } + }) + equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL) + }) - it('should parse license and contact from variables', async function () { - const result = await postmanToOpenApi(COLLECTION_LICENSE_CONTACT, OUTPUT_PATH) - equal(result, EXPECTED_LICENSE_CONTACT) - }) + it('should support optional params in license and contact options (2)', async function () { + const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, + { + info: { + license: { + name: 'MIT' + }, + contact: { + url: 'http://www.api.com/support' + } + } + }) + equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL_2) + }) - it('should use license and contact from options', async function () { - const result = await postmanToOpenApi(COLLECTION_LICENSE_CONTACT, OUTPUT_PATH, - { - info: { - license: { - name: 'MIT', - url: 'https://es.wikipedia.org/wiki/Licencia_MIT' - }, - contact: { - name: 'My Support', - url: 'http://www.api.com/support', - email: 'support@api.com' - } - } + it('should use depth configuration for parse paths', async function () { + const result = await postmanToOpenApi(COLLECTION_DEPTH_PATH_PARAMS, OUTPUT_PATH, { pathDepth: 1 }) + equal(result, EXPECTED_DEPTH_PATH_PARAMS) }) - equal(result, EXPECTED_LICENSE_CONTACT_OPT) - }) - it('should support optional params in license and contact options', async function () { - const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, - { - info: { - license: { - name: 'MIT' - }, - contact: { - name: 'My Support' - } - } + it('should parse status codes from test', async function () { + const result = await postmanToOpenApi(COLLECTION_PARSE_STATUS_CODE) + equal(result, EXPECTED_PARSE_STATUS_CODE) }) - equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL) - }) - it('should support optional params in license and contact options (2)', async function () { - const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, - { - info: { - license: { - name: 'MIT' - }, - contact: { - url: 'http://www.api.com/support' - } - } + it('should parse operation when no path (only domain)', async function () { + const result = await postmanToOpenApi(COLLECTION_NO_PATH) + equal(result, EXPECTED_NO_PATH) }) - equal(result, EXPECTED_LICENSE_CONTACT_PARTIAL_2) - }) - it('should use depth configuration for parse paths', async function () { - const result = await postmanToOpenApi(COLLECTION_DEPTH_PATH_PARAMS, OUTPUT_PATH, { pathDepth: 1 }) - equal(result, EXPECTED_DEPTH_PATH_PARAMS) - }) + it('should support "DELETE" operations', async function () { + const result = await postmanToOpenApi(COLLECTION_DELETE) + equal(result, EXPECTED_DELETE) + }) - it('should parse status codes from test', async function () { - const result = await postmanToOpenApi(COLLECTION_PARSE_STATUS_CODE) - equal(result, EXPECTED_PARSE_STATUS_CODE) - }) + it('should parse global authorization (Bearer)', async function () { + const result = await postmanToOpenApi(COLLECTION_AUTH_BEARER, OUTPUT_PATH) + equal(result, EXPECTED_AUTH_BEARER) + }) + + it('should parse global authorization (Basic)', async function () { + const result = await postmanToOpenApi(COLLECTION_AUTH_BASIC, OUTPUT_PATH) + equal(result, EXPECTED_AUTH_BASIC) + }) - it('should parse operation when no path (only domain)', async function () { - const result = await postmanToOpenApi(COLLECTION_NO_PATH) - equal(result, EXPECTED_NO_PATH) + it('should use global authorization by configuration', async function () { + const authDefinition = { + myCustomAuth: { + type: 'http', + scheme: 'bearer', + bearerFormat: 'A resource owner JWT', + description: 'My awesome authentication using bearer' + }, + myCustomAuth2: { + type: 'http', + scheme: 'basic', + description: 'My awesome authentication using user and password' + }, + notSupported: { + type: 'http', + scheme: 'digest', + description: 'Not supported security' + } + } + const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, { auth: authDefinition }) + equal(result, EXPECTED_BASIC_WITH_AUTH) + }) + }) }) it('should work if no options in request body', async function () { const result = await postmanToOpenApi(COLLECTION_NO_OPTIONS, OUTPUT_PATH, {}) equal(result, EXPECTED_BASIC) }) - - it('should support "DELETE" operations', async function () { - const result = await postmanToOpenApi(COLLECTION_DELETE) - equal(result, EXPECTED_DELETE) - }) }) diff --git a/test/resources/input/v2/AuthBasic.json b/test/resources/input/v2/AuthBasic.json new file mode 100644 index 0000000..550d7b8 --- /dev/null +++ b/test/resources/input/v2/AuthBasic.json @@ -0,0 +1,101 @@ +{ + "info": { + "_postman_id": "0f93eca8-921e-4b0d-9ac0-15f96a56eae8", + "name": "AuthBasic", + "description": "Collection to test authorization global", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User Copy", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + }, + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "users" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age" + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + }, + { + "key": "number", + "value": "23.56", + "description": "This is a number" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + } + ], + "auth": { + "type": "basic", + "basic": { + "password": "ssss", + "username": "sss" + } + }, + "event": [ + { + "listen": "prerequest", + "script": { + "id": "7b3e1a28-e253-4cd9-ac26-2d9d52092d80", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "b50e4ce3-8104-4eb7-bc20-50e6f3f5edab", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/AuthBearer.json b/test/resources/input/v2/AuthBearer.json new file mode 100644 index 0000000..31c5b1c --- /dev/null +++ b/test/resources/input/v2/AuthBearer.json @@ -0,0 +1,100 @@ +{ + "info": { + "_postman_id": "a6565bc1-2576-4f58-ab80-e18d3ed8ae9d", + "name": "AuthBearer", + "description": "Collection to test authorization global", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User Copy", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + }, + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "users" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age" + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + }, + { + "key": "number", + "value": "23.56", + "description": "This is a number" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + } + ], + "auth": { + "type": "bearer", + "bearer": { + "token": "YUIHUILOIJOJOJ" + } + }, + "event": [ + { + "listen": "prerequest", + "script": { + "id": "4a789393-4d04-4d39-96dc-ac6b8c0f6215", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "8f0b6648-0701-4ba3-b799-5683e33b6213", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/DeleteOperation.json b/test/resources/input/v2/DeleteOperation.json new file mode 100644 index 0000000..9c18634 --- /dev/null +++ b/test/resources/input/v2/DeleteOperation.json @@ -0,0 +1,50 @@ +{ + "info": { + "_postman_id": "467fe1f5-3fed-4005-bb02-fe6ddfa2c571", + "name": "Delete Operation", + "description": "Mi super test collection from postman", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Delete all users", + "request": { + "method": "DELETE", + "header": [], + "url": "https://api.io/users", + "description": "Delete all the existing users" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "4dd38097-bafe-459e-8d88-7e8880c07d61", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "cc58acea-2ade-42ce-b0fc-f96fd37b899b", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "b8ff9254-81e3-432f-9e5a-aea92cf34d7c", + "key": "version", + "value": "1.1.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/DepthPathParams.json b/test/resources/input/v2/DepthPathParams.json new file mode 100644 index 0000000..845b100 --- /dev/null +++ b/test/resources/input/v2/DepthPathParams.json @@ -0,0 +1,63 @@ +{ + "info": { + "_postman_id": "867a6cc8-590e-4892-a56f-e6467650762d", + "name": "Large Path Params", + "description": "Collection to test path parameters", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get one users info", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/dev/users/{{user_id}}", + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + }, + { + "name": "Get descriptions of a user", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/dev/user/{{user_id}}/desc/", + "description": "Obtain a list of users descriptions\n\n# postman-to-openapi\n\n| object | name | description | required | type | example |\n|--------|----------|--------------------------------|----------|--------|-----------|\n| path | user_id | This is just a user identifier | true | number | 476587598 |" + }, + "response": [] + }, + { + "name": "Get a description from an user", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/dev/user/{{user_id}}/desc/{{desc_id}}", + "description": "Obtain a list of users descriptions\n\n# postman-to-openapi\n\n| object | name | description | required | type | example |\n|--------|----------|--------------------------------|----------|--------|-----------|\n| path | user_id | This is just a user identifier | true | number | 476587598 |\n| path | desc_id | Description id | true | string | ALMT |" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "48730090-58d7-4d00-8370-1507a00e5dce", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "c769d644-4ade-4e62-bb4a-809590be46ee", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/FolderCollection.json b/test/resources/input/v2/FolderCollection.json new file mode 100644 index 0000000..e4334e5 --- /dev/null +++ b/test/resources/input/v2/FolderCollection.json @@ -0,0 +1,150 @@ +{ + "info": { + "_postman_id": "d56d78d2-cf20-4779-ad84-d9e578ab9d5a", + "name": "Folder Collection", + "description": "Just a simple collection for test", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Users", + "item": [ + { + "name": "Create a user", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "This is a post request with json body" + }, + "response": [] + }, + { + "name": "Create a customer", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/customer", + "description": "This is a post request with json body for create a customer" + }, + "response": [] + } + ], + "description": "Operations at User level", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "686448f3-5f27-4ab0-be72-f5751d40d587", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "be665e36-6d0b-402d-9577-03aa4601d721", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "Posts", + "item": [ + { + "name": "Create a post", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "file", + "file": {}, + "options": { + "raw": { + "language": "text" + } + } + }, + "url": "https://api.io/posts" + }, + "response": [] + } + ], + "description": "Operations for Post items", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "090c5815-9bf7-42ad-aee7-4e0b6949064e", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "b57c9340-3e13-4e3a-8a20-38cd0ee3c4b4", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "Create a info", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"test\":\"here\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/info" + }, + "response": [] + } + ], + "variable": [ + { + "id": "e4619cfa-c046-413a-9e69-f40a20248a4d", + "key": "version", + "value": "2.3.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/GetMethods.json b/test/resources/input/v2/GetMethods.json new file mode 100644 index 0000000..a1ab7c8 --- /dev/null +++ b/test/resources/input/v2/GetMethods.json @@ -0,0 +1,80 @@ +{ + "info": { + "_postman_id": "284c15b0-304f-4875-9f36-7a3cf96fca64", + "name": "Get Methods", + "description": "API to manage GET methods", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56&required=my value", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "users" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age [required]" + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name [REQUIRED]" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + }, + { + "key": "number", + "value": "23.56", + "description": "This is a number" + }, + { + "key": "required", + "value": "my value", + "description": "[required] mandatory paraemeter" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "48a08854-1364-4bf5-8c52-2987ae771f81", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "9414d1c7-923e-4370-8b43-adb8415092c7", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/Headers.json b/test/resources/input/v2/Headers.json new file mode 100644 index 0000000..39c4292 --- /dev/null +++ b/test/resources/input/v2/Headers.json @@ -0,0 +1,127 @@ +{ + "info": { + "_postman_id": "4ae5252b-8f18-4a03-a4e6-41dac2480a78", + "name": "Headers", + "description": "API with headers", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [ + { + "key": "X-My-Header", + "value": "hudjilksns78jsijns090", + "description": "Custom header [required]", + "type": "text" + }, + { + "key": "X-Other", + "value": "other", + "description": "Another header [REQUIRED]", + "type": "text" + }, + { + "key": "No-description", + "value": "header without description", + "type": "text" + }, + { + "key": "No-value", + "value": "", + "description": "header without value", + "type": "text" + } + ], + "url": { + "raw": "https://api.io/users?name=Jhon&review=true", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "users" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age", + "disabled": true + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + }, + { + "name": "Create new User", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "Indicate the type of body sent by client", + "type": "text" + }, + { + "key": "X-My-Header", + "value": "hudjilksns78jsijns090", + "description": "Custom header", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "b20368dc-8b15-4c5f-826f-4e91bb287d09", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "46cbfa9e-e283-4d4f-8915-4d13a958d2e9", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/LicenseContact.json b/test/resources/input/v2/LicenseContact.json new file mode 100644 index 0000000..3d24307 --- /dev/null +++ b/test/resources/input/v2/LicenseContact.json @@ -0,0 +1,102 @@ +{ + "info": { + "_postman_id": "cb2ca622-ddc3-4f90-a7c1-342f5f13a721", + "name": "License and Contact", + "description": "Collection to test license as variable", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://api.io/users?age=45&name=Jhon&review=true&number=23.56", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "users" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age" + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + }, + { + "key": "number", + "value": "23.56", + "description": "This is a number" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "19996b55-b646-45d4-b168-a1042a110053", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "1f32ddda-e7de-4453-9fd7-53ba18a5c058", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "b573c8e4-6a13-4d0e-8c3b-19536462f36c", + "key": "license.name", + "value": "Apache 2.0" + }, + { + "id": "b1aecf73-5ff1-4cea-b447-80fe28da62c1", + "key": "license.url", + "value": "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + { + "id": "35641083-7bd6-4c98-b2a8-4b45da0cdeb9", + "key": "contact.name", + "value": "API Support" + }, + { + "id": "7762d7a2-78f9-46eb-bf99-2a9519f35a79", + "key": "contact.url", + "value": "http://www.example.com/support" + }, + { + "id": "77c31f06-45ae-40ef-9734-1b03b7bd21fc", + "key": "contact.email", + "value": "support@example.com" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/MultipleServers.json b/test/resources/input/v2/MultipleServers.json new file mode 100644 index 0000000..1bd3e95 --- /dev/null +++ b/test/resources/input/v2/MultipleServers.json @@ -0,0 +1,115 @@ +{ + "info": { + "_postman_id": "e2b55c45-a50d-4421-a575-e8e863b8f4d6", + "name": "MultipleServers", + "description": "Collection to test multiples server parsing.", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + }, + { + "name": "Create a post", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "file", + "file": {}, + "options": { + "raw": { + "language": "text" + } + } + }, + "url": "https://api.dev.io/posts" + }, + "response": [] + }, + { + "name": "Create a note", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "This is an example Note", + "options": { + "raw": { + "language": "text" + } + } + }, + "url": "https://api.pre.io/note", + "description": "Just an example of text raw body" + }, + "response": [] + }, + { + "name": "Update User", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Update an existing user" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "54be283a-e8f1-42b9-82ab-8904e9e38d8a", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "3e532569-4da0-4ed4-90cc-46b53421c532", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "600f8632-5dfe-418b-83cd-f00302a437c0", + "key": "version", + "value": "1.1.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/NoPath.json b/test/resources/input/v2/NoPath.json new file mode 100644 index 0000000..63f31aa --- /dev/null +++ b/test/resources/input/v2/NoPath.json @@ -0,0 +1,77 @@ +{ + "info": { + "_postman_id": "070cfcaa-7648-440a-9496-b6d1a7165e71", + "name": "No Path", + "description": "API to manage GET methods", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get list of users", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "https://api.io?age=45&name=Jhon&review=true&number=23.56&required=my value", + "protocol": "https", + "host": [ + "api", + "io" + ], + "query": [ + { + "key": "age", + "value": "45", + "description": "Filter by age [required]" + }, + { + "key": "name", + "value": "Jhon", + "description": "Filter by name [REQUIRED]" + }, + { + "key": "review", + "value": "true", + "description": "Indicate if should be reviewed or not" + }, + { + "key": "number", + "value": "23.56", + "description": "This is a number" + }, + { + "key": "required", + "value": "my value", + "description": "[required] mandatory paraemeter" + } + ] + }, + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "e24b3815-bc32-4604-84d7-809318923959", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "dc987fcc-80bc-4750-a13e-60cbd2b47eb1", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/NoVersion.json b/test/resources/input/v2/NoVersion.json new file mode 100644 index 0000000..e9ed4a9 --- /dev/null +++ b/test/resources/input/v2/NoVersion.json @@ -0,0 +1,30 @@ +{ + "info": { + "_postman_id": "75f8c310-4c27-4fab-821a-7b9363596eed", + "name": "No Version Collection", + "description": "This collection don't have a version as variable", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/ParseStatusCode.json b/test/resources/input/v2/ParseStatusCode.json new file mode 100644 index 0000000..5b83a04 --- /dev/null +++ b/test/resources/input/v2/ParseStatusCode.json @@ -0,0 +1,138 @@ +{ + "info": { + "_postman_id": "f0db4461-05ee-463f-a7af-61ed39da58ff", + "name": "Parse Status Code", + "description": "Just a simple collection for test status parsing", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User 201", + "event": [ + { + "listen": "test", + "script": { + "id": "790546f2-92a8-4e75-9536-36880aa179ef", + "exec": [ + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Example of a 201 response" + }, + "response": [] + }, + { + "name": "Create new User 202", + "event": [ + { + "listen": "test", + "script": { + "id": "062589ef-895e-4431-ab69-16bab8c53e04", + "exec": [ + "pm.test(\"Status code is 202\", () => {", + " pm.expect(pm.response.code).to.eql(202);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users/active", + "description": "Example of a 202 response" + }, + "response": [] + }, + { + "name": "Deafult 200", + "event": [ + { + "listen": "test", + "script": { + "id": "91144f12-5169-4ed8-9712-567f0f1c2b78", + "exec": [ + "pm.expect(responseJson.type).to.eql('vip');", + "pm.expect(responseJson.name).to.be.a('string');" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users/group", + "description": "Example of a 202 response" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "062bfbaa-317a-4add-9b35-40d088da7f96", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "446420ef-660b-470c-b46b-3c15acc2dadb", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "7820b0cd-5643-4df8-881c-f172a6957730", + "key": "version", + "value": "2.3.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/PathParams.json b/test/resources/input/v2/PathParams.json new file mode 100644 index 0000000..a8202eb --- /dev/null +++ b/test/resources/input/v2/PathParams.json @@ -0,0 +1,63 @@ +{ + "info": { + "_postman_id": "996877f6-c686-4f69-a939-f93b08089232", + "name": "Path Params", + "description": "Collection to test path parameters", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Get one users info", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/users/{{user_id}}", + "description": "Obtain a list of users that fullfill the conditions of the filters" + }, + "response": [] + }, + { + "name": "Get one customer", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/customer/{{customer-id}}", + "description": "Obtain one customer info" + }, + "response": [] + }, + { + "name": "Get one users with description", + "request": { + "method": "GET", + "header": [], + "url": "https://api.io/desc/{{user_id}}", + "description": "Obtain a list of users descriptions\n\n# postman-to-openapi\n\n| object | name | description | required | type | example |\n|--------|----------|--------------------------------|----------|--------|-----------|\n| path | user_id | This is just a user identifier | true | number | 476587598 |\n| path | group_id | Group of the user | true | string | RETAIL |" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "ae27466c-2adf-427d-820c-a9f517387fec", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "3a6974eb-ea7f-4bf7-b7ee-1457db0d6be9", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/PostmantoOpenAPI.json b/test/resources/input/v2/PostmantoOpenAPI.json new file mode 100644 index 0000000..4f84ab2 --- /dev/null +++ b/test/resources/input/v2/PostmantoOpenAPI.json @@ -0,0 +1,96 @@ +{ + "info": { + "_postman_id": "eff74bc8-3567-4ce7-9052-e215f085cb12", + "name": "Postman to OpenAPI", + "description": "Mi super test collection from postman", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + }, + { + "name": "Create a post", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "file", + "file": {}, + "options": { + "raw": { + "language": "text" + } + } + }, + "url": "https://api.io/posts" + }, + "response": [] + }, + { + "name": "Create a note", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "This is an example Note", + "options": { + "raw": { + "language": "text" + } + } + }, + "url": "https://api.io/note", + "description": "Just an example of text raw body" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "58e69c41-03fc-46b0-b701-b07c71a1e9ea", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "344bfa97-abab-441b-97c7-aba4f2e0fe2d", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "d04439bd-c604-4758-bde2-3c873140f38c", + "key": "version", + "value": "1.1.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/v2/SimplePost.json b/test/resources/input/v2/SimplePost.json new file mode 100644 index 0000000..caa6c20 --- /dev/null +++ b/test/resources/input/v2/SimplePost.json @@ -0,0 +1,37 @@ +{ + "info": { + "_postman_id": "56e38043-4473-4faa-a735-1815ca79ee04", + "name": "Simple Post", + "description": "Just a simple collection for test", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Create new User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "https://api.io/users", + "description": "Create a new user into your amazing API" + }, + "response": [] + } + ], + "variable": [ + { + "id": "a1b68638-d65e-4ee8-9a91-4d5749e9c2f2", + "key": "version", + "value": "2.3.0" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/test/resources/input/AuthBasic.json b/test/resources/input/v21/AuthBasic.json similarity index 100% rename from test/resources/input/AuthBasic.json rename to test/resources/input/v21/AuthBasic.json diff --git a/test/resources/input/AuthBearer.json b/test/resources/input/v21/AuthBearer.json similarity index 100% rename from test/resources/input/AuthBearer.json rename to test/resources/input/v21/AuthBearer.json diff --git a/test/resources/input/DeleteOperation.json b/test/resources/input/v21/DeleteOperation.json similarity index 100% rename from test/resources/input/DeleteOperation.json rename to test/resources/input/v21/DeleteOperation.json diff --git a/test/resources/input/DepthPathParams.json b/test/resources/input/v21/DepthPathParams.json similarity index 100% rename from test/resources/input/DepthPathParams.json rename to test/resources/input/v21/DepthPathParams.json diff --git a/test/resources/input/FolderCollection.json b/test/resources/input/v21/FolderCollection.json similarity index 100% rename from test/resources/input/FolderCollection.json rename to test/resources/input/v21/FolderCollection.json diff --git a/test/resources/input/GetMethods.json b/test/resources/input/v21/GetMethods.json similarity index 100% rename from test/resources/input/GetMethods.json rename to test/resources/input/v21/GetMethods.json diff --git a/test/resources/input/Headers.json b/test/resources/input/v21/Headers.json similarity index 100% rename from test/resources/input/Headers.json rename to test/resources/input/v21/Headers.json diff --git a/test/resources/input/LicenseContact.json b/test/resources/input/v21/LicenseContact.json similarity index 100% rename from test/resources/input/LicenseContact.json rename to test/resources/input/v21/LicenseContact.json diff --git a/test/resources/input/MultipleServers.json b/test/resources/input/v21/MultipleServers.json similarity index 100% rename from test/resources/input/MultipleServers.json rename to test/resources/input/v21/MultipleServers.json diff --git a/test/resources/input/NoPath.json b/test/resources/input/v21/NoPath.json similarity index 100% rename from test/resources/input/NoPath.json rename to test/resources/input/v21/NoPath.json diff --git a/test/resources/input/NoVersion.json b/test/resources/input/v21/NoVersion.json similarity index 100% rename from test/resources/input/NoVersion.json rename to test/resources/input/v21/NoVersion.json diff --git a/test/resources/input/ParseStatusCode.json b/test/resources/input/v21/ParseStatusCode.json similarity index 100% rename from test/resources/input/ParseStatusCode.json rename to test/resources/input/v21/ParseStatusCode.json diff --git a/test/resources/input/PathParams.json b/test/resources/input/v21/PathParams.json similarity index 100% rename from test/resources/input/PathParams.json rename to test/resources/input/v21/PathParams.json diff --git a/test/resources/input/PostmantoOpenAPI.json b/test/resources/input/v21/PostmantoOpenAPI.json similarity index 100% rename from test/resources/input/PostmantoOpenAPI.json rename to test/resources/input/v21/PostmantoOpenAPI.json diff --git a/test/resources/input/SimplePost.json b/test/resources/input/v21/SimplePost.json similarity index 100% rename from test/resources/input/SimplePost.json rename to test/resources/input/v21/SimplePost.json From c3267a847327c371cc347f615de1e5bfd5ac55d2 Mon Sep 17 00:00:00 2001 From: Jorge Date: Thu, 1 Oct 2020 17:02:12 +0200 Subject: [PATCH 3/4] build: update version to 1.5.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec0e846..7846aa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "postman-to-openapi", - "version": "1.4.1", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5bb9f2f..b5e5c30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postman-to-openapi", - "version": "1.4.1", + "version": "1.5.0", "description": "Convert postman collection to OpenAPI spec", "main": "lib/index.js", "scripts": { From 38be7cb2dc6d88dfe67a2a553a3223949a82374b Mon Sep 17 00:00:00 2001 From: Jorge Date: Thu, 1 Oct 2020 17:15:27 +0200 Subject: [PATCH 4/4] docs: update CHANGELOG --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f739ca..4c9617f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## [1.5.0](https://github.com/joolfe/postman-to-openapi/compare/1.4.1...1.5.0) (2020-10-01) + + +### Features + +* support postman collection v2 ([1d9da47](https://github.com/joolfe/postman-to-openapi/commit/1d9da470d428b3053761464b7965b294c833e70b)), closes [#20](https://github.com/joolfe/postman-to-openapi/issues/20) + + +### Continuous Integration + +* added autorelease steps ([c3b297c](https://github.com/joolfe/postman-to-openapi/commit/c3b297cb4a85cf0028bdcc98c13c8ad2459e20f0)), closes [#71](https://github.com/joolfe/postman-to-openapi/issues/71) + + +### Build System + +* update version to 1.5.0 ([c3267a8](https://github.com/joolfe/postman-to-openapi/commit/c3267a847327c371cc347f615de1e5bfd5ac55d2)) + ### [1.4.1](https://github.com/joolfe/postman-to-openapi/compare/1.4.0...1.4.1) (2020-09-12)