From c8a8bf6b2b996d0c5c1e62540228dbf538db781f Mon Sep 17 00:00:00 2001 From: Gabriel Bennett <95309935+gbennett-squarespace@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:13:48 -0800 Subject: [PATCH] Check for existence of oaData.info (and title/version) (#747) * Adds a check to make sure that info and title/version exists before we try and manipulate them, adds defaults if missing. Signed-off-by: gbennett * Adds a check to make sure that info and title/version exists before we try and manipulate them, adds defaults if missing. Signed-off-by: gbennett * linting Signed-off-by: gbennett --------- Signed-off-by: gbennett --- utils.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils.js b/utils.js index ed4256dc7..50290416b 100644 --- a/utils.js +++ b/utils.js @@ -4680,8 +4680,13 @@ export const parseOpenapiSpecData = function (oaData) { } catch (e) { return servlist; } - const name = oaData.info.title.replace(/ /g, "-"); - const version = oaData.info.version || "latest"; + + const name = + oaData.info && oaData.info.title + ? oaData.info.title.replace(/ /g, "-") + : "default-name"; + const version = + oaData.info && oaData.info.version ? oaData.info.version : "latest"; const aservice = { "bom-ref": `urn:service:${name}:${version}`, name,