Procházet zdrojové kódy

Move filterConfigs to core

Fixes #3056
bubble
Javier Mendiara Cañardo před 7 roky
rodič
revize
53986d60bc
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: C4CF4990702CE9F7
3 změnil soubory, kde provedl 18 přidání a 20 odebrání
  1. +6
    -3
      src/core/index.js
  2. +12
    -0
      src/core/utils.js
  3. +0
    -17
      src/plugins/configs/index.js

+ 6
- 3
src/core/index.js Zobrazit soubor

@@ -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
@@ -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) {


+ 12
- 0
src/core/utils.js Zobrazit soubor

@@ -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
}

+ 0
- 17
src/plugins/configs/index.js Zobrazit soubor

@@ -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)
@@ -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
}

Načítá se…
Zrušit
Uložit