Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function swagger1Loader (config, { onLoadProgress, onNewAPI, onNewOperation, onNewDefinition, onLoadCompleted, onLoadError }) {
const url = config.url.getUrl()
onLoadProgress(`Loading API Swagger 1.0 Spec from ${url}`)
return Converter.convert({
from: 'swagger_1',
to: 'swagger_2',
source: url
}).then(function(converted) {
SwaggerParser.validate(converted.spec).then(function (api) {
let newApi = api
let defaultHost = window.location.origin
newApi = config.interceptor({ friendlyName: config.friendlyName, url: config.url }, api)
swagger2SpecLoader(newApi, config.friendlyName, config.slug, defaultHost, { onLoadProgress, onNewAPI, onNewOperation, onLoadCompleted, onLoadError })
}).catch(function (err) {
onLoadError(err)
})
}).catch(function(err) {
onLoadError(err)
})
}