Skip to content

Commit 3b5b041

Browse files
authored
Merge pull request #524 from mulesoft/3.x.x/develop
3.x.x/develop
2 parents 1f1f9ea + 7d8fc14 commit 3b5b041

File tree

9 files changed

+304
-9
lines changed

9 files changed

+304
-9
lines changed

dist/scripts/api-console.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,30 @@
20502050
return methodInfo;
20512051
}
20522052

2053+
function expandQueryParameters($scope, methodInfo) {
2054+
function expandDescriptions(queryParameters) {
2055+
Object.keys(queryParameters).forEach(function (key) {
2056+
var param = queryParameters[key][0];
2057+
var type = param.type ? RAML.Inspector.Types.findType(param.type[0], $scope.types) : undefined;
2058+
if (!param.description && type && type.description) {
2059+
param.description = type.description;
2060+
}
2061+
});
2062+
}
2063+
2064+
if (methodInfo.queryParameters) {
2065+
expandDescriptions(methodInfo.queryParameters);
2066+
}
2067+
return methodInfo;
2068+
}
2069+
2070+
function expand($scope, methodInfo) {
2071+
methodInfo = expandBodyExamples($scope, methodInfo);
2072+
methodInfo = expandQueryParameters($scope, methodInfo);
2073+
2074+
return methodInfo;
2075+
}
2076+
20532077
return function showResource($scope, resource, $event, $index) {
20542078
var methodInfo = $index === null ? $scope.methodInfo : resource.methods[$index];
20552079
var oldId = $rootScope.currentId;
@@ -2062,7 +2086,7 @@
20622086
$scope.currentMethod = methodInfo.method;
20632087
$scope.resource = resource;
20642088

2065-
$scope.methodInfo = expandBodyExamples($scope, methodInfo);
2089+
$scope.methodInfo = expand($scope, methodInfo);
20662090
$scope.responseInfo = getResponseInfo($scope);
20672091
$scope.context = new RAML.Services.TryIt.Context($scope.raml.baseUriParameters, resource, $scope.methodInfo, $scope.types);
20682092
$scope.requestUrl = '';
@@ -4958,12 +4982,16 @@ RAML.Inspector = (function() {
49584982
return type.properties;
49594983
}
49604984

4985+
function getType(type) {
4986+
return type.type ? (Array.isArray(type.type) ? type.type[0] : getType(type.type)) : type.type;
4987+
}
4988+
49614989
function mergeType(type, types) {
49624990
var resultingType = angular.copy(type);
49634991
resultingType.type = resultingType.type || resultingType.schema;
49644992
var properties = angular.copy(resultingType.properties || {});
4965-
var currentType = Array.isArray(resultingType.type) ?
4966-
resultingType.type[0] : resultingType.type;
4993+
4994+
var currentType = getType(resultingType);
49674995

49684996
properties = convertProperties(resultingType);
49694997

src/app/directives/resource-tree/show-resource.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,30 @@
106106
return methodInfo;
107107
}
108108

109+
function expandQueryParameters($scope, methodInfo) {
110+
function expandDescriptions(queryParameters) {
111+
Object.keys(queryParameters).forEach(function (key) {
112+
var param = queryParameters[key][0];
113+
var type = param.type ? RAML.Inspector.Types.findType(param.type[0], $scope.types) : undefined;
114+
if (!param.description && type && type.description) {
115+
param.description = type.description;
116+
}
117+
});
118+
}
119+
120+
if (methodInfo.queryParameters) {
121+
expandDescriptions(methodInfo.queryParameters);
122+
}
123+
return methodInfo;
124+
}
125+
126+
function expand($scope, methodInfo) {
127+
methodInfo = expandBodyExamples($scope, methodInfo);
128+
methodInfo = expandQueryParameters($scope, methodInfo);
129+
130+
return methodInfo;
131+
}
132+
109133
return function showResource($scope, resource, $event, $index) {
110134
var methodInfo = $index === null ? $scope.methodInfo : resource.methods[$index];
111135
var oldId = $rootScope.currentId;
@@ -118,7 +142,7 @@
118142
$scope.currentMethod = methodInfo.method;
119143
$scope.resource = resource;
120144

121-
$scope.methodInfo = expandBodyExamples($scope, methodInfo);
145+
$scope.methodInfo = expand($scope, methodInfo);
122146
$scope.responseInfo = getResponseInfo($scope);
123147
$scope.context = new RAML.Services.TryIt.Context($scope.raml.baseUriParameters, resource, $scope.methodInfo, $scope.types);
124148
$scope.requestUrl = '';

src/common/inspector/types.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@
8989
return type.properties;
9090
}
9191

92+
function getType(type) {
93+
return type.type ? (Array.isArray(type.type) ? type.type[0] : getType(type.type)) : type.type;
94+
}
95+
9296
function mergeType(type, types) {
9397
var resultingType = angular.copy(type);
9498
resultingType.type = resultingType.type || resultingType.schema;
9599
var properties = angular.copy(resultingType.properties || {});
96-
var currentType = Array.isArray(resultingType.type) ?
97-
resultingType.type[0] : resultingType.type;
100+
101+
var currentType = getType(resultingType);
98102

99103
properties = convertProperties(resultingType);
100104

test/regression/assertions/resource.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,30 @@ function Resource (poName) {
117117
var button = this.po.getMethodBtn(resource, method);
118118
button.click();
119119

120-
var queryParameters = this.po.getQueryParameterDetails(resource);
120+
var queryParameters = this.po.getQueryParametersDetail(resource);
121121
var queryParameter = queryParameters.get(queryParameterPosition);
122122

123123
expect(queryParameter.getText()).toMatch(/default: false/);
124124
};
125125

126126
this.ifShowingQueryParametersInCorrectOrder = function (resource, queryParametersName) {
127-
var queryParameters = this.po.getQueryParameterDetails(resource);
127+
var queryParameters = this.po.getQueryParametersDetail(resource);
128128

129129
queryParametersName.forEach(function(name, index) {
130130
var queryParameter = queryParameters.get(index);
131131
expect(queryParameter.getText()).toContain(name);
132132
});
133133
};
134134

135+
this.ifShowingParametersDescription = function (resource, queryParametersDescription) {
136+
var queryParameters = this.po.getQueryParametersDescription(resource);
137+
138+
queryParametersDescription.forEach(function(description, index) {
139+
var queryParameter = queryParameters.get(index);
140+
expect(queryParameter.getText()).toContain(description);
141+
});
142+
};
143+
135144
this.ifShowingTypesPropertiesInCorrectOrder = function (type, queryParametersName) {
136145
this.po.toggleRootType(type);
137146

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/external-library.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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#%RAML 1.0
2+
title: Stores Data Network API
3+
version: v1
4+
baseUri: http://api.lbi.com
5+
uses:
6+
Common: store-types.raml
7+
8+
types:
9+
brandNameType:
10+
type: string
11+
description: brand name like BBW VSS LZA
12+
enum: [
13+
"CORP",
14+
"BBW",
15+
"BPR",
16+
"BBC",
17+
"VSS",
18+
"VSC",
19+
"VUK",
20+
"VPR",
21+
"LZA",
22+
"LZU"
23+
]
24+
required: true
25+
26+
27+
/storesDataNetwork:
28+
post:
29+
queryParameters:
30+
brandName:
31+
type: Common.brandNameType
32+
brandName2:
33+
type: string
34+
description: brand name like BBW VSS LZA
35+
enum: [
36+
"CORP",
37+
"BBW",
38+
"BPR",
39+
"BBC",
40+
"VSS",
41+
"VSC",
42+
"VUK",
43+
"VPR",
44+
"LZA",
45+
"LZU"
46+
]
47+
required: true
48+
brandName3:
49+
type: brandNameType
50+
body:
51+
application/xml:
52+
53+
responses:
54+
200:
55+
body:
56+
application/json:
57+
example: |
58+
{
59+
"message" : "Hello World"
60+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#%RAML 1.0
2+
title: Stores Data Network API
3+
types:
4+
brandNameType:
5+
type: string
6+
description: brand name like BBW VSS LZA
7+
enum: [
8+
"CORP",
9+
"BBW",
10+
"BPR",
11+
"BBC",
12+
"VSS",
13+
"VSC",
14+
"VUK",
15+
"VPR",
16+
"LZA",
17+
"LZU"
18+
]
19+
required: true
20+
entityTypeType:
21+
type: string
22+
description: entity type
23+
enum: [
24+
"BACKOFFICELOAD",
25+
"CMDEXECUTEENTITY",
26+
"DIMP",
27+
"Parameter",
28+
"SOF",
29+
"Sample",
30+
"TRIGGERMESSAGE",
31+
"CENTRALOFFICEDWLOAD",
32+
"DIMP",
33+
"POSLOG",
34+
"EJOURNAL"
35+
]
36+
required: true
37+
entityNameType:
38+
type: string
39+
description: entity name
40+
enum: [
41+
"StoreHierarchyImport",
42+
"MerchandiseHierarchyImport",
43+
"MerchandiseHierarchyItemImport",
44+
"ItemImport",
45+
"InitialItemImport",
46+
"SeedServiceItemImport",
47+
"RedLineItemImport",
48+
"PriceImport",
49+
"InitialPriceImport",
50+
"TaxImport",
51+
"EmployeeImport",
52+
"ASSOC_PUNCH_GUARD_PARAMS",
53+
"HOURS_OF_OPERATION",
54+
"RoleSecurityMatrix",
55+
"RoleSecurityMatrixInitial",
56+
"Parameter",
57+
"VPOS",
58+
"ParameterRegisters",
59+
"ParameterInitial",
60+
"VPOSParameterInitial",
61+
"ParameterInitialRegisters",
62+
"RETRY",
63+
"CMDEXECUTEENTITY",
64+
"EmployeeForm",
65+
"Interface",
66+
"TRAFFIC",
67+
"ASMA",
68+
"ASMU",
69+
"PAY",
70+
"TA",
71+
"TRUEUP",
72+
"CERTIFICATION",
73+
"CLOCKHISTORY",
74+
"CSM_SHIFT",
75+
"STOREEVENT",
76+
"FINALPAY",
77+
"POSLOG",
78+
"EJOURNAL"]
79+
required: true
80+
responseTypeType:
81+
description: response type of jms response message if needed (used for batch stuff)
82+
enum: [
83+
"xml",
84+
"map"
85+
]
86+
required: false
87+
batchIDType:
88+
description: batch id 1234 or some such
89+
type: string
90+
required: true
91+
batchSequenceIDType:
92+
description: sequence number or EOB for end of batch
93+
type: string
94+
pattern: (\d+|EOB)
95+
required: true
96+
processDefinitionIDType:
97+
type: integer
98+
description: process definition id for the data
99+
required: true
100+
processInstanceIDType:
101+
type: string
102+
description: unique process instance of the data
103+
required: true
104+
configTypeType:
105+
type: string
106+
description: routing config type DEFAULT
107+
configNameType:
108+
type: string
109+
description: config name to lookup the key
110+
example: STORE, BRAND, DISTRICT,REFSITE
111+
configKeyType:
112+
type: string
113+
description: config key like store # or ref site #
114+
example: 1234 (STORE), BBW (for Brand), 9971 (refsite)
115+
routeToHomeOfficeType:
116+
description: does this data need to be sent to homeoffice too (as is Central Office POS App)
117+
type: boolean
118+
required: false
119+
responseQueueType:
120+
description: response queue for jms mesage if desired for batch stuff
121+
type: string
122+
required: false
123+
messageEffectiveDateTimeType:
124+
description: message effective date at store locale Time Zones are ignored for now
125+
type: datetime-only
126+
required: false
127+
messageExpirationDateTimeType:
128+
description: message expiration date at store locale TIme zones are ignored for now
129+
type: datetime-only
130+
required: false
131+
lastSequenceType:
132+
type: boolean
133+
required: false
134+
default: false
135+
description: indicates end of batch by setting to true if feasible

test/regression/page_objects/resourcePO.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ function ResourcesPO () {
7474
return this.resources.get(index+1).all(by.css('.raml-console-resource-close-btn'));
7575
};
7676

77-
this.getQueryParameterDetails = function (index) {
77+
this.getQueryParametersDetail = function (index) {
7878
return this.resources.get(index+1).all(by.css('.raml-console-resource-param-heading'));
7979
};
8080

81+
this.getQueryParametersDescription = function (index) {
82+
return this.resources.get(index+1).element(by.id('docs-query-parameters')).all(by.css('.raml-console-marked-content'));
83+
};
84+
8185
this.getTryItQueryParameterInput = function (resourceIndex, inputIndex) {
8286
return this.resources.get(resourceIndex+1).all(by.css('.raml-console-sidebar-content-wrapper .raml-console-sidebar-input')).get(inputIndex);
8387
};

0 commit comments

Comments
 (0)