Skip to content

Commit 6e4bd62

Browse files
authored
Merge pull request #473 from mulesoft/develop
Develop
2 parents 93f0480 + 0517576 commit 6e4bd62

File tree

16 files changed

+307
-129
lines changed

16 files changed

+307
-129
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"jszip": "~2.0.0",
2323
"marked": "~0.3.1",
2424
"raml-client-generator": "~0.0.7",
25-
"raml-1-parser": "https://github.com/raml-org/raml-js-parser-2/releases/download/1.1.20/raml-1-parser.zip",
25+
"raml-1-parser": "https://github.com/raml-org/raml-js-parser-2/releases/download/1.1.24/raml-1-parser.zip",
2626
"resolve-url": "~0.2.1",
2727
"slug": "~0.8.0",
2828
"velocity": "~1.1.0",

dist/scripts/api-console-vendor.js

Lines changed: 65 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scripts/api-console.js

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,13 +1425,15 @@
14251425
context = context || bodyContent.definitions[bodyContent.selected];
14261426
}
14271427

1428-
Object.keys(context.plain).map(function (key) {
1429-
var definition = context.plain[key].definitions[0];
1428+
if (context.plain) {
1429+
Object.keys(context.plain).map(function (key) {
1430+
var definition = context.plain[key].definitions[0];
14301431

1431-
if ($scope.isEnum(definition)) {
1432-
context.values[definition.id][0] = getParamType(definition)['enum'][0];
1433-
}
1434-
});
1432+
if ($scope.isEnum(definition)) {
1433+
context.values[definition.id][0] = getParamType(definition)['enum'][0];
1434+
}
1435+
});
1436+
}
14351437

14361438
$scope.isFile = function (param) {
14371439
return param.type === 'file';
@@ -1595,6 +1597,7 @@
15951597

15961598
/**
15971599
* @param {Promise} promise
1600+
* @param {Object} options
15981601
* @param {Boolean} options.isLoadingFromUrl
15991602
*/
16001603
function loadFromPromise(promise, options) {
@@ -2603,7 +2606,7 @@
26032606
};
26042607

26052608
$scope.hasExampleValue = function (value) {
2606-
return typeof value !== 'undefined' ? true : false;
2609+
return typeof value !== 'undefined';
26072610
};
26082611

26092612
$scope.context.forceRequest = false;
@@ -2788,7 +2791,6 @@
27882791
Object.keys(securitySchemes).map(function(key) {
27892792
if (securitySchemes[key].type === $scope.currentSchemeType) {
27902793
scheme = securitySchemes && securitySchemes[key];
2791-
return;
27922794
}
27932795
});
27942796

@@ -2965,6 +2967,19 @@
29652967
$scope.uploadFile = function (event) {
29662968
$scope.context.bodyContent.definitions[$scope.context.bodyContent.selected].value = event.files[0];
29672969
};
2970+
2971+
$scope.hasFormParameters = $scope.context.bodyContent && $scope.context.bodyContent.selected ? $scope.methodInfo.body[$scope.context.bodyContent.selected].hasOwnProperty('formParameters') : undefined;
2972+
2973+
2974+
$scope.getFormModel = function(param) {
2975+
var definitions = $scope.context.bodyContent.definitions[$scope.context.bodyContent.selected];
2976+
if ($scope.hasFormParameters) {
2977+
return definitions.values[param.definitions[0].id];
2978+
} else if (definitions.contentType && param.name) {
2979+
var example = definitions.contentType[param.name].example;
2980+
return example ? [example] : example;
2981+
}
2982+
};
29682983
}]
29692984
};
29702985
};
@@ -5140,12 +5155,17 @@ RAML.Inspector = (function() {
51405155
}
51415156

51425157
switch (contentType) {
5143-
case FORM_URLENCODED:
5144-
case FORM_DATA:
5145-
definitions[contentType] = new RAML.Services.TryIt.NamedParameters(definition.formParameters);
5146-
break;
5147-
default:
5148-
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition);
5158+
case FORM_URLENCODED:
5159+
case FORM_DATA:
5160+
//For RAML 0.8 formParameters should be defined, but for RAML 1.0 properties node
5161+
if (definition.formParameters) {
5162+
definitions[contentType] = new RAML.Services.TryIt.NamedParameters(definition.formParameters);
5163+
} else if (definition.properties) {
5164+
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition.properties);
5165+
}
5166+
break;
5167+
default:
5168+
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition);
51495169
}
51505170
});
51515171
};
@@ -7441,7 +7461,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
74417461
" </section>\n" +
74427462
"\n" +
74437463
"\n" +
7444-
" <section class=\"raml-console-resource-section\" ng-if=\"methodInfo.body\">\n" +
7464+
" <section class=\"raml-console-resource-section raml-console-documentation-body\" ng-if=\"methodInfo.body\">\n" +
74457465
" <h3 class=\"raml-console-resource-heading-a\">\n" +
74467466
" Body\n" +
74477467
" </h3>\n" +
@@ -7455,12 +7475,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
74557475
" <section ng-if=\"value.formParameters\">\n" +
74567476
" <div class=\"raml-console-resource-param\" ng-repeat=\"formParam in value.formParameters\">\n" +
74577477
" <h4 class=\"raml-console-resource-param-heading\">{{formParam[0].displayName}}<span class=\"raml-console-resource-param-instructional\">{{parameterDocumentation(formParam[0])}}</span></h4>\n" +
7458-
"\n" +
74597478
" <p markdown=\"formParam[0].description\" class=\"raml-console-marked-content\"></p>\n" +
7460-
"\n" +
7461-
" <p ng-if=\"formParam[0].example !== undefined\">\n" +
7462-
" <span class=\"raml-console-resource-param-example\"><b>Example:</b> {{formParam[0].example}}</span>\n" +
7463-
" </p>\n" +
74647479
" </div>\n" +
74657480
" </section>\n" +
74667481
"\n" +
@@ -8258,7 +8273,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
82588273
" </select>\n" +
82598274
" </div>\n" +
82608275
"\n" +
8261-
" <div class=\"raml-console-sidebar-row\" ng-switch=\"context.bodyContent.isForm(context.bodyContent.selected)\">\n" +
8276+
" <div class=\"raml-console-sidebar-row raml-console-body-data\" ng-switch=\"context.bodyContent.isForm(context.bodyContent.selected)\">\n" +
82628277
" <div ng-switch-when=\"false\">\n" +
82638278
"\n" +
82648279
" <div ng-switch=\"isFileBody(context.bodyContent.definitions[context.bodyContent.selected])\">\n" +
@@ -8282,16 +8297,35 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
82828297
"\n" +
82838298
"\n" +
82848299
" <div ng-switch-when=\"true\">\n" +
8285-
" <p class=\"raml-console-sidebar-input-container\" ng-repeat=\"param in context.bodyContent.definitions[context.bodyContent.selected].plain\">\n" +
8286-
" <span class=\"raml-console-sidebar-input-tooltip-container\" ng-if=\"param.definitions[0].description\">\n" +
8287-
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-tooltip\"><span class=\"raml-console-visuallyhidden\">Show documentation</span></button>\n" +
8288-
" <span class=\"raml-console-sidebar-tooltip-flyout\">\n" +
8289-
" <span markdown=\"param.definitions[0].description\" class=\"raml-console-marked-content\"></span>\n" +
8290-
" </span>\n" +
8291-
" </span>\n" +
8292-
"\n" +
8293-
" <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]\"></raml-field>\n" +
8294-
" </p>\n" +
8300+
"\n" +
8301+
" <div ng-switch=\"hasFormParameters\">\n" +
8302+
" <div ng-switch-when=\"true\">\n" +
8303+
" <p class=\"raml-console-sidebar-input-container\" ng-repeat=\"param in context.bodyContent.definitions[context.bodyContent.selected].plain\">\n" +
8304+
" <span class=\"raml-console-sidebar-input-tooltip-container\" ng-init=\"paramDescription = param.definitions[0].description\" ng-if=\"paramDescription\">\n" +
8305+
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-tooltip\"><span class=\"raml-console-visuallyhidden\">Show documentation</span></button>\n" +
8306+
" <span class=\"raml-console-sidebar-tooltip-flyout\">\n" +
8307+
" <span markdown=\"paramDescription\" class=\"raml-console-marked-content\"></span>\n" +
8308+
" </span>\n" +
8309+
" </span>\n" +
8310+
"\n" +
8311+
" <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]\"></raml-field>\n" +
8312+
" </p>\n" +
8313+
" </div>\n" +
8314+
"\n" +
8315+
" <div ng-switch-when=\"false\">\n" +
8316+
" <p class=\"raml-console-sidebar-input-container\" ng-repeat=\"(key, param) in context.bodyContent.definitions[context.bodyContent.selected].contentType\">\n" +
8317+
" <span class=\"raml-console-sidebar-input-tooltip-container\" ng-init=\"paramDescription = param.description\" ng-if=\"paramDescription\">\n" +
8318+
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-tooltip\"><span class=\"raml-console-visuallyhidden\">Show documentation</span></button>\n" +
8319+
" <span class=\"raml-console-sidebar-tooltip-flyout\">\n" +
8320+
" <span markdown=\"paramDescription\" class=\"raml-console-marked-content\"></span>\n" +
8321+
" </span>\n" +
8322+
" </span>\n" +
8323+
"\n" +
8324+
" <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param\" model=\"getFormModel(param)\"></raml-field>\n" +
8325+
" </p>\n" +
8326+
" </div>\n" +
8327+
" </div>\n" +
8328+
"\n" +
82958329
" </div>\n" +
82968330
" </div>\n" +
82978331
" </section>\n" +

src/app/directives/documentation.tpl.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h4 class="raml-console-resource-param-heading">{{key}}</h4>
9191
</section>
9292

9393

94-
<section class="raml-console-resource-section" ng-if="methodInfo.body">
94+
<section class="raml-console-resource-section raml-console-documentation-body" ng-if="methodInfo.body">
9595
<h3 class="raml-console-resource-heading-a">
9696
Body
9797
</h3>
@@ -105,12 +105,7 @@ <h4 class="raml-console-request-body-heading">
105105
<section ng-if="value.formParameters">
106106
<div class="raml-console-resource-param" ng-repeat="formParam in value.formParameters">
107107
<h4 class="raml-console-resource-param-heading">{{formParam[0].displayName}}<span class="raml-console-resource-param-instructional">{{parameterDocumentation(formParam[0])}}</span></h4>
108-
109108
<p markdown="formParam[0].description" class="raml-console-marked-content"></p>
110-
111-
<p ng-if="formParam[0].example !== undefined">
112-
<span class="raml-console-resource-param-example"><b>Example:</b> {{formParam[0].example}}</span>
113-
</p>
114109
</div>
115110
</section>
116111

src/app/directives/raml-field.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@
4141
context = context || bodyContent.definitions[bodyContent.selected];
4242
}
4343

44-
Object.keys(context.plain).map(function (key) {
45-
var definition = context.plain[key].definitions[0];
44+
if (context.plain) {
45+
Object.keys(context.plain).map(function (key) {
46+
var definition = context.plain[key].definitions[0];
4647

47-
if ($scope.isEnum(definition)) {
48-
context.values[definition.id][0] = getParamType(definition)['enum'][0];
49-
}
50-
});
48+
if ($scope.isEnum(definition)) {
49+
context.values[definition.id][0] = getParamType(definition)['enum'][0];
50+
}
51+
});
52+
}
5153

5254
$scope.isFile = function (param) {
5355
return param.type === 'file';

src/app/directives/raml-initializer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464

6565
/**
6666
* @param {Promise} promise
67+
* @param {Object} options
6768
* @param {Boolean} options.isLoadingFromUrl
6869
*/
6970
function loadFromPromise(promise, options) {

src/app/directives/sidebar.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
};
326326

327327
$scope.hasExampleValue = function (value) {
328-
return typeof value !== 'undefined' ? true : false;
328+
return typeof value !== 'undefined';
329329
};
330330

331331
$scope.context.forceRequest = false;
@@ -510,7 +510,6 @@
510510
Object.keys(securitySchemes).map(function(key) {
511511
if (securitySchemes[key].type === $scope.currentSchemeType) {
512512
scheme = securitySchemes && securitySchemes[key];
513-
return;
514513
}
515514
});
516515

@@ -687,6 +686,19 @@
687686
$scope.uploadFile = function (event) {
688687
$scope.context.bodyContent.definitions[$scope.context.bodyContent.selected].value = event.files[0];
689688
};
689+
690+
$scope.hasFormParameters = $scope.context.bodyContent && $scope.context.bodyContent.selected ? $scope.methodInfo.body[$scope.context.bodyContent.selected].hasOwnProperty('formParameters') : undefined;
691+
692+
693+
$scope.getFormModel = function(param) {
694+
var definitions = $scope.context.bodyContent.definitions[$scope.context.bodyContent.selected];
695+
if ($scope.hasFormParameters) {
696+
return definitions.values[param.definitions[0].id];
697+
} else if (definitions.contentType && param.name) {
698+
var example = definitions.contentType[param.name].example;
699+
return example ? [example] : example;
700+
}
701+
};
690702
}]
691703
};
692704
};

src/app/directives/sidebar.tpl.html

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h4 class="raml-console-sidebar-subhead">Body</h4>
8787
</select>
8888
</div>
8989

90-
<div class="raml-console-sidebar-row" ng-switch="context.bodyContent.isForm(context.bodyContent.selected)">
90+
<div class="raml-console-sidebar-row raml-console-body-data" ng-switch="context.bodyContent.isForm(context.bodyContent.selected)">
9191
<div ng-switch-when="false">
9292

9393
<div ng-switch="isFileBody(context.bodyContent.definitions[context.bodyContent.selected])">
@@ -111,16 +111,35 @@ <h4 class="raml-console-sidebar-subhead">Body</h4>
111111

112112

113113
<div ng-switch-when="true">
114-
<p class="raml-console-sidebar-input-container" ng-repeat="param in context.bodyContent.definitions[context.bodyContent.selected].plain">
115-
<span class="raml-console-sidebar-input-tooltip-container" ng-if="param.definitions[0].description">
116-
<button tabindex="-1" class="raml-console-sidebar-input-tooltip"><span class="raml-console-visuallyhidden">Show documentation</span></button>
117-
<span class="raml-console-sidebar-tooltip-flyout">
118-
<span markdown="param.definitions[0].description" class="raml-console-marked-content"></span>
119-
</span>
120-
</span>
121-
122-
<raml-field context="context" type="type" types="types" param="param.definitions[0]" model="context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]"></raml-field>
123-
</p>
114+
115+
<div ng-switch="hasFormParameters">
116+
<div ng-switch-when="true">
117+
<p class="raml-console-sidebar-input-container" ng-repeat="param in context.bodyContent.definitions[context.bodyContent.selected].plain">
118+
<span class="raml-console-sidebar-input-tooltip-container" ng-init="paramDescription = param.definitions[0].description" ng-if="paramDescription">
119+
<button tabindex="-1" class="raml-console-sidebar-input-tooltip"><span class="raml-console-visuallyhidden">Show documentation</span></button>
120+
<span class="raml-console-sidebar-tooltip-flyout">
121+
<span markdown="paramDescription" class="raml-console-marked-content"></span>
122+
</span>
123+
</span>
124+
125+
<raml-field context="context" type="type" types="types" param="param.definitions[0]" model="context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]"></raml-field>
126+
</p>
127+
</div>
128+
129+
<div ng-switch-when="false">
130+
<p class="raml-console-sidebar-input-container" ng-repeat="(key, param) in context.bodyContent.definitions[context.bodyContent.selected].contentType">
131+
<span class="raml-console-sidebar-input-tooltip-container" ng-init="paramDescription = param.description" ng-if="paramDescription">
132+
<button tabindex="-1" class="raml-console-sidebar-input-tooltip"><span class="raml-console-visuallyhidden">Show documentation</span></button>
133+
<span class="raml-console-sidebar-tooltip-flyout">
134+
<span markdown="paramDescription" class="raml-console-marked-content"></span>
135+
</span>
136+
</span>
137+
138+
<raml-field context="context" type="type" types="types" param="param" model="getFormModel(param)"></raml-field>
139+
</p>
140+
</div>
141+
</div>
142+
124143
</div>
125144
</div>
126145
</section>

src/common/try_it/body_content.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
}
2020

2121
switch (contentType) {
22-
case FORM_URLENCODED:
23-
case FORM_DATA:
24-
definitions[contentType] = new RAML.Services.TryIt.NamedParameters(definition.formParameters);
25-
break;
26-
default:
27-
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition);
22+
case FORM_URLENCODED:
23+
case FORM_DATA:
24+
//For RAML 0.8 formParameters should be defined, but for RAML 1.0 properties node
25+
if (definition.formParameters) {
26+
definitions[contentType] = new RAML.Services.TryIt.NamedParameters(definition.formParameters);
27+
} else if (definition.properties) {
28+
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition.properties);
29+
}
30+
break;
31+
default:
32+
definitions[contentType] = new RAML.Services.TryIt.BodyType(definition);
2833
}
2934
});
3035
};

test/regression/assertions/resource.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ function Resource (poName) {
170170
var panel = this.po.getResourcePanel(resource);
171171
expect(panel.isPresent()).toBe(isOpen);
172172
};
173+
174+
this.ifDisplayingProperties = function (resource, properties) {
175+
var bodyProperties = this.po.getTryItBodyPanelParameters(resource);
176+
177+
properties.forEach(function (name, index) {
178+
var property = bodyProperties.get(index);
179+
expect(property.getText()).toContain(name);
180+
});
181+
};
173182
}
174183

175184
module.exports = Resource;

0 commit comments

Comments
 (0)