Skip to content

Commit

Permalink
Merge pull request #368 from mulesoft/develop
Browse files Browse the repository at this point in the history
Render console if there are only warnings
  • Loading branch information
carowright authored Nov 24, 2016
2 parents c15b4b1 + db55f3b commit dfa1c1f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
26 changes: 21 additions & 5 deletions dist/scripts/api-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -7104,7 +7120,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
" <span>{{ vm.error.message }}</span>\n" +
" </div>\n" +
" <div class=\"raml-console-error-pre\" ng-repeat=\"err in vm.error.errors\">\n" +
" {{err.message}}\n" +
" [{{err.isWarning && 'warning' || 'error'}}] {{err.message}}\n" +
" </div>\n" +
" </div>\n" +
" </section>\n" +
Expand Down
12 changes: 10 additions & 2 deletions src/app/directives/raml-console-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion src/app/directives/raml-console-loader.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4 class="raml-console-initializer-subhead">Error while parsing</h4>
<span>{{ vm.error.message }}</span>
</div>
<div class="raml-console-error-pre" ng-repeat="err in vm.error.errors">
{{err.message}}
[{{err.isWarning && 'warning' || 'error'}}] {{err.message}}
</div>
</div>
</section>
Expand Down
12 changes: 10 additions & 2 deletions src/app/directives/raml-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit dfa1c1f

Please sign in to comment.