From fe2a8073290e15127f4711d87abdb153bec4c347 Mon Sep 17 00:00:00 2001 From: apilabeyes Date: Tue, 15 Feb 2022 16:25:45 +0900 Subject: [PATCH] Add swagger escape character https://swagger.io/docs/specification/using-ref/ --- openapi-to-har.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/openapi-to-har.js b/openapi-to-har.js index 5ca81c4..582969a 100644 --- a/openapi-to-har.js +++ b/openapi-to-har.js @@ -541,14 +541,25 @@ const resolveRef = function (openApi, ref) { if (index + 1 < parts.length) { // index = 1 let newCount = index + 1; - return recursive(obj[parts[index]], newCount); + return recursive(obj[replaceCharacter(parts[index])], newCount); } else { - return obj[parts[index]]; + return obj[replaceCharacter(parts[index])]; } }; return recursive(openApi, 1); }; +/** + * Replace escape character + * https://swagger.io/docs/specification/using-ref/ + * + * @param {string} refParts A reference string + * @return {string} + */ +const replaceCharacter = function (refParts) { + return refParts.replaceAll('~0', '~').replaceAll('~1', '/'); +} + module.exports = { getAll: openApiToHarList, getEndpoint: createHar,