From b03bf906640148a9e73721b4ab760417992a1efc Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Fri, 22 Dec 2017 22:39:39 -0600 Subject: [PATCH] Allow initialState key deletion --- src/core/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/index.js b/src/core/index.js index 8a94c97e..15f0e798 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -92,6 +92,20 @@ module.exports = function SwaggerUI(opts) { }, constructorConfig.initialState) } + if(constructorConfig.initialState) { + // if the user sets a key as `undefined`, that signals to us that we + // should delete the key entirely. + // known usage: Swagger-Editor validate plugin tests + for (var key in constructorConfig.initialState) { + if( + constructorConfig.initialState.hasOwnProperty(key) + && constructorConfig.initialState[key] === undefined + ) { + delete storeConfigs.state[key] + } + } + } + let inlinePlugin = ()=> { return { fn: constructorConfig.fn,