Skip to content

Commit dfa1c1f

Browse files
authored
Merge pull request #368 from mulesoft/develop
Render console if there are only warnings
2 parents c15b4b1 + db55f3b commit dfa1c1f

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

dist/scripts/api-console.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,18 @@
11701170
} else {
11711171
return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options)
11721172
.then(function (api) {
1173-
if (api.errors.length <= 0) {
1173+
var success = true;
1174+
var issues = api.errors; // errors and warnings
1175+
if (issues && issues.length > 0) {
1176+
success = issues.filter(function (issue) {
1177+
return !issue.isWarning;
1178+
}).length === 0;
1179+
}
1180+
1181+
if (success) {
11741182
$scope.vm.raml = api.specification;
11751183
} else {
1176-
$scope.vm.error = { message: 'Api contains errors.', errors : api.errors};
1184+
$scope.vm.error = { message: 'Api contains errors.', errors : issues};
11771185
}
11781186
})
11791187
.finally(function () {
@@ -1669,11 +1677,19 @@
16691677

16701678
return promise
16711679
.then(function (api) {
1672-
if (api.errors.length <= 0) {
1680+
var success = true;
1681+
var issues = api.errors; // errors and warnings
1682+
if (issues && issues.length > 0) {
1683+
success = issues.filter(function (issue) {
1684+
return !issue.isWarning;
1685+
}).length === 0;
1686+
}
1687+
1688+
if (success) {
16731689
$scope.vm.raml = api.specification;
16741690
} else {
16751691
$scope.vm.error = { message: 'Api contains errors.'};
1676-
$scope.vm.codeMirror.lint = lintFromError(api.errors);
1692+
$scope.vm.codeMirror.lint = lintFromError(issues);
16771693
}
16781694
})
16791695
.finally(function () {
@@ -7104,7 +7120,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
71047120
" <span>{{ vm.error.message }}</span>\n" +
71057121
" </div>\n" +
71067122
" <div class=\"raml-console-error-pre\" ng-repeat=\"err in vm.error.errors\">\n" +
7107-
" {{err.message}}\n" +
7123+
" [{{err.isWarning && 'warning' || 'error'}}] {{err.message}}\n" +
71087124
" </div>\n" +
71097125
" </div>\n" +
71107126
" </section>\n" +

src/app/directives/raml-console-loader.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,18 @@
4545
} else {
4646
return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options)
4747
.then(function (api) {
48-
if (api.errors.length <= 0) {
48+
var success = true;
49+
var issues = api.errors; // errors and warnings
50+
if (issues && issues.length > 0) {
51+
success = issues.filter(function (issue) {
52+
return !issue.isWarning;
53+
}).length === 0;
54+
}
55+
56+
if (success) {
4957
$scope.vm.raml = api.specification;
5058
} else {
51-
$scope.vm.error = { message: 'Api contains errors.', errors : api.errors};
59+
$scope.vm.error = { message: 'Api contains errors.', errors : issues};
5260
}
5361
})
5462
.finally(function () {

src/app/directives/raml-console-loader.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h4 class="raml-console-initializer-subhead">Error while parsing</h4>
1717
<span>{{ vm.error.message }}</span>
1818
</div>
1919
<div class="raml-console-error-pre" ng-repeat="err in vm.error.errors">
20-
{{err.message}}
20+
[{{err.isWarning && 'warning' || 'error'}}] {{err.message}}
2121
</div>
2222
</div>
2323
</section>

src/app/directives/raml-initializer.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,19 @@
7676

7777
return promise
7878
.then(function (api) {
79-
if (api.errors.length <= 0) {
79+
var success = true;
80+
var issues = api.errors; // errors and warnings
81+
if (issues && issues.length > 0) {
82+
success = issues.filter(function (issue) {
83+
return !issue.isWarning;
84+
}).length === 0;
85+
}
86+
87+
if (success) {
8088
$scope.vm.raml = api.specification;
8189
} else {
8290
$scope.vm.error = { message: 'Api contains errors.'};
83-
$scope.vm.codeMirror.lint = lintFromError(api.errors);
91+
$scope.vm.codeMirror.lint = lintFromError(issues);
8492
}
8593
})
8694
.finally(function () {

0 commit comments

Comments
 (0)