From 35afaba45f47aac0dcb967b123fd6303b45f572e Mon Sep 17 00:00:00 2001 From: agustin Date: Thu, 24 Nov 2016 17:38:02 -0300 Subject: [PATCH] Render console if there are only warnings --- dist/scripts/api-console.js | 26 +++++++++++++++---- src/app/directives/raml-console-loader.js | 12 +++++++-- .../directives/raml-console-loader.tpl.html | 2 +- src/app/directives/raml-initializer.js | 12 +++++++-- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/dist/scripts/api-console.js b/dist/scripts/api-console.js index 1ce180782..4ba151a04 100644 --- a/dist/scripts/api-console.js +++ b/dist/scripts/api-console.js @@ -1170,10 +1170,18 @@ } else { return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options) .then(function (api) { - if (api.errors.length <= 0) { + var success = true; + var issues = api.errors; // errors and warnings + if (issues && issues.length > 0) { + success = issues.filter(function (issue) { + return !issue.isWarning; + }).length === 0; + } + + if (success) { $scope.vm.raml = api.specification; } else { - $scope.vm.error = { message: 'Api contains errors.', errors : api.errors}; + $scope.vm.error = { message: 'Api contains errors.', errors : issues}; } }) .finally(function () { @@ -1669,11 +1677,19 @@ return promise .then(function (api) { - if (api.errors.length <= 0) { + var success = true; + var issues = api.errors; // errors and warnings + if (issues && issues.length > 0) { + success = issues.filter(function (issue) { + return !issue.isWarning; + }).length === 0; + } + + if (success) { $scope.vm.raml = api.specification; } else { $scope.vm.error = { message: 'Api contains errors.'}; - $scope.vm.codeMirror.lint = lintFromError(api.errors); + $scope.vm.codeMirror.lint = lintFromError(issues); } }) .finally(function () { @@ -7104,7 +7120,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache) " {{ vm.error.message }}\n" + " \n" + "
\n" + - " {{err.message}}\n" + + " [{{err.isWarning && 'warning' || 'error'}}] {{err.message}}\n" + "
\n" + " \n" + " \n" + diff --git a/src/app/directives/raml-console-loader.js b/src/app/directives/raml-console-loader.js index 1ce16a756..c6ba34ce4 100644 --- a/src/app/directives/raml-console-loader.js +++ b/src/app/directives/raml-console-loader.js @@ -45,10 +45,18 @@ } else { return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options) .then(function (api) { - if (api.errors.length <= 0) { + var success = true; + var issues = api.errors; // errors and warnings + if (issues && issues.length > 0) { + success = issues.filter(function (issue) { + return !issue.isWarning; + }).length === 0; + } + + if (success) { $scope.vm.raml = api.specification; } else { - $scope.vm.error = { message: 'Api contains errors.', errors : api.errors}; + $scope.vm.error = { message: 'Api contains errors.', errors : issues}; } }) .finally(function () { diff --git a/src/app/directives/raml-console-loader.tpl.html b/src/app/directives/raml-console-loader.tpl.html index 49bf4e744..3991447e5 100644 --- a/src/app/directives/raml-console-loader.tpl.html +++ b/src/app/directives/raml-console-loader.tpl.html @@ -17,7 +17,7 @@

Error while parsing

{{ vm.error.message }}
- {{err.message}} + [{{err.isWarning && 'warning' || 'error'}}] {{err.message}}
diff --git a/src/app/directives/raml-initializer.js b/src/app/directives/raml-initializer.js index fde416c38..641bcc9f7 100644 --- a/src/app/directives/raml-initializer.js +++ b/src/app/directives/raml-initializer.js @@ -76,11 +76,19 @@ return promise .then(function (api) { - if (api.errors.length <= 0) { + var success = true; + var issues = api.errors; // errors and warnings + if (issues && issues.length > 0) { + success = issues.filter(function (issue) { + return !issue.isWarning; + }).length === 0; + } + + if (success) { $scope.vm.raml = api.specification; } else { $scope.vm.error = { message: 'Api contains errors.'}; - $scope.vm.codeMirror.lint = lintFromError(api.errors); + $scope.vm.codeMirror.lint = lintFromError(issues); } }) .finally(function () {