fixed fetch config
This commit is contained in:
4
dist/swagger-ui.js
vendored
4
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
2
dist/swagger-ui.js.map
vendored
2
dist/swagger-ui.js.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;AA2mGA;AAy3HA;AA6+FA;AAgqCA;AA69BA;AAmwCA;AAw4BA","sourceRoot":""}
|
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;AAqnGA;AAi2HA;AA6+FA;AAgqCA;AA69BA;AAmwCA;AAw4BA","sourceRoot":""}
|
||||||
@@ -66,6 +66,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
store.register([config.plugins, inlinePlugin])
|
store.register([config.plugins, inlinePlugin])
|
||||||
|
|
||||||
var system = store.getSystem()
|
var system = store.getSystem()
|
||||||
|
let queryConfig = parseSeach()
|
||||||
|
|
||||||
const downloadSpec = (configs) => {
|
const downloadSpec = (configs) => {
|
||||||
if(typeof config !== "object") {
|
if(typeof config !== "object") {
|
||||||
@@ -73,46 +74,31 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
|
||||||
let mergedConfig = deepExtend({}, config, configs, localConfig)
|
let mergedConfig = deepExtend({}, config, localConfig, configs, queryConfig)
|
||||||
let search = parseSeach()
|
|
||||||
if (search.url) {
|
|
||||||
mergedConfig.url = search.url
|
|
||||||
}
|
|
||||||
store.setConfigs(filterConfigs(mergedConfig))
|
store.setConfigs(filterConfigs(mergedConfig))
|
||||||
|
|
||||||
if(!search.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
if(!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) {
|
||||||
system.specActions.updateUrl("")
|
system.specActions.updateUrl("")
|
||||||
system.specActions.updateLoadingStatus("success");
|
system.specActions.updateLoadingStatus("success");
|
||||||
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
|
system.specActions.updateSpec(JSON.stringify(mergedConfig.spec))
|
||||||
} else if(mergedConfig.url) {
|
} else if(system.specActions.download && mergedConfig.url) {
|
||||||
system.specActions.updateUrl(mergedConfig.url)
|
system.specActions.updateUrl(mergedConfig.url)
|
||||||
system.specActions.download(mergedConfig.url)
|
system.specActions.download(mergedConfig.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mergedConfig.dom_id)
|
if(mergedConfig.dom_id) {
|
||||||
system.render(mergedConfig.dom_id, "App")
|
system.render(mergedConfig.dom_id, "App")
|
||||||
|
|
||||||
return system
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) {
|
|
||||||
return downloadSpec(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system.specActions.download && config.url) {
|
|
||||||
system.specActions.download(config.url)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(config.spec && typeof config.spec === "string")
|
|
||||||
system.specActions.updateSpec(config.spec)
|
|
||||||
|
|
||||||
if(config.dom_id) {
|
|
||||||
system.render(config.dom_id, "App")
|
|
||||||
} else {
|
} else {
|
||||||
console.error("Skipped rendering: no `dom_id` was specified")
|
console.error("Skipped rendering: no `dom_id` was specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
return system
|
return system
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!system.specActions.getConfigByUrl || system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) {
|
||||||
|
return downloadSpec(config)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add presets
|
// Add presets
|
||||||
|
|||||||
Reference in New Issue
Block a user