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' ;
15951597
15961598 /**
15971599 * @param {Promise } promise
1600+ * @param {Object } options
15981601 * @param {Boolean } options.isLoadingFromUrl
15991602 */
16001603 function loadFromPromise ( promise , options ) {
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 ;
27882791 Object . keys ( securitySchemes ) . map ( function ( key ) {
27892792 if ( securitySchemes [ key ] . type === $scope . currentSchemeType ) {
27902793 scheme = securitySchemes && securitySchemes [ key ] ;
2791- return ;
27922794 }
27932795 } ) ;
27942796
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" +
0 commit comments