Skip to content

Commit a3025c9

Browse files
author
Carolina Wright
committed
Merge branch 'master' into bugs/response-codes-panel
2 parents 241ee1d + b7dce72 commit a3025c9

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
@@ -743,25 +743,34 @@
743743
isNestedProperty: '=',
744744
hideTypeLinks: '=',
745745
hidePropertyDetails: '=',
746-
showExamples: '='
746+
showExamples: '=',
747+
showSecuritySchemaProperties: '='
747748
},
748749
controller: ['$scope', '$rootScope', function ($scope, $rootScope) {
749750
if (!Array.isArray($scope.list)) {
750751
$scope.listArray = Object.keys($scope.list).map(function (key) {
751752
return $scope.list[key];
752753
});
753754

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

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

763772
if (newType.type[0] === 'array') {
764-
newType.type = newType.items.type.map(function (aType) {
773+
newType.type = getArrayTypes(newType).map(function (aType) {
765774
return aType + '[]';
766775
});
767776
newType.properties = newType.items.properties;
@@ -770,6 +779,14 @@
770779
return newType;
771780
};
772781

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

@@ -781,10 +798,6 @@
781798

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

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

790803
$scope.isCollapsible = function isCollapsible(property) {
@@ -6508,16 +6521,16 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
65086521
" <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" +
65096522
" </ol>\n" +
65106523
"\n" +
6511-
" <p ng-if\"documentationSchemeSelected.description\" markdown=\"documentationSchemeSelected.description\" class=\"raml-console-marked-content\"></p>\n" +
6524+
" <p ng-if=\"documentationSchemeSelected.description\" markdown=\"documentationSchemeSelected.description\" class=\"raml-console-marked-content\"></p>\n" +
65126525
"\n" +
65136526
" <section class=\"raml-console-resource-section raml-console-scheme-headers\" ng-if=\"documentationSchemeSelected.describedBy.headers\">\n" +
65146527
" <h4 class=\"raml-console-resource-heading-a\">Headers</h4>\n" +
6515-
" <properties list=\"documentationSchemeSelected.describedBy.headers\" show-examples=\"true\"></properties>\n" +
6528+
" <properties list=\"documentationSchemeSelected.describedBy.headers\" show-security-schema-properties=\"true\" show-examples=\"true\"></properties>\n" +
65166529
" </section>\n" +
65176530
"\n" +
65186531
" <section class=\"raml-console-resource-section raml-console-scheme-query-parameters\" ng-if=\"documentationSchemeSelected.describedBy.queryParameters\">\n" +
65196532
" <h4 class=\"raml-console-resource-heading-a\">Query Parameters</h4>\n" +
6520-
" <properties list=\"documentationSchemeSelected.describedBy.queryParameters\" show-examples=\"true\"></properties>\n" +
6533+
" <properties list=\"documentationSchemeSelected.describedBy.queryParameters\" show-security-schema-properties=\"true\" show-examples=\"true\"></properties>\n" +
65216534
" </section>\n" +
65226535
"\n" +
65236536
" <section class=\"raml-console-resource-section raml-console-scheme-responses\" ng-if=\"documentationSchemeSelected.describedBy.responses\">\n" +
@@ -6717,7 +6730,9 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67176730

67186731
$templateCache.put('directives/properties.tpl.html',
67196732
"<div>\n" +
6720-
" <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" +
6733+
" <div class=\"raml-console-resource-param\" ng-repeat=\"property in listArray\"\n" +
6734+
" ng-if=\"isPropertyVisible(property)\"\n" +
6735+
" ng-init=\"vm.isCollapsed = !!collapsible\">\n" +
67216736
" <div ng-init=\"type = getType(property[0])\">\n" +
67226737
" <h4 class=\"raml-console-resource-param-heading\" style=\"position: relative\">\n" +
67236738
" <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)