Skip to content

Commit

Permalink
Merge branch 'master' into fix/gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
shockey authored May 10, 2017
2 parents d378d38 + f8381bf commit 0ac0b5b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
9 changes: 6 additions & 3 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import System from "core/system"
import win from "core/window"
import ApisPreset from "core/presets/apis"
import * as AllPlugins from "core/plugins/all"
import { filterConfigs } from "plugins/configs"
import { parseSeach } from "core/utils"
import { parseSeach, filterConfigs } from "core/utils"

const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id",
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders" ]

// eslint-disable-next-line no-undef
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
Expand Down Expand Up @@ -82,7 +85,7 @@ module.exports = function SwaggerUI(opts) {

let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
store.setConfigs(filterConfigs(mergedConfig))
store.setConfigs(filterConfigs(mergedConfig, CONFIGS))

if (fetchedConfig !== null) {
if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
Expand Down
12 changes: 12 additions & 0 deletions src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,15 @@ export const buildFormData = (data) => {
}
return formArr.join("&")
}

export const filterConfigs = (configs, allowed) => {
let i, filteredConfigs = {}

for (i in configs) {
if (allowed.indexOf(i) !== -1) {
filteredConfigs[i] = configs[i]
}
}

return filteredConfigs
}
17 changes: 0 additions & 17 deletions src/plugins/configs/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import YAML from "js-yaml"
import yamlConfig from "../../../swagger-config.yaml"

const CONFIGS = [ "url", "spec", "validatorUrl", "onComplete", "onFailure", "authorizations", "docExpansion",
"apisSorter", "operationsSorter", "supportedSubmitMethods", "highlightSizeThreshold", "dom_id",
"defaultModelRendering", "oauth2RedirectUrl", "showRequestHeaders" ]

const parseYamlConfig = (yaml, system) => {
try {
return YAML.safeLoad(yaml)
Expand Down Expand Up @@ -58,16 +54,3 @@ export default function configPlugin (toolbox) {
}
}
}


export function filterConfigs (configs) {
let i, filteredConfigs = {}

for (i in configs) {
if (CONFIGS.indexOf(i) !== -1) {
filteredConfigs[i] = configs[i]
}
}

return filteredConfigs
}

0 comments on commit 0ac0b5b

Please # to comment.