124124 return {
125125 restrict : 'E' ,
126126 templateUrl : 'directives/documentation.tpl.html' ,
127- replace : true ,
128127 controller : [ '$scope' , function ( $scope ) {
129128 var defaultSchemaKey = Object . keys ( $scope . securitySchemes ) . sort ( ) [ 0 ] ;
130129 var defaultSchema = $scope . securitySchemes [ defaultSchemaKey ] ;
131130
132131 $scope . markedOptions = RAML . Settings . marked ;
133132 $scope . documentationSchemeSelected = defaultSchema ;
134133
134+ function mergeResponseCodes ( methodCodes , schemas ) {
135+ var extractSchema = function ( key ) { return schemas . hasOwnProperty ( key ) ? schemas [ key ] : undefined ; } ;
136+ var isValidSchema = function ( schema ) { return schema . describedBy && schema . describedBy . responses ; } ;
137+
138+ var codes = { } ;
139+
140+ // Copy all method codes
141+ Object . keys ( methodCodes ) . forEach ( function ( code ) {
142+ if ( methodCodes . hasOwnProperty ( code ) ) { codes [ code ] = methodCodes [ code ] ; }
143+ } ) ;
144+
145+ // Copy schema's code that are not present in the method
146+ Object . keys ( schemas )
147+ . map ( extractSchema )
148+ . filter ( isValidSchema )
149+ . forEach ( function ( schema ) {
150+ copyToCodesIfNotPresent ( codes , schema . describedBy . responses ) ;
151+ } ) ;
152+
153+ return codes ;
154+ }
155+
156+ function copyToCodesIfNotPresent ( codes , schemaCodes ) {
157+ if ( Array . isArray ( schemaCodes ) ) {
158+ schemaCodes . forEach ( function ( response ) {
159+ if ( ! codes . hasOwnProperty ( response . code ) ) {
160+ codes [ response . code ] = response . code ;
161+ }
162+ } ) ;
163+ } else {
164+ Object . keys ( schemaCodes ) . forEach ( function ( code ) {
165+ if ( schemaCodes . hasOwnProperty ( code ) && ! codes . hasOwnProperty ( code ) ) {
166+ codes [ code ] = schemaCodes [ code ] ;
167+ }
168+ } ) ;
169+ }
170+ }
171+ $scope . fullResponses = mergeResponseCodes ( $scope . methodInfo . responses || { } , $scope . methodInfo . securitySchemes ( ) ) ;
172+ $scope . fullResponseCodes = Object . keys ( $scope . fullResponses ) ;
173+
135174 $scope . isSchemeSelected = function isSchemeSelected ( scheme ) {
136175 return scheme . id === $scope . documentationSchemeSelected . id ;
137176 } ;
156195
157196 $scope . currentStatusCode = '200' ;
158197
159- if ( $scope . methodInfo . responseCodes && $scope . methodInfo . responseCodes . length > 0 ) {
160- $scope . currentStatusCode = $scope . methodInfo . responseCodes [ 0 ] ;
198+ if ( $scope . fullResponseCodes && $scope . fullResponseCodes . length > 0 ) {
199+ $scope . currentStatusCode = $scope . fullResponseCodes [ 0 ] ;
161200 }
162201
163202 $scope . $on ( 'resetData' , function ( ) {
164- if ( $scope . methodInfo . responseCodes && $scope . methodInfo . responseCodes . length > 0 ) {
165- $scope . currentStatusCode = $scope . methodInfo . responseCodes [ 0 ] ;
203+ if ( $scope . fullResponseCodes && $scope . fullResponseCodes . length > 0 ) {
204+ $scope . currentStatusCode = $scope . fullResponseCodes [ 0 ] ;
166205 }
167206 } ) ;
168207
314353 $elements . removeClass ( 'raml-console-is-active' ) ;
315354 $container . find ( '.raml-console-body-' + $scope . getBodyId ( value ) ) . addClass ( 'raml-console-is-active' ) ;
316355 } ) ;
317- } ]
356+ } ] ,
357+ replace : true
318358 } ;
319359 } ;
320360
30693109 return new RAML . Client . AuthStrategies . Oauth2 ( scheme , credentials ) ;
30703110 case 'OAuth 1.0' :
30713111 return new RAML . Client . AuthStrategies . Oauth1 ( scheme , credentials ) ;
3112+ case 'Pass Through' :
3113+ return RAML . Client . AuthStrategies . anonymous ( ) ;
30723114 case 'x-custom' :
30733115 return RAML . Client . AuthStrategies . anonymous ( ) ;
30743116 case 'Anonymous' :
@@ -6280,14 +6322,15 @@ RAML.Inspector = (function() {
62806322 * @return {Object }
62816323 */
62826324 return function ( value , key , object ) {
6283- // Short-circuit validation if the value is `null`.
6284- if ( value == null ) {
6285- return toValidationObject ( isOptional , 'required' , value , key ) ;
6286- }
62876325
62886326 // Switch validation type depending on if the value is an array or not.
62896327 var isArray = Array . isArray ( value ) ;
62906328
6329+ // Short-circuit validation if empty value
6330+ if ( value == null || ( isArray && value . length === 0 ) ) {
6331+ return toValidationObject ( isOptional , 'required' , value , key ) ;
6332+ }
6333+
62916334 // Select the validation stack to use based on the (repeated) value.
62926335 var values = isArray ? value : [ value ] ;
62936336 var validations = isArray ? repeatValidations : simpleValidations ;
@@ -6603,7 +6646,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
66036646 " </div>\n" +
66046647 "\n" +
66056648 " <!-- Response -->\n" +
6606- " <div ng-if=\"methodInfo.responseCodes \">\n" +
6649+ " <div ng-if=\"fullResponseCodes \">\n" +
66076650 " <header class=\"raml-console-resource-header\">\n" +
66086651 " <h3 class=\"raml-console-resource-head\">\n" +
66096652 " Response\n" +
@@ -6612,39 +6655,39 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
66126655 "\n" +
66136656 " <div class=\"raml-console-resource-response-jump\">\n" +
66146657 " <ul class=\"raml-console-resource-menu\">\n" +
6615- " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6658+ " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in fullResponseCodes \">\n" +
66166659 " <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>\n" +
66176660 " </li>\n" +
66186661 " </ul>\n" +
66196662 " </div>\n" +
66206663 "\n" +
66216664 " <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}\">\n" +
6622- " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6665+ " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in fullResponseCodes \">\n" +
66236666 " <a name=\"code{{code}}\"></a>\n" +
66246667 " <h3 class=\"raml-console-resource-heading-a\">Status {{code}}</h3>\n" +
66256668 "\n" +
66266669 " <div class=\"raml-console-resource-response\">\n" +
6627- " <p markdown=\"methodInfo.responses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
6670+ " <p markdown=\"fullResponses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
66286671 " </div>\n" +
66296672 "\n" +
6630- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].headers\">\n" +
6673+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].headers\">\n" +
66316674 " <h4 class=\"raml-console-resource-body-heading\">Headers</h4>\n" +
6632- " <properties list=\"methodInfo.responses [code].headers\"></properties>\n" +
6675+ " <properties list=\"fullResponses [code].headers\"></properties>\n" +
66336676 " </div>\n" +
66346677 "\n" +
6635- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].body\">\n" +
6678+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].body\">\n" +
66366679 " <h4 class=\"raml-console-resource-body-heading\">\n" +
66376680 " Body\n" +
66386681 " <span\n" +
66396682 " ng-click=\"changeType($event, key, code)\"\n" +
66406683 " ng-class=\"{ 'raml-console-is-active': responseInfo[code].currentType === key}\"\n" +
66416684 " class=\"raml-console-flag\"\n" +
6642- " ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6685+ " ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66436686 " {{key}}\n" +
66446687 " </span>\n" +
66456688 " </h4>\n" +
66466689 "\n" +
6647- " <div ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6690+ " <div ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66486691 " <div ng-if=\"responseInfo[code].currentType === key\">\n" +
66496692 " <examples\n" +
66506693 " ng-if=\"responseInfo[code] && responseInfo[code].currentType\"\n" +
@@ -6708,7 +6751,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67086751 " <div class=\"raml-console-sidebar-row\">\n" +
67096752 " <p class=\"raml-console-sidebar-input-container raml-console-sidebar-input-container-custom\" ng-repeat=\"customParam in context.customParameters[type]\">\n" +
67106753 " <button class=\"raml-console-sidebar-input-delete\" ng-click=\"removeCutomParam(customParam)\"></button>\n" +
6711- " <label for=\"custom-header\" class=\"raml-console-sidebar-label raml-console-sidebar-label-custom\">\n" +
6754+ " <label class=\"raml-console-sidebar-label raml-console-sidebar-label-custom\">\n" +
67126755 " <input class=\"raml-console-sidebar-custom-input-for-label\" ng-model=\"customParam.name\" placeholder=\"custom key\">\n" +
67136756 " </label>\n" +
67146757 " <input name=\"custom-header\" class=\"raml-console-sidebar-input raml-console-sidebar-input-custom\" placeholder=\"custom value\" ng-model=\"customParam.value\">\n" +
0 commit comments