132132 $scope . markedOptions = RAML . Settings . marked ;
133133 $scope . documentationSchemeSelected = defaultSchema ;
134134
135+ function mergeResponseCodes ( methodCodes , schemas ) {
136+ var codes = { } ;
137+
138+ // Copy all method codes
139+ Object . keys ( methodCodes ) . forEach ( function ( code ) {
140+ if ( methodCodes . hasOwnProperty ( code ) ) { codes [ code ] = methodCodes [ code ] ; }
141+ } ) ;
142+
143+ // Copy schema's code that are not present in the method
144+ Object . keys ( schemas ) . forEach ( function ( key ) {
145+ if ( schemas . hasOwnProperty ( key ) ) { copyToCodesIfNotPresent ( codes , schemas [ key ] . describedBy . responses ) }
146+ } ) ;
147+
148+ return codes ;
149+ }
150+
151+ function copyToCodesIfNotPresent ( codes , schemaCodes ) {
152+ Object . keys ( schemaCodes ) . forEach ( function ( code ) {
153+ if ( schemaCodes . hasOwnProperty ( code ) && ! codes . hasOwnProperty ( code ) ) {
154+ codes [ code ] = schemaCodes [ code ] ;
155+ }
156+ } ) ;
157+ }
158+ $scope . fullResponses = mergeResponseCodes ( $scope . methodInfo . responses || { } , $scope . methodInfo . securitySchemes ( ) ) ;
159+ $scope . fullResponseCodes = Object . keys ( $scope . fullResponses ) ;
160+
161+
135162 $scope . isSchemeSelected = function isSchemeSelected ( scheme ) {
136163 return scheme . id === $scope . documentationSchemeSelected . id ;
137164 } ;
156183
157184 $scope . currentStatusCode = '200' ;
158185
159- if ( $scope . methodInfo . responseCodes && $scope . methodInfo . responseCodes . length > 0 ) {
160- $scope . currentStatusCode = $scope . methodInfo . responseCodes [ 0 ] ;
186+ if ( $scope . fullResponseCodes && $scope . fullResponseCodes . length > 0 ) {
187+ $scope . currentStatusCode = $scope . fullResponseCodes [ 0 ] ;
161188 }
162189
163190 $scope . $on ( 'resetData' , function ( ) {
164- if ( $scope . methodInfo . responseCodes && $scope . methodInfo . responseCodes . length > 0 ) {
165- $scope . currentStatusCode = $scope . methodInfo . responseCodes [ 0 ] ;
191+ if ( $scope . fullResponseCodes && $scope . fullResponseCodes . length > 0 ) {
192+ $scope . currentStatusCode = $scope . fullResponseCodes [ 0 ] ;
166193 }
167194 } ) ;
168195
@@ -6591,7 +6618,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
65916618 " </div>\n" +
65926619 "\n" +
65936620 " <!-- Response -->\n" +
6594- " <div ng-if=\"methodInfo.responseCodes \">\n" +
6621+ " <div ng-if=\"fullResponseCodes \">\n" +
65956622 " <header class=\"raml-console-resource-header\">\n" +
65966623 " <h3 class=\"raml-console-resource-head\">\n" +
65976624 " Response\n" +
@@ -6600,39 +6627,39 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
66006627 "\n" +
66016628 " <div class=\"raml-console-resource-response-jump\">\n" +
66026629 " <ul class=\"raml-console-resource-menu\">\n" +
6603- " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6630+ " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in fullResponseCodes \">\n" +
66046631 " <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" +
66056632 " </li>\n" +
66066633 " </ul>\n" +
66076634 " </div>\n" +
66086635 "\n" +
66096636 " <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" +
6610- " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6637+ " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in fullResponseCodes \">\n" +
66116638 " <a name=\"code{{code}}\"></a>\n" +
66126639 " <h3 class=\"raml-console-resource-heading-a\">Status {{code}}</h3>\n" +
66136640 "\n" +
66146641 " <div class=\"raml-console-resource-response\">\n" +
6615- " <p markdown=\"methodInfo.responses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
6642+ " <p markdown=\"fullResponses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
66166643 " </div>\n" +
66176644 "\n" +
6618- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].headers\">\n" +
6645+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].headers\">\n" +
66196646 " <h4 class=\"raml-console-resource-body-heading\">Headers</h4>\n" +
6620- " <properties list=\"methodInfo.responses [code].headers\"></properties>\n" +
6647+ " <properties list=\"fullResponses [code].headers\"></properties>\n" +
66216648 " </div>\n" +
66226649 "\n" +
6623- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].body\">\n" +
6650+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].body\">\n" +
66246651 " <h4 class=\"raml-console-resource-body-heading\">\n" +
66256652 " Body\n" +
66266653 " <span\n" +
66276654 " ng-click=\"changeType($event, key, code)\"\n" +
66286655 " ng-class=\"{ 'raml-console-is-active': responseInfo[code].currentType === key}\"\n" +
66296656 " class=\"raml-console-flag\"\n" +
6630- " ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6657+ " ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66316658 " {{key}}\n" +
66326659 " </span>\n" +
66336660 " </h4>\n" +
66346661 "\n" +
6635- " <div ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6662+ " <div ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66366663 " <div ng-if=\"responseInfo[code].currentType === key\">\n" +
66376664 " <examples\n" +
66386665 " ng-if=\"responseInfo[code] && responseInfo[code].currentType\"\n" +
0 commit comments