fixed fetch config

This commit is contained in:
Anna Bodnia
2017-03-19 14:47:42 +02:00
parent 26d5305404
commit 0b56640273
3 changed files with 12 additions and 26 deletions

4
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -66,6 +66,7 @@ module.exports = function SwaggerUI(opts) {
store.register([config.plugins, inlinePlugin])
var system = store.getSystem()
let queryConfig = parseSeach()
const downloadSpec = (configs) => {
if(typeof config !== "object") {
@@ -73,41 +74,20 @@ module.exports = function SwaggerUI(opts) {
}
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, config, configs, localConfig)
let search = parseSeach()
if (search.url) {
mergedConfig.url = search.url
}
let mergedConfig = deepExtend({}, config, localConfig, configs, queryConfig)
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.updateLoadingStatus("success");
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.download(mergedConfig.url)
}
if(mergedConfig.dom_id)
if(mergedConfig.dom_id) {
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 {
console.error("Skipped rendering: no `dom_id` was specified")
}
@@ -115,6 +95,12 @@ module.exports = function SwaggerUI(opts) {
return system
}
if (!system.specActions.getConfigByUrl || system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) {
return downloadSpec(config)
}
}
// Add presets
module.exports.presets = {
apis: ApisPreset,