From 28b0da583fb00f247e4c5e560b675d8ed26637c8 Mon Sep 17 00:00:00 2001 From: glosier Date: Thu, 7 Jan 2021 09:35:14 -0800 Subject: [PATCH] server addys --- openapi-to-har.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openapi-to-har.js b/openapi-to-har.js index f767261..762ddea 100644 --- a/openapi-to-har.js +++ b/openapi-to-har.js @@ -36,11 +36,9 @@ const createHar = function (openApi, path, method, queryParamValues) { queryParamValues = {} } - const baseUrl = getBaseUrl(openApi) - const har = { method: method.toUpperCase(), - url: baseUrl + getFullPath(openApi, path, method), + url: getFullPath(openApi, path, method), headers: getHeadersArray(openApi, path, method), queryString: getQueryStrings(openApi, path, method, queryParamValues), httpVersion: 'HTTP/1.1', @@ -190,7 +188,9 @@ const getQueryStrings = function (openApi, path, method, values) { * @return {string} Full path including example values */ const getFullPath = function (openApi, path, method) { - let fullPath = path + const baseUrl = getBaseUrl(openApi) + const servers = openApi.paths[path].servers || openApi.paths[path][method].servers + let fullPath = (servers) ? servers[0].url + path : baseUrl + path const parameters = openApi.paths[path].parameters || openApi.paths[path][method].parameters; if (typeof parameters !== 'undefined') {