diff --git a/app/index.html b/app/index.html index 2366d183d21..373b46e063e 100644 --- a/app/index.html +++ b/app/index.html @@ -4,10 +4,10 @@ Swagger Editor - - + + - + @@ -16,100 +16,100 @@
- - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/scripts/bootstrap.js b/app/scripts/bootstrap.js index 9c2c847082f..9c356c92614 100644 --- a/app/scripts/bootstrap.js +++ b/app/scripts/bootstrap.js @@ -9,11 +9,17 @@ $(function () { window.SwaggerEditor.$defaults = embeddedDefaults; angular.bootstrap(window.document, ['SwaggerEditor']); } else { - $.getJSON('/config/defaults.json').done(function (resp) { + var rootPath = ''; + if (window.location.pathname.lastIndexOf('/') !== + (window.location.pathname.length - 1)) { + rootPath = window.location.pathname + '/../'; + } + $.getJSON(rootPath + './config/defaults.json').done(function (resp) { window.SwaggerEditor.$defaults = resp; angular.bootstrap(window.document, ['SwaggerEditor']); }).fail(function () { - console.error('Failed to load defaults.json at', '/config/defaults.json'); + console.error('Failed to load defaults.json at', + rootPath + './config/defaults.json'); }); } }); diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index c52cee64e94..279090d2b74 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -43,7 +43,12 @@ SwaggerEditor.controller('MainCtrl', function MainCtrl($rootScope, $stateParams, // If there is no saved YAML either, load the default example } else if (!yaml) { - url = defaults.examplesFolder + defaults.exampleFiles[0]; + var rootPath = ''; + if (window.location.pathname.lastIndexOf('/') !== + (window.location.pathname.length - 1)) { + rootPath = window.location.pathname + '/../'; + } + url = rootPath + defaults.examplesFolder + defaults.exampleFiles[0]; } if (url) {