Skip to content

Commit f74d8aa

Browse files
author
Carolina Wright
committed
Merge branch 'master' into bugs/query-parameters-validations
2 parents ebab9fc + b7dce72 commit f74d8aa

File tree

11 files changed

+128
-25
lines changed

11 files changed

+128
-25
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-console",
3-
"version": "3.0.9",
3+
"version": "3.0.10",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/mulesoft/api-console.git"
@@ -20,7 +20,7 @@
2020
"jszip": "~2.0.0",
2121
"marked": "~0.3.1",
2222
"raml-client-generator": "~0.0.7",
23-
"raml-1-parser": "https://github.com/raml-org/raml-js-parser-2/releases/download/1.1.5/raml-1-parser.zip",
23+
"raml-1-parser": "https://github.com/raml-org/raml-js-parser-2/releases/download/1.1.6/raml-1-parser.zip",
2424
"resolve-url": "~0.2.1",
2525
"slug": "~0.8.0",
2626
"velocity": "~1.1.0",

dist/scripts/api-console.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,25 +744,34 @@
744744
isNestedProperty: '=',
745745
hideTypeLinks: '=',
746746
hidePropertyDetails: '=',
747-
showExamples: '='
747+
showExamples: '=',
748+
showSecuritySchemaProperties: '='
748749
},
749750
controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
750751
if (!Array.isArray($scope.list)) {
751752
$scope.listArray = Object.keys($scope.list).map(function (key) {
752753
return $scope.list[key];
753754
});
754755

755-
$scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.list);
756+
$scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.listArray);
756757
} else {
757758
$scope.listArray = $scope.list;
758759
}
759760

761+
var getArrayTypes = function(arrayType) {
762+
if (arrayType.items.type || Array.isArray(arrayType.items.type)) {
763+
return arrayType.items.type;
764+
}
765+
766+
return [arrayType.items];
767+
};
768+
760769
$scope.getType = function (type) {
761770
var newType = $scope.mergeType(type);
762771
newType.type = RAML.Inspector.Types.ensureArray(newType.type);
763772

764773
if (newType.type[0] === 'array') {
765-
newType.type = newType.items.type.map(function (aType) {
774+
newType.type = getArrayTypes(newType).map(function (aType) {
766775
return aType + '[]';
767776
});
768777
newType.properties = newType.items.properties;
@@ -771,6 +780,14 @@
771780
return newType;
772781
};
773782

783+
var isPattern = function (propertyName) {
784+
return propertyName.match(PATTERN_PATTERN);
785+
};
786+
787+
$scope.isPropertyVisible = function(property) {
788+
return ($scope.showSecuritySchemaProperties || !property[0].isFromSecurityScheme) && !isPattern(property[0].displayName);
789+
};
790+
774791
$scope.mergeType = function (type) {
775792
var newType = angular.copy(type);
776793

@@ -782,10 +799,6 @@
782799

783800
$scope.isNativeType = RAML.Inspector.Types.isNativeType;
784801

785-
$scope.isPattern = function (propertyName) {
786-
return propertyName.match(PATTERN_PATTERN);
787-
};
788-
789802
$scope.isSchema = RAML.Inspector.Types.isSchema;
790803

791804
$scope.isCollapsible = function isCollapsible(property) {
@@ -6518,16 +6531,16 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
65186531
" <li class=\"raml-console-documentation-scheme\" ng-class=\"{'raml-console-is-active':isSchemeSelected(value)}\" ng-click=\"selectDocumentationScheme(value)\" ng-repeat=\"(key, value) in securitySchemes\">{{value.name}}</li>\n" +
65196532
" </ol>\n" +
65206533
"\n" +
6521-
" <p ng-if\"documentationSchemeSelected.description\" markdown=\"documentationSchemeSelected.description\" class=\"raml-console-marked-content\"></p>\n" +
6534+
" <p ng-if=\"documentationSchemeSelected.description\" markdown=\"documentationSchemeSelected.description\" class=\"raml-console-marked-content\"></p>\n" +
65226535
"\n" +
65236536
" <section class=\"raml-console-resource-section raml-console-scheme-headers\" ng-if=\"documentationSchemeSelected.describedBy.headers\">\n" +
65246537
" <h4 class=\"raml-console-resource-heading-a\">Headers</h4>\n" +
6525-
" <properties list=\"documentationSchemeSelected.describedBy.headers\" show-examples=\"true\"></properties>\n" +
6538+
" <properties list=\"documentationSchemeSelected.describedBy.headers\" show-security-schema-properties=\"true\" show-examples=\"true\"></properties>\n" +
65266539
" </section>\n" +
65276540
"\n" +
65286541
" <section class=\"raml-console-resource-section raml-console-scheme-query-parameters\" ng-if=\"documentationSchemeSelected.describedBy.queryParameters\">\n" +
65296542
" <h4 class=\"raml-console-resource-heading-a\">Query Parameters</h4>\n" +
6530-
" <properties list=\"documentationSchemeSelected.describedBy.queryParameters\" show-examples=\"true\"></properties>\n" +
6543+
" <properties list=\"documentationSchemeSelected.describedBy.queryParameters\" show-security-schema-properties=\"true\" show-examples=\"true\"></properties>\n" +
65316544
" </section>\n" +
65326545
"\n" +
65336546
" <section class=\"raml-console-resource-section raml-console-scheme-responses\" ng-if=\"documentationSchemeSelected.describedBy.responses\">\n" +
@@ -6727,7 +6740,9 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67276740

67286741
$templateCache.put('directives/properties.tpl.html',
67296742
"<div>\n" +
6730-
" <div class=\"raml-console-resource-param\" ng-repeat=\"property in listArray\" ng-if=\"!property[0].isFromSecurityScheme && !isPattern(property[0].displayName)\" ng-init=\"vm.isCollapsed = !!collapsible\">\n" +
6743+
" <div class=\"raml-console-resource-param\" ng-repeat=\"property in listArray\"\n" +
6744+
" ng-if=\"isPropertyVisible(property)\"\n" +
6745+
" ng-init=\"vm.isCollapsed = !!collapsible\">\n" +
67316746
" <div ng-init=\"type = getType(property[0])\">\n" +
67326747
" <h4 class=\"raml-console-resource-param-heading\" style=\"position: relative\">\n" +
67336748
" <span ng-if=\"isCollapsible(type)\" ng-click=\"vm.isCollapsed = !vm.isCollapsed\" style=\"cursor: pointer\">{{ vm.isCollapsed ? '▶' : '▼' }}</span>&nbsp;{{type.displayName}}\n" +

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-console",
3-
"version": "3.0.9",
3+
"version": "3.0.10",
44
"description": "Api-Console for RAML based app",
55
"files": [
66
"dist",

src/app/directives/documentation.tpl.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ <h3 class="raml-console-resource-heading-a">Security Schemes</h3>
3636
<li class="raml-console-documentation-scheme" ng-class="{'raml-console-is-active':isSchemeSelected(value)}" ng-click="selectDocumentationScheme(value)" ng-repeat="(key, value) in securitySchemes">{{value.name}}</li>
3737
</ol>
3838

39-
<p ng-if"documentationSchemeSelected.description" markdown="documentationSchemeSelected.description" class="raml-console-marked-content"></p>
39+
<p ng-if="documentationSchemeSelected.description" markdown="documentationSchemeSelected.description" class="raml-console-marked-content"></p>
4040

4141
<section class="raml-console-resource-section raml-console-scheme-headers" ng-if="documentationSchemeSelected.describedBy.headers">
4242
<h4 class="raml-console-resource-heading-a">Headers</h4>
43-
<properties list="documentationSchemeSelected.describedBy.headers" show-examples="true"></properties>
43+
<properties list="documentationSchemeSelected.describedBy.headers" show-security-schema-properties="true" show-examples="true"></properties>
4444
</section>
4545

4646
<section class="raml-console-resource-section raml-console-scheme-query-parameters" ng-if="documentationSchemeSelected.describedBy.queryParameters">
4747
<h4 class="raml-console-resource-heading-a">Query Parameters</h4>
48-
<properties list="documentationSchemeSelected.describedBy.queryParameters" show-examples="true"></properties>
48+
<properties list="documentationSchemeSelected.describedBy.queryParameters" show-security-schema-properties="true" show-examples="true"></properties>
4949
</section>
5050

5151
<section class="raml-console-resource-section raml-console-scheme-responses" ng-if="documentationSchemeSelected.describedBy.responses">

src/app/directives/properties.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,34 @@
1414
isNestedProperty: '=',
1515
hideTypeLinks: '=',
1616
hidePropertyDetails: '=',
17-
showExamples: '='
17+
showExamples: '=',
18+
showSecuritySchemaProperties: '='
1819
},
1920
controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
2021
if (!Array.isArray($scope.list)) {
2122
$scope.listArray = Object.keys($scope.list).map(function (key) {
2223
return $scope.list[key];
2324
});
2425

25-
$scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.list);
26+
$scope.listArray = RAML.Inspector.Properties.normalizeNamedParameters($scope.listArray);
2627
} else {
2728
$scope.listArray = $scope.list;
2829
}
2930

31+
var getArrayTypes = function(arrayType) {
32+
if (arrayType.items.type || Array.isArray(arrayType.items.type)) {
33+
return arrayType.items.type;
34+
}
35+
36+
return [arrayType.items];
37+
};
38+
3039
$scope.getType = function (type) {
3140
var newType = $scope.mergeType(type);
3241
newType.type = RAML.Inspector.Types.ensureArray(newType.type);
3342

3443
if (newType.type[0] === 'array') {
35-
newType.type = newType.items.type.map(function (aType) {
44+
newType.type = getArrayTypes(newType).map(function (aType) {
3645
return aType + '[]';
3746
});
3847
newType.properties = newType.items.properties;
@@ -41,6 +50,15 @@
4150
return newType;
4251
};
4352

53+
var isPattern = function (propertyName) {
54+
return propertyName.match(PATTERN_PATTERN);
55+
};
56+
57+
$scope.isPropertyVisible = function(property) {
58+
return ($scope.showSecuritySchemaProperties || !property[0].isFromSecurityScheme)
59+
&& !isPattern(property[0].displayName);
60+
};
61+
4462
$scope.mergeType = function (type) {
4563
var newType = angular.copy(type);
4664

@@ -52,10 +70,6 @@
5270

5371
$scope.isNativeType = RAML.Inspector.Types.isNativeType;
5472

55-
$scope.isPattern = function (propertyName) {
56-
return propertyName.match(PATTERN_PATTERN);
57-
};
58-
5973
$scope.isSchema = RAML.Inspector.Types.isSchema;
6074

6175
$scope.isCollapsible = function isCollapsible(property) {

src/app/directives/properties.tpl.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div>
2-
<div class="raml-console-resource-param" ng-repeat="property in listArray" ng-if="!property[0].isFromSecurityScheme && !isPattern(property[0].displayName)" ng-init="vm.isCollapsed = !!collapsible">
2+
<div class="raml-console-resource-param" ng-repeat="property in listArray"
3+
ng-if="isPropertyVisible(property)"
4+
ng-init="vm.isCollapsed = !!collapsible">
35
<div ng-init="type = getType(property[0])">
46
<h4 class="raml-console-resource-param-heading" style="position: relative">
57
<span ng-if="isCollapsible(type)" ng-click="vm.isCollapsed = !vm.isCollapsed" style="cursor: pointer">{{ vm.isCollapsed ? '▶' : '▼' }}</span>&nbsp;{{type.displayName}}

test/regression/assertions/resource.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ function Resource (poName) {
5151
});
5252
};
5353

54+
this.ifShowingSecuritySchemaHeaders = function (resource, method, expectedNOfHeaders, expectedHeaders) {
55+
var button = this.po.getMethodBtn(resource, method);
56+
button.click();
57+
58+
var headers = this.po.getSecuritySchemeHeaderTitles(resource);
59+
var numberOfHeaders = headers.count();
60+
61+
expect(numberOfHeaders).toBe(expectedNOfHeaders);
62+
for(var i = 0; i < expectedHeaders.length; i++) {
63+
expect(headers.get(i).getInnerHtml()).toContain(expectedHeaders[i]);
64+
}
65+
};
66+
5467
this.ifCredentialsUpdateBetweenResources = function () {
5568
var resourcesGetButton= this.po.getMethodBtn(0, 0);
5669
var pageObject = this.po;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>API Console</title>
7+
<link href="styles/api-console-light-theme.css" rel="stylesheet" class="theme">
8+
</head>
9+
<body ng-app="ramlConsoleApp" ng-cloak class="raml-console-body">
10+
<raml-console-loader src="raml/security-schema-resource.raml"></raml-console-loader>
11+
<script src="scripts/api-console-vendor.js"></script>
12+
<script src="scripts/api-console.js"></script>
13+
<script type="text/javascript">
14+
$.noConflict();
15+
</script>
16+
</body>
17+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#%RAML 0.8
2+
title: My REST API
3+
version: v1
4+
5+
securitySchemes:
6+
- Custom:
7+
type: x-custom
8+
describedBy:
9+
headers:
10+
Authorization:
11+
description: This header MUST be included in all requests that require authentication/authorization. The auth scheme is using a JSON Web Token Bearer Token as the header value. See [JWT](http://jwt.io/introduction/) for an introduction to JWT. (Though you don't really need to know anything about it)
12+
type: string
13+
required: true
14+
responses:
15+
400:
16+
description: Bad request
17+
401:
18+
description: Unauthorized
19+
403:
20+
description: Forbidden. You are not authorized to access this resource
21+
22+
/endpoint:
23+
get:
24+
securedBy: [ Custom ]

test/regression/page_objects/resourcePO.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ function ResourcesPO () {
4141
this.getSecuritySchemes = function (index) {
4242
return this.resources.get(index+1).all(by.tagName('option'));
4343
};
44+
45+
this.getSecuritySchemeHeaderTitles = function (index) {
46+
return this.resources.get(index+1).all(by.css('.raml-console-resource-param-heading'));
47+
};
48+
4449
this.getUsernameField = function () {
4550
return element(by.name('username'));
4651
};
52+
4753
this.getPasswordField = function () {
4854
return element(by.name('password'));
4955
};
56+
5057
this.getCloseBtn = function (index) {
5158
return this.resources.get(index+1).all(by.css('.raml-console-resource-close-btn'));
5259
};

0 commit comments

Comments
 (0)