From fa93c35426b7607072d945ca9143794288b6c4bd Mon Sep 17 00:00:00 2001 From: Jorge Date: Sat, 17 Sep 2022 12:20:23 +0200 Subject: [PATCH 1/2] fix: support collections without the headers fields in request close #217 --- lib/index.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- test/resources/input/NullHeaders.json | 28 +++++++++++++++++++++++++++ test/resources/output/NullHeader.yml | 22 +++++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 543b52c..768bec6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -38,7 +38,7 @@ async function postmanToOpenApi (input, output, { // If there are an empty folder at the end of the colection elements could be `undefined` if (element != null) { const { - request: { url, method, body, description: rawDesc, header, auth }, + request: { url, method, body, description: rawDesc, header = [], auth }, name: summary, tag = defaultTag, event: events, response } = element const { path, query, protocol, host, port, valid, pathVars } = scrapeURL(url) diff --git a/package-lock.json b/package-lock.json index 12fa425..6b322f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "postman-to-openapi", - "version": "2.6.1", + "version": "2.6.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "postman-to-openapi", - "version": "2.6.1", + "version": "2.6.2", "license": "MIT", "dependencies": { "commander": "^8.3.0", diff --git a/package.json b/package.json index 5dcb990..263148e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postman-to-openapi", - "version": "2.6.1", + "version": "2.6.2", "description": "Convert postman collection to OpenAPI spec", "main": "lib/index.js", "types": "types/index.d.ts", diff --git a/test/resources/input/NullHeaders.json b/test/resources/input/NullHeaders.json index 7fa049c..dc3ea82 100644 --- a/test/resources/input/NullHeaders.json +++ b/test/resources/input/NullHeaders.json @@ -97,6 +97,34 @@ "body": "{\n \"erreur\": null,\n \"codeErreur\": 0,\n \"contenu\": {\n \"token\": \"ct54q7uoidffg2z661afigu98ix476s8\"\n }\n}" } ] + }, + { + "name": "Missing headers field", + "request": { + "method": "POST", + "body": { + "mode": "raw", + "raw": "{\n \"example\": \"field\",\n \"other\": {\n \"data1\": \"yes\",\n \"data2\": \"no\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "https://api.io/userHeader", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "userHeader" + ] + }, + "description": "Create a new user into your amazing API" + }, + "response": [] } ], "event": [ diff --git a/test/resources/output/NullHeader.yml b/test/resources/output/NullHeader.yml index 8481ac8..6526bf2 100644 --- a/test/resources/output/NullHeader.yml +++ b/test/resources/output/NullHeader.yml @@ -4,6 +4,7 @@ info: version: 1.0.0 servers: - url: http://{{url}} + - url: https://api.io tags: - name: Authentification paths: @@ -47,3 +48,24 @@ paths: codeErreur: 0 contenu: token: ct54q7uoidffg2z661afigu98ix476s8 + /userHeader: + post: + tags: + - Authentification + summary: Missing headers field + description: Create a new user into your amazing API + requestBody: + content: + application/json: + schema: + type: object + example: + example: field + other: + data1: 'yes' + data2: 'no' + responses: + '200': + description: Successful response + content: + application/json: {} From 76867b90b7728875292a2be78b340d1e44133d24 Mon Sep 17 00:00:00 2001 From: Jorge Date: Sat, 17 Sep 2022 12:23:56 +0200 Subject: [PATCH 2/2] docs: update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 132ba9d..a162aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### [2.6.2](https://github.com/joolfe/postman-to-openapi/compare/2.6.1...2.6.2) (2022-09-17) + + +### Bug Fixes + +* support collections without the headers fields in request close [#217](https://github.com/joolfe/postman-to-openapi/issues/217) ([fa93c35](https://github.com/joolfe/postman-to-openapi/commit/fa93c35426b7607072d945ca9143794288b6c4bd)) + ### [2.6.1](https://github.com/joolfe/postman-to-openapi/compare/2.6.0...2.6.1) (2022-09-17)