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
@@ -6585,7 +6612,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
65856612 " </div>\n" +
65866613 "\n" +
65876614 " <!-- Response -->\n" +
6588- " <div ng-if=\"methodInfo.responseCodes \">\n" +
6615+ " <div ng-if=\"fullResponseCodes \">\n" +
65896616 " <header class=\"raml-console-resource-header\">\n" +
65906617 " <h3 class=\"raml-console-resource-head\">\n" +
65916618 " Response\n" +
@@ -6594,39 +6621,39 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
65946621 "\n" +
65956622 " <div class=\"raml-console-resource-response-jump\">\n" +
65966623 " <ul class=\"raml-console-resource-menu\">\n" +
6597- " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6624+ " <li class=\"raml-console-resource-btns raml-console-resource-menu-item\" ng-repeat=\"code in fullResponseCodes \">\n" +
65986625 " <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" +
65996626 " </li>\n" +
66006627 " </ul>\n" +
66016628 " </div>\n" +
66026629 "\n" +
66036630 " <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" +
6604- " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in methodInfo.responseCodes \">\n" +
6631+ " <section ng-if=\"isActiveCode(code)\" class=\"raml-console-resource-section raml-console-resource-response-section\" ng-repeat=\"code in fullResponseCodes \">\n" +
66056632 " <a name=\"code{{code}}\"></a>\n" +
66066633 " <h3 class=\"raml-console-resource-heading-a\">Status {{code}}</h3>\n" +
66076634 "\n" +
66086635 " <div class=\"raml-console-resource-response\">\n" +
6609- " <p markdown=\"methodInfo.responses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
6636+ " <p markdown=\"fullResponses [code].description\" class=\"raml-console-marked-content\"></p>\n" +
66106637 " </div>\n" +
66116638 "\n" +
6612- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].headers\">\n" +
6639+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].headers\">\n" +
66136640 " <h4 class=\"raml-console-resource-body-heading\">Headers</h4>\n" +
6614- " <properties list=\"methodInfo.responses [code].headers\"></properties>\n" +
6641+ " <properties list=\"fullResponses [code].headers\"></properties>\n" +
66156642 " </div>\n" +
66166643 "\n" +
6617- " <div class=\"raml-console-resource-response\" ng-if=\"methodInfo.responses [code].body\">\n" +
6644+ " <div class=\"raml-console-resource-response\" ng-if=\"fullResponses [code].body\">\n" +
66186645 " <h4 class=\"raml-console-resource-body-heading\">\n" +
66196646 " Body\n" +
66206647 " <span\n" +
66216648 " ng-click=\"changeType($event, key, code)\"\n" +
66226649 " ng-class=\"{ 'raml-console-is-active': responseInfo[code].currentType === key}\"\n" +
66236650 " class=\"raml-console-flag\"\n" +
6624- " ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6651+ " ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66256652 " {{key}}\n" +
66266653 " </span>\n" +
66276654 " </h4>\n" +
66286655 "\n" +
6629- " <div ng-repeat=\"(key, value) in methodInfo.responses [code].body\">\n" +
6656+ " <div ng-repeat=\"(key, value) in fullResponses [code].body\">\n" +
66306657 " <div ng-if=\"responseInfo[code].currentType === key\">\n" +
66316658 " <examples\n" +
66326659 " ng-if=\"responseInfo[code] && responseInfo[code].currentType\"\n" +
0 commit comments