From d1be86968a19d6c39509e0c1504bb47af4f230b8 Mon Sep 17 00:00:00 2001 From: Melsy Huamani Date: Mon, 23 Feb 2026 12:48:25 -0500 Subject: [PATCH 1/2] fix: update primary auth token retrieval --- src/generator/authorization.js | 2 +- src/parser/openapiAuthorizationDefinition.js | 19 +++++++++---------- test/generator-authorization.js | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/generator/authorization.js b/src/generator/authorization.js index 9ca5123..ab0f72f 100644 --- a/src/generator/authorization.js +++ b/src/generator/authorization.js @@ -5,7 +5,7 @@ const _ = require('lodash'); module.exports = function() { - + return function get(postmanRequest, status){ if (!postmanRequest.aux.authorization){ return postmanRequest; diff --git a/src/parser/openapiAuthorizationDefinition.js b/src/parser/openapiAuthorizationDefinition.js index 73287fc..a8d2be6 100644 --- a/src/parser/openapiAuthorizationDefinition.js +++ b/src/parser/openapiAuthorizationDefinition.js @@ -6,12 +6,11 @@ const _ = require('lodash'); module.exports = function() { - + return function get(oAuthDefinition){ let definition for (const i in oAuthDefinition) { definition = oAuthDefinition[i]; - } const data = parseUrl(definition.flows) const authKey = _.keys(global.definition.security[0])[0] @@ -27,20 +26,20 @@ module.exports = function() { }, item: [ { - name: "Get OAuth2 Token", + name: `Get OAuth2 Token - ${auth}`, event: [ { listen: "test", script: { id: "7e78bc50-5882-47e1-9920-754befbbbfc5", exec: [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "var json = pm.response.json();", - "", - `pm.environment.set(\"${auth}\", \"Bearer \"+json.data.access_token);` + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "var json = pm.response.json();", + "var token = json.access_token || (json.data && json.data.access_token);", + `pm.environment.set("${auth}", "Bearer "+token);` ], type: "text/javascript" } diff --git a/test/generator-authorization.js b/test/generator-authorization.js index 7aed250..70ef8a3 100644 --- a/test/generator-authorization.js +++ b/test/generator-authorization.js @@ -3,7 +3,7 @@ const assert = require('assert'); describe('generator-authorization', () => { - + it('good', () => { let endpoint = require('../seeds/generatorEndpointInitial.json'); From 5d3075b4d0ffc417ad685d8dd288fcdb61ca3a9c Mon Sep 17 00:00:00 2001 From: Melsy Huamani Date: Mon, 23 Feb 2026 14:13:59 -0500 Subject: [PATCH 2/2] update version to 2.2.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a7088a..7458a1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi2postman", - "version": "2.2.6", + "version": "2.2.7", "description": "openapi2postman", "bin": { "o2p": "index.js"