|
790 | 790 | showSecuritySchemaProperties: '=' |
791 | 791 | }, |
792 | 792 | controller: ['$scope', '$rootScope', function ($scope, $rootScope) { |
793 | | - if (!Array.isArray($scope.list)) { |
794 | | - $scope.listArray = Object.keys($scope.list).map(function (key) { |
795 | | - return $scope.list[key]; |
796 | | - }); |
| 793 | + $scope.$watch('list', function () { |
| 794 | + if (!Array.isArray($scope.list)) { |
| 795 | + $scope.listArray = Object.keys($scope.list).map(function (key) { |
| 796 | + return $scope.list[key]; |
| 797 | + }); |
797 | 798 |
|
798 | | - $scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.listArray); |
799 | | - } else { |
800 | | - $scope.listArray = $scope.list; |
801 | | - } |
| 799 | + $scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.listArray); |
| 800 | + } else { |
| 801 | + $scope.listArray = $scope.list; |
| 802 | + } |
| 803 | + }); |
802 | 804 |
|
803 | 805 | var getArrayTypes = function(arrayType) { |
804 | 806 | if (arrayType.items.type || Array.isArray(arrayType.items.type)) { |
|
1164 | 1166 | $scope.vm.error = void(0); |
1165 | 1167 |
|
1166 | 1168 | if(RAML.LoaderUtils.ramlOriginValidate(url, $scope.options)) { |
1167 | | - $scope.vm.error = {buffer : 'RAML origin check failed. Raml does not reside underneath the path:' + RAML.LoaderUtils.allowedRamlOrigin($scope.options)}; |
| 1169 | + $scope.vm.error = {message : 'RAML origin check failed. Raml does not reside underneath the path:' + RAML.LoaderUtils.allowedRamlOrigin($scope.options)}; |
1168 | 1170 | } else { |
1169 | 1171 | return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options) |
1170 | 1172 | .then(function (api) { |
1171 | | - $scope.vm.raml = api.specification; |
1172 | | - }) |
1173 | | - .catch(function (error) { |
1174 | | - $scope.vm.error = angular.extend(error, { |
1175 | | - /*jshint camelcase: false */ |
1176 | | - buffer: (error.context_mark || error.problem_mark).buffer |
1177 | | - /*jshint camelcase: true */ |
1178 | | - }); |
| 1173 | + if (api.errors.length <= 0) { |
| 1174 | + $scope.vm.raml = api.specification; |
| 1175 | + } else { |
| 1176 | + $scope.vm.error = { message: 'Api contains errors.', errors : api.errors}; |
| 1177 | + } |
1179 | 1178 | }) |
1180 | 1179 | .finally(function () { |
1181 | 1180 | $scope.vm.loaded = true; |
|
1641 | 1640 |
|
1642 | 1641 | function loadFromUrl(url) { |
1643 | 1642 | $scope.vm.ramlUrl = url; |
1644 | | - |
1645 | 1643 | if(RAML.LoaderUtils.ramlOriginValidate(url, $scope.options)) { |
1646 | 1644 | $scope.vm.isLoadedFromUrl = true; |
1647 | 1645 | $scope.vm.error = {message : 'RAML origin check failed. Raml does not reside underneath the path:' + RAML.LoaderUtils.allowedRamlOrigin($scope.options)}; |
@@ -4652,38 +4650,35 @@ RAML.Inspector = (function() { |
4652 | 4650 | }); |
4653 | 4651 | })(); |
4654 | 4652 |
|
4655 | | -(function() { |
| 4653 | +(function () { |
4656 | 4654 | 'use strict'; |
4657 | 4655 |
|
4658 | 4656 | RAML.LoaderUtils = { |
4659 | | - |
4660 | | - allowedRamlOrigin : function(options) { |
4661 | | - var basepath='../'; |
4662 | | - if(typeof options.ramlOriginCheck === 'string') { |
| 4657 | + allowedRamlOrigin: function (options) { |
| 4658 | + var basepath = '../'; |
| 4659 | + if (typeof options.ramlOriginCheck === 'string') { |
4663 | 4660 | basepath = options.ramlOriginCheck; |
4664 | 4661 | } |
4665 | 4662 | return basepath; |
4666 | 4663 | }, |
4667 | 4664 |
|
4668 | 4665 | // prevent loading stuff from other hosts and/or services |
4669 | 4666 | ramlOriginValidate: function (url, options) { |
4670 | | - var absolutePath = function(href) { |
4671 | | - var link = document.createElement('a'); |
4672 | | - link.href = href; |
4673 | | - return link.href; |
| 4667 | + var absolutePath = function (href) { |
| 4668 | + var link = document.createElement('a'); |
| 4669 | + link.href = href; |
| 4670 | + return link.href; |
4674 | 4671 | }; |
4675 | 4672 |
|
4676 | | - var isSameBasePath = function(href, basepath) { |
4677 | | - var absoluteBasepath=absolutePath(basepath); |
4678 | | - var absoluteRamlPath=absolutePath(href); |
4679 | | - return absoluteRamlPath.indexOf(absoluteBasepath, 0) === 0; |
| 4673 | + var isSameBasePath = function (href, basepath) { |
| 4674 | + var absoluteBasepath = absolutePath(basepath); |
| 4675 | + var absoluteRamlPath = absolutePath(href); |
| 4676 | + return absoluteRamlPath.indexOf(absoluteBasepath, 0) === 0; |
4680 | 4677 | }; |
4681 | 4678 |
|
4682 | | - var decodedRamlUrl=decodeURIComponent(url); |
| 4679 | + var decodedRamlUrl = decodeURIComponent(url); |
4683 | 4680 | return options && options.ramlOriginCheck && !isSameBasePath(decodedRamlUrl, RAML.LoaderUtils.allowedRamlOrigin(options)); |
4684 | 4681 | } |
4685 | | - |
4686 | | - |
4687 | 4682 | }; |
4688 | 4683 | })(); |
4689 | 4684 |
|
@@ -7105,17 +7100,12 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache) |
7105 | 7100 | " </header>\n" + |
7106 | 7101 | "\n" + |
7107 | 7102 | " <div class=\"raml-console-initializer-row\">\n" + |
7108 | | - " <p class=\"raml-console-initializer-input-container\" style=\"height: 550px;\">\n" + |
7109 | | - " <textarea id=\"raml\" ui-codemirror=\"{\n" + |
7110 | | - " gutters: ['CodeMirror-lint-markers'],\n" + |
7111 | | - " lineNumbers: true,\n" + |
7112 | | - " lineWrapping: false,\n" + |
7113 | | - " lint: true,\n" + |
7114 | | - " mode: 'yaml',\n" + |
7115 | | - " tabSize: 2,\n" + |
7116 | | - " theme: 'raml-console'\n" + |
7117 | | - " }\" ng-model=\"vm.error.buffer\"></textarea>\n" + |
7118 | | - " </p>\n" + |
| 7103 | + " <div class=\"raml-console-parser-error\">\n" + |
| 7104 | + " <span>{{ vm.error.message }}</span>\n" + |
| 7105 | + " </div>\n" + |
| 7106 | + " <div class=\"raml-console-error-pre\" ng-repeat=\"err in vm.error.errors\">\n" + |
| 7107 | + " {{err.message}}\n" + |
| 7108 | + " </div>\n" + |
7119 | 7109 | " </div>\n" + |
7120 | 7110 | " </section>\n" + |
7121 | 7111 | " </div>\n" + |
|
0 commit comments