From 8311563e556cc5fdf791f7304d43de994203ae3d Mon Sep 17 00:00:00 2001 From: Michael Flynn Date: Sat, 24 Jul 2021 23:24:07 -0400 Subject: [PATCH 1/7] feat: adding x-www-form-urlencoded support feat: form data encoding support refactor: form data accumulator functions move to named functions --- lib/index.js | 76 +++++++++++++------ test/index.spec.js | 7 ++ test/resources/input/v2/FormData.json | 12 ++- .../resources/input/v2/WwwFormUrlencoded.json | 41 ++++++++++ test/resources/input/v21/FormData.json | 12 ++- .../input/v21/WwwFormUrlencoded.json | 51 +++++++++++++ test/resources/output/FormData.yml | 21 ++++- test/resources/output/WwwFormUrlencoded.yml | 37 +++++++++ 8 files changed, 226 insertions(+), 31 deletions(-) create mode 100644 test/resources/input/v2/WwwFormUrlencoded.json create mode 100644 test/resources/input/v21/WwwFormUrlencoded.json create mode 100644 test/resources/output/WwwFormUrlencoded.yml diff --git a/lib/index.js b/lib/index.js index a8aeebe..f278d80 100644 --- a/lib/index.js +++ b/lib/index.js @@ -116,12 +116,12 @@ function parseContact (variables, optsContact = {}) { const { name = nameVar, url = urlVar, email = emailVar } = optsContact return [name, url, email].some(e => e != null) ? { - contact: { - ...(name ? { name } : {}), - ...(url ? { url } : {}), - ...(email ? { email } : {}) - } + contact: { + ...(name ? { name } : {}), + ...(url ? { url } : {}), + ...(email ? { email } : {}) } + } : {} } @@ -169,26 +169,58 @@ function parseBody (body = {}, method) { case "formdata": content = { "multipart/form-data": { - schema: { - type: "object", - properties: body.formdata.reduce((acc, v) => { - acc[v.key] = { type: v.type === 'text' ? 'string' : v.type }; - if (v.hasOwnProperty("description")) { - acc[v.key].description = v.description == '' ? 'Description' : v.description; - } - if (v.hasOwnProperty("value") && v.value !== '') { - acc[v.key].example = v.value; - }; - return acc; - }, {}) - } + schema: { + type: "object", + properties: body.formdata.reduce(mapFormData(), {}), + encoding: body.formdata.reduce(mapFormDataEencoding(), {}) } - }; + } + }; + break; + case "urlencoded": + content = { + "application/x-www-form-urlencoded": { + schema: { + properties: body.urlencoded.reduce(mapFormData(), {}) + } + } + }; break; } return { requestBody: { content } } } +function mapFormData () { + return (data, { key, value, description, type }) => { + data[key] = { type: inferType (value) }; + if (type == "file") { + data[key].type = "string"; + data[key].format = "base64"; + } + if (description && description !== '') { + data[key].description = description; + } + if (value && value !== '') { + data[key].example = value; + }; + if (/\[required\]/gi.test(description)) { + data[key].require = true; + } + return data + } +} + +function mapFormDataEencoding () { + return (data, { key, contentType }) => { + if (contentType) { + data[key] = { contentType: contentType }; + } else { + data[key] = { contentType: 'text/plain' }; + } + return data + } +} + /* Parse the Postman query and header and transform into OpenApi parameters */ function parseParameters (query = [], header, paths, paramsMeta = {}) { // parse Headers @@ -307,9 +339,9 @@ function parseOptsAuth (optAuth) { return Object.keys(securitySchemes).length === 0 ? {} : { - components: { securitySchemes }, - security - } + components: { securitySchemes }, + security + } } /* From the path array compose the real path for OpenApi specs */ diff --git a/test/index.spec.js b/test/index.spec.js index e14fc31..d1d40b0 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -49,6 +49,7 @@ const EXPECTED_RESPONSES_MULTI_LANG = readFileSync('./test/resources/output/Resp const EXPECTED_AUTH_REQUEST = readFileSync('./test/resources/output/AuthRequest.yml', 'utf8') const EXPECTED_RESPONSES_NO_HEADERS = readFileSync('./test/resources/output/ResponsesNoHeaders.yml', 'utf8') const EXPECTED_FORM_DATA = readFileSync('./test/resources/output/FormData.yml', 'utf8') +const EXPECTED_WWW_FORM_URLENCODED = readFileSync('./test/resources/output/WwwFormUrlencoded.yml', 'utf8') const AUTH_DEFINITIONS = { myCustomAuth: { @@ -104,6 +105,7 @@ describe('Library specs', function () { const COLLECTION_RESPONSES_MULTI_LANG = `./test/resources/input/${version}/ResponsesMultiLang.json` const COLLECTION_AUTH_REQUEST = `./test/resources/input/${version}/AuthRequest.json` const COLLECTION_FORM_DATA = `./test/resources/input/${version}/FormData.json` + const COLLECTION_WWW_FORM_URLENCODED = `./test/resources/input/${version}/WwwFormUrlencoded.json` it('should work with a basic transform', async function () { const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, {}) @@ -402,6 +404,11 @@ describe('Library specs', function () { const result = await postmanToOpenApi(COLLECTION_FORM_DATA, OUTPUT_PATH, {}) equal(result, EXPECTED_FORM_DATA) }) + + it('should parse POST methods with www form urlencoded', async function () { + const result = await postmanToOpenApi(COLLECTION_WWW_FORM_URLENCODED, OUTPUT_PATH, {}) + equal(result, EXPECTED_WWW_FORM_URLENCODED) + }) }) }) diff --git a/test/resources/input/v2/FormData.json b/test/resources/input/v2/FormData.json index bd8b67f..faebc52 100644 --- a/test/resources/input/v2/FormData.json +++ b/test/resources/input/v2/FormData.json @@ -17,20 +17,26 @@ { "key": "name", "value": "New User", - "description": "full name of the user (accepts spaces)", + "description": "full name of the user (accepts spaces) [required]", "type": "text" }, { "key": "email", "value": "newuser@example.com", - "description": "email of the user (for notifications and login)", + "description": "email of the user (for notifications and login) [required]", "type": "text" }, { "key": "password", "value": "pasword123", - "description": "password (to be used for logging in)", + "description": "password (to be used for logging in) [required]", "type": "text" + }, + { + "key": "avatar", + "contentType": "application/octet-stream", + "type": "file", + "src": [] } ] }, diff --git a/test/resources/input/v2/WwwFormUrlencoded.json b/test/resources/input/v2/WwwFormUrlencoded.json new file mode 100644 index 0000000..53ee6da --- /dev/null +++ b/test/resources/input/v2/WwwFormUrlencoded.json @@ -0,0 +1,41 @@ +{ + "info": { + "_postman_id": "1eaa74c4-2d76-45f0-bd34-bff5d96f0ba8", + "name": "Form Data", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "name": "Register New User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "name", + "value": "New User", + "description": "full name of the user (accepts spaces) [required]", + "type": "text" + }, + { + "key": "email", + "value": "newuser@example.com", + "description": "email of the user (for notifications and login) [required]", + "type": "text" + }, + { + "key": "password", + "value": "pasword123", + "description": "password (to be used for logging in) [required]", + "type": "text" + } + ] + }, + "url": "https://api.io/register" + }, + "response": [] + } + ] +} diff --git a/test/resources/input/v21/FormData.json b/test/resources/input/v21/FormData.json index f572d16..609b7dc 100644 --- a/test/resources/input/v21/FormData.json +++ b/test/resources/input/v21/FormData.json @@ -17,20 +17,26 @@ { "key": "name", "value": "New User", - "description": "full name of the user (accepts spaces)", + "description": "full name of the user (accepts spaces) [required]", "type": "text" }, { "key": "email", "value": "newuser@example.com", - "description": "email of the user (for notifications and login)", + "description": "email of the user (for notifications and login) [required]", "type": "text" }, { "key": "password", "value": "pasword123", - "description": "password (to be used for logging in)", + "description": "password (to be used for logging in) [required]", "type": "text" + }, + { + "key": "avatar", + "contentType": "application/octet-stream", + "type": "file", + "src": [] } ] }, diff --git a/test/resources/input/v21/WwwFormUrlencoded.json b/test/resources/input/v21/WwwFormUrlencoded.json new file mode 100644 index 0000000..faff9dc --- /dev/null +++ b/test/resources/input/v21/WwwFormUrlencoded.json @@ -0,0 +1,51 @@ +{ + "info": { + "_postman_id": "1eaa74c4-2d76-45f0-bd34-bff5d96f0ba8", + "name": "Form Data", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Register New User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "name", + "value": "New User", + "description": "full name of the user (accepts spaces) [required]", + "type": "text" + }, + { + "key": "email", + "value": "newuser@example.com", + "description": "email of the user (for notifications and login) [required]", + "type": "text" + }, + { + "key": "password", + "value": "pasword123", + "description": "password (to be used for logging in) [required]", + "type": "text" + } + ] + }, + "url": { + "raw": "https://api.io/register", + "protocol": "https", + "host": [ + "api", + "io" + ], + "path": [ + "register" + ] + } + }, + "response": [] + } + ] +} diff --git a/test/resources/output/FormData.yml b/test/resources/output/FormData.yml index 229ee62..985673b 100644 --- a/test/resources/output/FormData.yml +++ b/test/resources/output/FormData.yml @@ -19,16 +19,31 @@ paths: properties: name: type: string - description: full name of the user (accepts spaces) + description: full name of the user (accepts spaces) [required] example: New User + require: true email: type: string - description: email of the user (for notifications and login) + description: email of the user (for notifications and login) [required] example: newuser@example.com + require: true password: type: string - description: password (to be used for logging in) + description: password (to be used for logging in) [required] example: pasword123 + require: true + avatar: + type: string + format: base64 + encoding: + name: + contentType: text/plain + email: + contentType: text/plain + password: + contentType: text/plain + avatar: + contentType: application/octet-stream responses: '200': description: Successful response diff --git a/test/resources/output/WwwFormUrlencoded.yml b/test/resources/output/WwwFormUrlencoded.yml new file mode 100644 index 0000000..a391830 --- /dev/null +++ b/test/resources/output/WwwFormUrlencoded.yml @@ -0,0 +1,37 @@ +openapi: 3.0.0 +info: + title: Form Data + version: 1.0.0 +servers: + - url: https://api.io +paths: + /register: + post: + tags: + - default + summary: Register New User + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + type: string + description: full name of the user (accepts spaces) [required] + example: New User + require: true + email: + type: string + description: email of the user (for notifications and login) [required] + example: newuser@example.com + require: true + password: + type: string + description: password (to be used for logging in) [required] + example: pasword123 + require: true + responses: + '200': + description: Successful response + content: + application/json: {} From a85eef63d7d9d67538fbf089ff7514d11f64357e Mon Sep 17 00:00:00 2001 From: Michael Flynn Date: Sun, 25 Jul 2021 00:12:45 -0400 Subject: [PATCH 2/7] refactor: improving the mapFormData function --- lib/index.js | 36 +++++++++------------ test/resources/output/FormData.yml | 10 +++--- test/resources/output/WwwFormUrlencoded.yml | 12 +++---- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/lib/index.js b/lib/index.js index c5d4c9a..56ad611 100644 --- a/lib/index.js +++ b/lib/index.js @@ -190,34 +190,28 @@ function parseBody (body = {}, method) { return { requestBody: { content } } } +/* Accumulator function for form data values */ function mapFormData () { - return (data, { key, value, description, type }) => { - data[key] = { type: inferType(value) } - if (type === 'file') { - data[key].type = 'string' - data[key].format = 'base64' - } - if (description && description !== '') { - data[key].description = description - } - if (value && value !== '') { - data[key].example = value - }; - if (/\[required\]/gi.test(description)) { - data[key].require = true + return (obj, { key, type, description, value }) => { + const required = /\[required\]/gi.test(description) + obj[key] = { + type: inferType(value), + ...(description ? { description: description.replace(/ ?\[required\] ?/gi, '') } : {}), + ...(value ? { example: value } : {}), + ...(type === 'file' ? { format: 'binary' } : {}), + ...(required ? { required } : {}) } - return data + return obj } } +/* Accumulator function for form data value encodings */ function mapFormDataEencoding () { - return (data, { key, contentType }) => { - if (contentType) { - data[key] = { contentType: contentType } - } else { - data[key] = { contentType: 'text/plain' } + return (obj, { key, contentType }) => { + obj[key] = { + ...(contentType ? { contentType: contentType } : { contentType: 'text/plain' }) } - return data + return obj } } diff --git a/test/resources/output/FormData.yml b/test/resources/output/FormData.yml index 30eda17..b822791 100644 --- a/test/resources/output/FormData.yml +++ b/test/resources/output/FormData.yml @@ -19,21 +19,21 @@ paths: properties: name: type: string - description: full name of the user (accepts spaces) [required] + description: full name of the user (accepts spaces) example: New User - require: true + required: true email: type: string - description: email of the user (for notifications and login) [required] + description: email of the user (for notifications and login) example: newuser@example.com - require: true + required: true password: type: string example: pasword123 profileImage: type: string - format: base64 description: User avatar + format: binary encoding: name: contentType: text/plain diff --git a/test/resources/output/WwwFormUrlencoded.yml b/test/resources/output/WwwFormUrlencoded.yml index a391830..0ca7ea0 100644 --- a/test/resources/output/WwwFormUrlencoded.yml +++ b/test/resources/output/WwwFormUrlencoded.yml @@ -17,19 +17,19 @@ paths: properties: name: type: string - description: full name of the user (accepts spaces) [required] + description: full name of the user (accepts spaces) example: New User - require: true + required: true email: type: string - description: email of the user (for notifications and login) [required] + description: email of the user (for notifications and login) example: newuser@example.com - require: true + required: true password: type: string - description: password (to be used for logging in) [required] + description: password (to be used for logging in) example: pasword123 - require: true + required: true responses: '200': description: Successful response From 9994c8d24805f125244af1b320dedb106a05fd78 Mon Sep 17 00:00:00 2001 From: Michael Flynn Date: Sun, 25 Jul 2021 14:10:29 -0400 Subject: [PATCH 3/7] refactor: form data drop encoding section from and removed require code Removed encoding section based on feedback. required for form data was implemented as it is used in parameters. This was removed and not refactored based on feedback. --- lib/index.js | 17 ++--------------- test/resources/output/FormData.yml | 11 ----------- test/resources/output/WwwFormUrlencoded.yml | 3 --- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/lib/index.js b/lib/index.js index 56ad611..13d4e12 100644 --- a/lib/index.js +++ b/lib/index.js @@ -171,8 +171,7 @@ function parseBody (body = {}, method) { 'multipart/form-data': { schema: { type: 'object', - properties: body.formdata.reduce(mapFormData(), {}), - encoding: body.formdata.reduce(mapFormDataEencoding(), {}) + properties: body.formdata.reduce(mapFormData(), {}) } } } @@ -193,23 +192,11 @@ function parseBody (body = {}, method) { /* Accumulator function for form data values */ function mapFormData () { return (obj, { key, type, description, value }) => { - const required = /\[required\]/gi.test(description) obj[key] = { type: inferType(value), ...(description ? { description: description.replace(/ ?\[required\] ?/gi, '') } : {}), ...(value ? { example: value } : {}), - ...(type === 'file' ? { format: 'binary' } : {}), - ...(required ? { required } : {}) - } - return obj - } -} - -/* Accumulator function for form data value encodings */ -function mapFormDataEencoding () { - return (obj, { key, contentType }) => { - obj[key] = { - ...(contentType ? { contentType: contentType } : { contentType: 'text/plain' }) + ...(type === 'file' ? { format: 'binary' } : {}) } return obj } diff --git a/test/resources/output/FormData.yml b/test/resources/output/FormData.yml index b822791..69f576c 100644 --- a/test/resources/output/FormData.yml +++ b/test/resources/output/FormData.yml @@ -21,12 +21,10 @@ paths: type: string description: full name of the user (accepts spaces) example: New User - required: true email: type: string description: email of the user (for notifications and login) example: newuser@example.com - required: true password: type: string example: pasword123 @@ -34,15 +32,6 @@ paths: type: string description: User avatar format: binary - encoding: - name: - contentType: text/plain - email: - contentType: text/plain - password: - contentType: text/plain - profileImage: - contentType: application/octet-stream responses: '200': description: Successful response diff --git a/test/resources/output/WwwFormUrlencoded.yml b/test/resources/output/WwwFormUrlencoded.yml index 0ca7ea0..e2d5656 100644 --- a/test/resources/output/WwwFormUrlencoded.yml +++ b/test/resources/output/WwwFormUrlencoded.yml @@ -19,17 +19,14 @@ paths: type: string description: full name of the user (accepts spaces) example: New User - required: true email: type: string description: email of the user (for notifications and login) example: newuser@example.com - required: true password: type: string description: password (to be used for logging in) example: pasword123 - required: true responses: '200': description: Successful response From cc4f4c5c67ea7f1f9fda87527144cfcaf9456439 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 30 Jul 2021 20:46:32 +0200 Subject: [PATCH 4/7] build: update version and mocha dep --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8eb017..62cd1bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "postman-to-openapi", - "version": "1.14.0", + "version": "1.15.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.14.0", + "version": "1.15.0", "license": "MIT", "dependencies": { "commander": "^7.2.0", @@ -25,7 +25,7 @@ "eslint-plugin-promise": "^5.1.0", "execa": "^5.1.1", "husky": "^6.0.0", - "mocha": "^9.0.2", + "mocha": "^9.0.3", "nyc": "^15.1.0", "typescript": "^4.3.2" }, @@ -3629,9 +3629,9 @@ } }, "node_modules/mocha": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.2.tgz", - "integrity": "sha512-FpspiWU+UT9Sixx/wKimvnpkeW0mh6ROAKkIaPokj3xZgxeRhcna/k5X57jJghEr8X+Cgu/Vegf8zCX5ugSuTA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", @@ -8208,9 +8208,9 @@ } }, "mocha": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.2.tgz", - "integrity": "sha512-FpspiWU+UT9Sixx/wKimvnpkeW0mh6ROAKkIaPokj3xZgxeRhcna/k5X57jJghEr8X+Cgu/Vegf8zCX5ugSuTA==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", diff --git a/package.json b/package.json index 996fcf6..331124d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postman-to-openapi", - "version": "1.14.0", + "version": "1.15.0", "description": "Convert postman collection to OpenAPI spec", "main": "lib/index.js", "types": "types/index.d.ts", @@ -54,7 +54,7 @@ "eslint-plugin-promise": "^5.1.0", "execa": "^5.1.1", "husky": "^6.0.0", - "mocha": "^9.0.2", + "mocha": "^9.0.3", "nyc": "^15.1.0", "typescript": "^4.3.2" }, From 8115bc76aa944ee16c460363bbf27ffc6932a458 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 30 Jul 2021 20:55:56 +0200 Subject: [PATCH 5/7] refactor: change collection name --- test/index.spec.js | 8 ++++---- .../v2/{WwwFormUrlencoded.json => FormUrlencoded.json} | 6 +++--- .../v21/{WwwFormUrlencoded.json => FormUrlencoded.json} | 6 +++--- .../output/{WwwFormUrlencoded.yml => FormUrlencoded.yml} | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename test/resources/input/v2/{WwwFormUrlencoded.json => FormUrlencoded.json} (90%) rename test/resources/input/v21/{WwwFormUrlencoded.json => FormUrlencoded.json} (91%) rename test/resources/output/{WwwFormUrlencoded.yml => FormUrlencoded.yml} (97%) diff --git a/test/index.spec.js b/test/index.spec.js index d1d40b0..b540b5a 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -49,7 +49,7 @@ const EXPECTED_RESPONSES_MULTI_LANG = readFileSync('./test/resources/output/Resp const EXPECTED_AUTH_REQUEST = readFileSync('./test/resources/output/AuthRequest.yml', 'utf8') const EXPECTED_RESPONSES_NO_HEADERS = readFileSync('./test/resources/output/ResponsesNoHeaders.yml', 'utf8') const EXPECTED_FORM_DATA = readFileSync('./test/resources/output/FormData.yml', 'utf8') -const EXPECTED_WWW_FORM_URLENCODED = readFileSync('./test/resources/output/WwwFormUrlencoded.yml', 'utf8') +const EXPECTED_FORM_URLENCODED = readFileSync('./test/resources/output/FormUrlencoded.yml', 'utf8') const AUTH_DEFINITIONS = { myCustomAuth: { @@ -105,7 +105,7 @@ describe('Library specs', function () { const COLLECTION_RESPONSES_MULTI_LANG = `./test/resources/input/${version}/ResponsesMultiLang.json` const COLLECTION_AUTH_REQUEST = `./test/resources/input/${version}/AuthRequest.json` const COLLECTION_FORM_DATA = `./test/resources/input/${version}/FormData.json` - const COLLECTION_WWW_FORM_URLENCODED = `./test/resources/input/${version}/WwwFormUrlencoded.json` + const COLLECTION_FORM_URLENCODED = `./test/resources/input/${version}/FormUrlencoded.json` it('should work with a basic transform', async function () { const result = await postmanToOpenApi(COLLECTION_BASIC, OUTPUT_PATH, {}) @@ -406,8 +406,8 @@ describe('Library specs', function () { }) it('should parse POST methods with www form urlencoded', async function () { - const result = await postmanToOpenApi(COLLECTION_WWW_FORM_URLENCODED, OUTPUT_PATH, {}) - equal(result, EXPECTED_WWW_FORM_URLENCODED) + const result = await postmanToOpenApi(COLLECTION_FORM_URLENCODED, OUTPUT_PATH, {}) + equal(result, EXPECTED_FORM_URLENCODED) }) }) }) diff --git a/test/resources/input/v2/WwwFormUrlencoded.json b/test/resources/input/v2/FormUrlencoded.json similarity index 90% rename from test/resources/input/v2/WwwFormUrlencoded.json rename to test/resources/input/v2/FormUrlencoded.json index 53ee6da..e199615 100644 --- a/test/resources/input/v2/WwwFormUrlencoded.json +++ b/test/resources/input/v2/FormUrlencoded.json @@ -1,7 +1,7 @@ { "info": { - "_postman_id": "1eaa74c4-2d76-45f0-bd34-bff5d96f0ba8", - "name": "Form Data", + "_postman_id": "c7890cb4-aa39-4569-9701-a9d6f4abc750", + "name": "Form Url Encoded", "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" }, "item": [ @@ -38,4 +38,4 @@ "response": [] } ] -} +} \ No newline at end of file diff --git a/test/resources/input/v21/WwwFormUrlencoded.json b/test/resources/input/v21/FormUrlencoded.json similarity index 91% rename from test/resources/input/v21/WwwFormUrlencoded.json rename to test/resources/input/v21/FormUrlencoded.json index faff9dc..d0cc333 100644 --- a/test/resources/input/v21/WwwFormUrlencoded.json +++ b/test/resources/input/v21/FormUrlencoded.json @@ -1,7 +1,7 @@ { "info": { - "_postman_id": "1eaa74c4-2d76-45f0-bd34-bff5d96f0ba8", - "name": "Form Data", + "_postman_id": "c7890cb4-aa39-4569-9701-a9d6f4abc750", + "name": "Form Url Encoded", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ @@ -48,4 +48,4 @@ "response": [] } ] -} +} \ No newline at end of file diff --git a/test/resources/output/WwwFormUrlencoded.yml b/test/resources/output/FormUrlencoded.yml similarity index 97% rename from test/resources/output/WwwFormUrlencoded.yml rename to test/resources/output/FormUrlencoded.yml index e2d5656..6e1d141 100644 --- a/test/resources/output/WwwFormUrlencoded.yml +++ b/test/resources/output/FormUrlencoded.yml @@ -1,6 +1,6 @@ openapi: 3.0.0 info: - title: Form Data + title: Form Url Encoded version: 1.0.0 servers: - url: https://api.io From 2c38fd91db2e9401840b37094cdf3a53c5f75221 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 30 Jul 2021 20:58:12 +0200 Subject: [PATCH 6/7] docs: mention new feature about "x-www-form-urlencoded" --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 0af88f5..a7dfc8b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,7 +25,7 @@ * Transform query, headers and path parameters (description, required...). * Postman variables as Path parameters. * Automatic infer types from query and headers parameters. -* Support postman "raw" body for `Json` and `Text` formats and also postman body "form-data". +* Support postman "raw" body (`Json` and `Text`), "form-data" and "x-www-form-urlencoded". * Postman Authorization parse or by configuration (Basic and Bearer). * Contact and License from variables or by configuration. * Provide meta-information as a markdown table. @@ -320,7 +320,7 @@ The default value is `true`, so headers are by default added to the response def ## Basic conversion -This library support the transformation from Postman collection to all the basic HTTP method as GET, POST, PUT... parse the body request of type "raw" (`Json` and `Text`) and "form-data" (see ["form-data" body](#form-data-body) section for more info about this mode). [Query parameters](#parameters-parsing) are also supported. +This library support the transformation from Postman collection to all the basic HTTP method as GET, POST, PUT... parse the body request of type "raw" (`Json` and `Text`), "form-data" (see ["form-data" body](#form-data-body) section for more info about this mode) and "x-www-form-urlencoded" formats. [Query parameters](#parameters-parsing) are also supported. Have a look to the [PostmantoOpenAPI collection](https://github.com/joolfe/postman-to-openapi/blob/master/test/resources/input/v21/PostmantoOpenAPI.json) file for an example of how to use this feature. From 89b6310dcfb8eb66141aec2114e0990e36232783 Mon Sep 17 00:00:00 2001 From: Jorge Date: Fri, 30 Jul 2021 20:59:07 +0200 Subject: [PATCH 7/7] docs: update CHANGELOG --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dbac63..1b1f9e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +## [1.15.0](https://github.com/joolfe/postman-to-openapi/compare/1.14.0...1.15.0) (2021-07-30) + + +### Features + +* adding x-www-form-urlencoded support ([8311563](https://github.com/joolfe/postman-to-openapi/commit/8311563e556cc5fdf791f7304d43de994203ae3d)) + + +### Bug Fixes + +* move import to try to fix erro in gh pages ([326c745](https://github.com/joolfe/postman-to-openapi/commit/326c745a957cd0dc38187adeb1aaf81309dc8a89)) +* put color to the beginning of the css ([9cc56b0](https://github.com/joolfe/postman-to-openapi/commit/9cc56b06963cf775232dea9134cb30c362f2c4e9)) + + +### Tests + +* trying to fix docs theme error ([8c6428b](https://github.com/joolfe/postman-to-openapi/commit/8c6428b119607d92aa7adf46a86cf4caa5729acc)) + + +### Build System + +* update version and mocha dep ([cc4f4c5](https://github.com/joolfe/postman-to-openapi/commit/cc4f4c5c67ea7f1f9fda87527144cfcaf9456439)) + + +### Code Refactoring + +* change collection name ([8115bc7](https://github.com/joolfe/postman-to-openapi/commit/8115bc76aa944ee16c460363bbf27ffc6932a458)) +* form data drop encoding section from and removed require code ([9994c8d](https://github.com/joolfe/postman-to-openapi/commit/9994c8d24805f125244af1b320dedb106a05fd78)) +* improving the mapFormData function ([a85eef6](https://github.com/joolfe/postman-to-openapi/commit/a85eef63d7d9d67538fbf089ff7514d11f64357e)) + + +### Documentation + +* mention new feature about "x-www-form-urlencoded" ([2c38fd9](https://github.com/joolfe/postman-to-openapi/commit/2c38fd91db2e9401840b37094cdf3a53c5f75221)) + ## [1.14.0](https://github.com/joolfe/postman-to-openapi/compare/1.13.0...1.14.0) (2021-07-24)