From daea0715d7ad03126c3a0d1ce258f482ea041427 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Mon, 11 Jun 2018 22:49:30 -0700 Subject: [PATCH] fix: nerf property access to better support Editor test harness --- src/core/index.js | 8 +++++++- src/core/plugins/spec/wrap-actions.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/index.js b/src/core/index.js index c839ca61..77ae7ebe 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -131,6 +131,9 @@ module.exports = function SwaggerUI(opts) { var system = store.getSystem() const downloadSpec = (fetchedConfig) => { + if(typeof constructorConfig !== "object") { + return system + } let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {} let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig) @@ -140,7 +143,10 @@ module.exports = function SwaggerUI(opts) { } store.setConfigs(mergedConfig) - system.configsActions.loaded() + + if(system.configsActions) { + system.configsActions.loaded() + } if (fetchedConfig !== null) { if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) { diff --git a/src/core/plugins/spec/wrap-actions.js b/src/core/plugins/spec/wrap-actions.js index 52347318..69700d62 100644 --- a/src/core/plugins/spec/wrap-actions.js +++ b/src/core/plugins/spec/wrap-actions.js @@ -12,7 +12,7 @@ export const updateJsonSpec = (ori, {specActions}) => (...args) => { // Trigger resolution of any path-level $refs. const [json] = args - const pathItems = get(json, ["paths"]) + const pathItems = get(json, ["paths"]) || {} const pathItemKeys = Object.keys(pathItems) pathItemKeys.forEach(k => {