Skip to content

Commit 63386bd

Browse files
authored
Merge branch 'master' into types-bg
2 parents 12bf9e0 + de66d3a commit 63386bd

27 files changed

+396
-103
lines changed

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ module.exports = function (grunt) {
285285

286286
jshint: {
287287
options: {
288-
jshintrc: true
288+
jshintrc: true,
289+
reporterOutput: ''
289290
},
290291

291292
files: [

dist/scripts/api-console.js

Lines changed: 106 additions & 45 deletions
Large diffs are not rendered by default.

dist/styles/api-console-dark-theme.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ ol.raml-console-resources-container-no-title {
17821782
}
17831783

17841784
ol.raml-console-resources-container {
1785-
margin-top: 0px;
1785+
margin-top: 0;
17861786
}
17871787

17881788
.raml-console-resource-level-description {
@@ -1800,13 +1800,15 @@ ol.raml-console-resources-container {
18001800

18011801
.raml-console-resource-response-jump {
18021802
margin-top: 50px;
1803-
position: absolute;
1803+
position: inherit;
18041804
margin-left: 10px;
1805+
margin-bottom: 5px;
1806+
float: left;
18051807
}
18061808

18071809
.raml-console-resource-menu {
18081810
list-style: none;
1809-
padding-left: 0px;
1811+
padding-left: 0;
18101812
margin-top: -5px;
18111813
}
18121814

@@ -2211,7 +2213,7 @@ a.raml-console-resource-path-active {
22112213
.raml-console-resource-heading-flag {
22122214
position: relative;
22132215
top: -1px;
2214-
padding: 0px 3px;
2216+
padding: 0 3px;
22152217
border-radius: 3px;
22162218
background: #0f1217;
22172219
}

dist/styles/api-console-light-theme.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ ol.raml-console-resources-container-no-title {
17821782
}
17831783

17841784
ol.raml-console-resources-container {
1785-
margin-top: 0px;
1785+
margin-top: 0;
17861786
}
17871787

17881788
.raml-console-resource-level-description {
@@ -1800,13 +1800,15 @@ ol.raml-console-resources-container {
18001800

18011801
.raml-console-resource-response-jump {
18021802
margin-top: 50px;
1803-
position: absolute;
1803+
position: inherit;
18041804
margin-left: 10px;
1805+
margin-bottom: 5px;
1806+
float: left;
18051807
}
18061808

18071809
.raml-console-resource-menu {
18081810
list-style: none;
1809-
padding-left: 0px;
1811+
padding-left: 0;
18101812
margin-top: -5px;
18111813
}
18121814

@@ -2211,7 +2213,7 @@ a.raml-console-resource-path-active {
22112213
.raml-console-resource-heading-flag {
22122214
position: relative;
22132215
top: -1px;
2214-
padding: 0px 3px;
2216+
padding: 0 3px;
22152217
border-radius: 3px;
22162218
background: #e3e4e6;
22172219
}

src/app/directives/documentation.js

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,53 @@
55
return {
66
restrict: 'E',
77
templateUrl: 'directives/documentation.tpl.html',
8-
replace: true,
98
controller: ['$scope', function($scope) {
109
var defaultSchemaKey = Object.keys($scope.securitySchemes).sort()[0];
1110
var defaultSchema = $scope.securitySchemes[defaultSchemaKey];
1211

1312
$scope.markedOptions = RAML.Settings.marked;
1413
$scope.documentationSchemeSelected = defaultSchema;
1514

15+
function mergeResponseCodes(methodCodes, schemas) {
16+
var extractSchema = function (key) { return schemas.hasOwnProperty(key) ? schemas[key] : undefined; };
17+
var isValidSchema = function (schema) { return schema.describedBy && schema.describedBy.responses; };
18+
19+
var codes = {};
20+
21+
// Copy all method codes
22+
Object.keys(methodCodes).forEach(function (code) {
23+
if (methodCodes.hasOwnProperty(code)) { codes[code] = methodCodes[code]; }
24+
});
25+
26+
// Copy schema's code that are not present in the method
27+
Object.keys(schemas)
28+
.map(extractSchema)
29+
.filter(isValidSchema)
30+
.forEach(function (schema) {
31+
copyToCodesIfNotPresent(codes, schema.describedBy.responses);
32+
});
33+
34+
return codes;
35+
}
36+
37+
function copyToCodesIfNotPresent(codes, schemaCodes) {
38+
if (Array.isArray(schemaCodes)) {
39+
schemaCodes.forEach(function (response) {
40+
if (!codes.hasOwnProperty(response.code)) {
41+
codes[response.code] = response.code;
42+
}
43+
});
44+
} else {
45+
Object.keys(schemaCodes).forEach(function (code) {
46+
if (schemaCodes.hasOwnProperty(code) && !codes.hasOwnProperty(code)) {
47+
codes[code] = schemaCodes[code];
48+
}
49+
});
50+
}
51+
}
52+
$scope.fullResponses = mergeResponseCodes($scope.methodInfo.responses || {}, $scope.methodInfo.securitySchemes());
53+
$scope.fullResponseCodes = Object.keys($scope.fullResponses);
54+
1655
$scope.isSchemeSelected = function isSchemeSelected(scheme) {
1756
return scheme.id === $scope.documentationSchemeSelected.id;
1857
};
@@ -37,13 +76,13 @@
3776

3877
$scope.currentStatusCode = '200';
3978

40-
if ($scope.methodInfo.responseCodes && $scope.methodInfo.responseCodes.length > 0) {
41-
$scope.currentStatusCode = $scope.methodInfo.responseCodes[0];
79+
if ($scope.fullResponseCodes && $scope.fullResponseCodes.length > 0) {
80+
$scope.currentStatusCode = $scope.fullResponseCodes[0];
4281
}
4382

4483
$scope.$on('resetData', function() {
45-
if ($scope.methodInfo.responseCodes && $scope.methodInfo.responseCodes.length > 0) {
46-
$scope.currentStatusCode = $scope.methodInfo.responseCodes[0];
84+
if ($scope.fullResponseCodes && $scope.fullResponseCodes.length > 0) {
85+
$scope.currentStatusCode = $scope.fullResponseCodes[0];
4786
}
4887
});
4988

@@ -195,7 +234,8 @@
195234
$elements.removeClass('raml-console-is-active');
196235
$container.find('.raml-console-body-' + $scope.getBodyId(value)).addClass('raml-console-is-active');
197236
});
198-
}]
237+
}],
238+
replace: true
199239
};
200240
};
201241

src/app/directives/documentation.tpl.html

Lines changed: 12 additions & 12 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">
@@ -108,7 +108,7 @@ <h4 class="raml-console-resource-param-heading">{{formParam[0].displayName}}<spa
108108
</div>
109109

110110
<!-- Response -->
111-
<div ng-if="methodInfo.responseCodes">
111+
<div ng-if="fullResponseCodes">
112112
<header class="raml-console-resource-header">
113113
<h3 class="raml-console-resource-head">
114114
Response
@@ -117,39 +117,39 @@ <h3 class="raml-console-resource-head">
117117

118118
<div class="raml-console-resource-response-jump">
119119
<ul class="raml-console-resource-menu">
120-
<li class="raml-console-resource-btns raml-console-resource-menu-item" ng-repeat="code in methodInfo.responseCodes">
120+
<li class="raml-console-resource-btns raml-console-resource-menu-item" ng-repeat="code in fullResponseCodes">
121121
<button ng-click="showCodeDetails(code)" class="raml-console-resource-btn raml-console-resource-menu-button raml-console-resource-menu-btn-{{getColorCode(code)}}" ng-class="{ 'raml-console-button-is-active': isActiveCode(code) }" href="#code{{code}}">{{code}}</button>
122122
</li>
123123
</ul>
124124
</div>
125125

126126
<div class="raml-console-resource-panel-primary-row raml-console-resource-panel-content raml-console-is-active raml-console-response-container" ng-class="{'raml-console-is-active':showResponseDocumentation}">
127-
<section ng-if="isActiveCode(code)" class="raml-console-resource-section raml-console-resource-response-section" ng-repeat="code in methodInfo.responseCodes">
127+
<section ng-if="isActiveCode(code)" class="raml-console-resource-section raml-console-resource-response-section" ng-repeat="code in fullResponseCodes">
128128
<a name="code{{code}}"></a>
129129
<h3 class="raml-console-resource-heading-a">Status {{code}}</h3>
130130

131131
<div class="raml-console-resource-response">
132-
<p markdown="methodInfo.responses[code].description" class="raml-console-marked-content"></p>
132+
<p markdown="fullResponses[code].description" class="raml-console-marked-content"></p>
133133
</div>
134134

135-
<div class="raml-console-resource-response" ng-if="methodInfo.responses[code].headers">
135+
<div class="raml-console-resource-response" ng-if="fullResponses[code].headers">
136136
<h4 class="raml-console-resource-body-heading">Headers</h4>
137-
<properties list="methodInfo.responses[code].headers"></properties>
137+
<properties list="fullResponses[code].headers"></properties>
138138
</div>
139139

140-
<div class="raml-console-resource-response" ng-if="methodInfo.responses[code].body">
140+
<div class="raml-console-resource-response" ng-if="fullResponses[code].body">
141141
<h4 class="raml-console-resource-body-heading">
142142
Body
143143
<span
144144
ng-click="changeType($event, key, code)"
145145
ng-class="{ 'raml-console-is-active': responseInfo[code].currentType === key}"
146146
class="raml-console-flag"
147-
ng-repeat="(key, value) in methodInfo.responses[code].body">
147+
ng-repeat="(key, value) in fullResponses[code].body">
148148
{{key}}
149149
</span>
150150
</h4>
151151

152-
<div ng-repeat="(key, value) in methodInfo.responses[code].body">
152+
<div ng-repeat="(key, value) in fullResponses[code].body">
153153
<div ng-if="responseInfo[code].currentType === key">
154154
<examples
155155
ng-if="responseInfo[code] && responseInfo[code].currentType"

src/app/directives/examples.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
return [{
3333
name: 'Example',
3434
content: (typeof exampleContainer.example === 'object') ?
35-
JSON.stringify(exampleContainer.example) : exampleContainer.example
35+
JSON.stringify(exampleContainer.example, null, 2) : exampleContainer.example
3636
}];
3737
} else if (exampleContainer.examples) {
3838
if (Array.isArray(exampleContainer.examples)) {
3939
return exampleContainer.examples.map(function (example, index) {
4040
return {
4141
name: example.name || 'Example ' + index,
42-
content: JSON.stringify(example.value, null, 2)
42+
content: (typeof example.value === 'object') ?
43+
JSON.stringify(example.value, null, 2) : example.value
4344
};
4445
});
4546
} else {

src/app/directives/named-parameters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
scope: {
1010
src: '=',
1111
context: '=',
12+
types: '=',
1213
type: '@',
1314
title: '@'
1415
},

src/app/directives/named-parameters.tpl.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h4 class="raml-console-sidebar-subhead">{{title}}</h4>
77
<div class="raml-console-sidebar-row">
88
<p class="raml-console-sidebar-input-container raml-console-sidebar-input-container-custom" ng-repeat="customParam in context.customParameters[type]">
99
<button class="raml-console-sidebar-input-delete" ng-click="removeCutomParam(customParam)"></button>
10-
<label for="custom-header" class="raml-console-sidebar-label raml-console-sidebar-label-custom">
10+
<label class="raml-console-sidebar-label raml-console-sidebar-label-custom">
1111
<input class="raml-console-sidebar-custom-input-for-label" ng-model="customParam.name" placeholder="custom key">
1212
</label>
1313
<input name="custom-header" class="raml-console-sidebar-input raml-console-sidebar-input-custom" placeholder="custom value" ng-model="customParam.value">
@@ -30,7 +30,7 @@ <h4 class="raml-console-sidebar-subhead">{{title}}</h4>
3030
</span>
3131
</span>
3232

33-
<raml-field context="context" type="type" param="param.definitions[0]" model="context[type].values[param.definitions[0].id]"></raml-field>
33+
<raml-field context="context" type="type" types="types" param="param.definitions[0]" model="context[type].values[param.definitions[0].id]"></raml-field>
3434
</p>
3535
</div>
3636
</section>

src/app/directives/properties.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
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
}
@@ -49,6 +50,14 @@
4950
return newType;
5051
};
5152

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) && !isPattern(property[0].displayName);
59+
};
60+
5261
$scope.mergeType = function (type) {
5362
var newType = angular.copy(type);
5463

@@ -60,10 +69,6 @@
6069

6170
$scope.isNativeType = RAML.Inspector.Types.isNativeType;
6271

63-
$scope.isPattern = function (propertyName) {
64-
return propertyName.match(PATTERN_PATTERN);
65-
};
66-
6772
$scope.isSchema = RAML.Inspector.Types.isSchema;
6873

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

0 commit comments

Comments
 (0)