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]) 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")
} else {
console.error("Skipped rendering: no `dom_id` was specified")
}
return system return system
} }
if (system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) { if (!system.specActions.getConfigByUrl || system.specActions.getConfigByUrl && !system.specActions.getConfigByUrl(downloadSpec)) {
return downloadSpec(config) 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")
}
return system
} }
// Add presets // Add presets