Merge branch 'master' into fix/gitignore
This commit is contained in:
@@ -4,8 +4,11 @@ import System from "core/system"
|
|||||||
import win from "core/window"
|
import win from "core/window"
|
||||||
import ApisPreset from "core/presets/apis"
|
import ApisPreset from "core/presets/apis"
|
||||||
import * as AllPlugins from "core/plugins/all"
|
import * as AllPlugins from "core/plugins/all"
|
||||||
import { filterConfigs } from "plugins/configs"
|
import { parseSeach, filterConfigs } from "core/utils"
|
||||||
import { parseSeach } 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
|
// eslint-disable-next-line no-undef
|
||||||
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
|
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 localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
||||||
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
|
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)
|
||||||
store.setConfigs(filterConfigs(mergedConfig))
|
store.setConfigs(filterConfigs(mergedConfig, CONFIGS))
|
||||||
|
|
||||||
if (fetchedConfig !== null) {
|
if (fetchedConfig !== null) {
|
||||||
if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
||||||
|
|||||||
@@ -577,3 +577,15 @@ export const buildFormData = (data) => {
|
|||||||
}
|
}
|
||||||
return formArr.join("&")
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import YAML from "js-yaml"
|
import YAML from "js-yaml"
|
||||||
import yamlConfig from "../../../swagger-config.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) => {
|
const parseYamlConfig = (yaml, system) => {
|
||||||
try {
|
try {
|
||||||
return YAML.safeLoad(yaml)
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user