146146 Object . keys ( schemas )
147147 . map ( extractSchema )
148148 . filter ( isValidSchema )
149- . forEach ( function ( schema ) { copyToCodesIfNotPresent ( codes , schema . describedBy . responses ) ; } ) ;
149+ . forEach ( function ( schema ) {
150+ copyToCodesIfNotPresent ( codes , schema . describedBy . responses ) ;
151+ } ) ;
150152
151153 return codes ;
152154 }
693695 scope : {
694696 src : '=' ,
695697 context : '=' ,
698+ types : '=' ,
696699 type : '@' ,
697700 title : '@'
698701 } ,
14791482 scope : {
14801483 context : '=' ,
14811484 type : '=' ,
1485+ types : '=' ,
14821486 model : '=' ,
14831487 param : '='
14841488 } ,
26912695 var errors ;
26922696
26932697 value = typeof value !== 'undefined' && value !== null && value . length === 0 ? undefined : value ;
2694- current [ validation . id ] = value ;
2698+ current [ validationId ] = value ;
26952699
26962700 errors = validator ( sanitizer ( current ) ) . errors ;
26972701
27002704 // Note: We want to allow invalid errors for testing purposes
27012705 return value ;
27022706 } else {
2703- clear ( control , validationRules [ validation . id ] ) ;
2707+ clear ( control , validationRules [ validationId ] ) ;
27042708 return value ;
27052709 }
27062710 }
27072711
27082712 var validation = $parse ( $attrs . validate ) ( $scope ) ;
2713+ var validationId = validation . id ;
27092714 var sanitationRules = { } ;
27102715 var validationRules = { } ;
27112716 var control = $ctrl ;
27122717
2713- sanitationRules [ validation . id ] = {
2718+ if ( validation && validation . type ) {
2719+ var declaredType = RAML . Inspector . Types . findType ( validation . type [ 0 ] , $scope . types ) ;
2720+ if ( declaredType ) { validation = declaredType ; }
2721+ }
2722+
2723+ sanitationRules [ validationId ] = {
27142724 type : validation . type || null ,
27152725 repeat : validation . repeat || null
27162726 } ;
27172727
2718- sanitationRules [ validation . id ] = RAML . Utils . filterEmpty ( sanitationRules [ validation . id ] ) ;
2728+ sanitationRules [ validationId ] = RAML . Utils . filterEmpty ( sanitationRules [ validationId ] ) ;
27192729
2720- validationRules [ validation . id ] = {
2730+ validationRules [ validationId ] = {
27212731 type : validation . type || null ,
27222732 minLength : validation . minLength || null ,
27232733 maxLength : validation . maxLength || null ,
27292739 repeat : validation . repeat || null
27302740 } ;
27312741
2732- validationRules [ validation . id ] = RAML . Utils . filterEmpty ( validationRules [ validation . id ] ) ;
2742+ validationRules [ validationId ] = RAML . Utils . filterEmpty ( validationRules [ validationId ] ) ;
27332743
27342744 $ctrl . $formatters . unshift ( function ( value ) {
27352745 return validate ( value ) ;
@@ -5743,7 +5753,9 @@ RAML.Inspector = (function() {
57435753 * @return {Boolean }
57445754 */
57455755 var toBoolean = function ( value ) {
5746- return [ 0 , false , '' , '0' , 'false' ] . indexOf ( value ) === - 1 ;
5756+ if ( [ 0 , false , '0' , 'false' ] . indexOf ( value ) !== - 1 ) return false ;
5757+ if ( [ 1 , true , '1' , 'true' ] . indexOf ( value ) !== - 1 ) return true ;
5758+ return null ;
57475759 } ;
57485760
57495761 /**
@@ -5783,7 +5795,7 @@ RAML.Inspector = (function() {
57835795 */
57845796 var returnValue = function ( value ) {
57855797 return value ;
5786- }
5798+ } ;
57875799
57885800 var toUnion = function ( value , key , object , configs ) {
57895801 var any = null ;
@@ -5794,7 +5806,7 @@ RAML.Inspector = (function() {
57945806 } ) ;
57955807
57965808 return any ;
5797- }
5809+ } ;
57985810
57995811 function isNativeType ( typeName ) {
58005812 typeName = typeName . replace ( '[]' , '' ) ;
@@ -6763,7 +6775,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67636775 " </span>\n" +
67646776 " </span>\n" +
67656777 "\n" +
6766- " <raml-field context=\"context\" type=\"type\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
6778+ " <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
67676779 " </p>\n" +
67686780 " </div>\n" +
67696781 "</section>\n"
@@ -7039,7 +7051,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
70397051 " </div>\n" +
70407052 "\n" +
70417053 " <div ng-if=\"param.properties\" style=\"padding-left: 10px\">\n" +
7042- " <raml-field ng-repeat=\"aParam in param.properties\" context=\"context\" type=\"type\" param=\"aParam[0]\" ng-init=\"model[0][aParam[0].name] = [undefined]\" model=\"model[0][aParam[0].name]\"></raml-field>\n" +
7054+ " <raml-field ng-repeat=\"aParam in param.properties\" context=\"context\" type=\"type\" types=\"types\" param=\"aParam[0]\" ng-init=\"model[0][aParam[0].name] = [undefined]\" model=\"model[0][aParam[0].name]\"></raml-field>\n" +
70437055 " </div>\n" +
70447056 "</div>\n"
70457057 ) ;
@@ -7269,7 +7281,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
72697281 "\n" +
72707282 " <named-parameters src=\"methodInfo.headers.plain\" context=\"context\" type=\"headers\" title=\"Headers\" enable-custom-parameters></named-parameters>\n" +
72717283 "\n" +
7272- " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
7284+ " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" types=\"types\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
72737285 "\n" +
72747286 " <section ng-if=\"methodInfo.queryString\">\n" +
72757287 " <header class=\"raml-console-sidebar-row raml-console-sidebar-subheader\">\n" +
@@ -7320,7 +7332,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
73207332 " </span>\n" +
73217333 " </span>\n" +
73227334 "\n" +
7323- " <raml-field context=\"context\" type=\"type\" param=\"param.definitions[0]\" model=\"context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]\"></raml-field>\n" +
7335+ " <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" +
73247336 " </p>\n" +
73257337 " </div>\n" +
73267338 " </div>\n" +
0 commit comments