|
132 | 132 | $scope.documentationSchemeSelected = defaultSchema; |
133 | 133 |
|
134 | 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 | + |
135 | 138 | var codes = {}; |
136 | 139 |
|
137 | 140 | // Copy all method codes |
|
140 | 143 | }); |
141 | 144 |
|
142 | 145 | // Copy schema's code that are not present in the method |
143 | | - Object.keys(schemas).forEach(function (key) { |
144 | | - if (schemas.hasOwnProperty(key)) { copyToCodesIfNotPresent(codes, schemas[key].describedBy.responses) } |
145 | | - }); |
| 146 | + Object.keys(schemas) |
| 147 | + .map(extractSchema) |
| 148 | + .filter(isValidSchema) |
| 149 | + .forEach(function (schema) { copyToCodesIfNotPresent(codes, schema.describedBy.responses) }); |
146 | 150 |
|
147 | 151 | return codes; |
148 | 152 | } |
|
165 | 169 | $scope.fullResponses = mergeResponseCodes($scope.methodInfo.responses || {}, $scope.methodInfo.securitySchemes()); |
166 | 170 | $scope.fullResponseCodes = Object.keys($scope.fullResponses); |
167 | 171 |
|
168 | | - |
169 | 172 | $scope.isSchemeSelected = function isSchemeSelected(scheme) { |
170 | 173 | return scheme.id === $scope.documentationSchemeSelected.id; |
171 | 174 | }; |
|
781 | 784 | showExamples: '=', |
782 | 785 | showSecuritySchemaProperties: '=' |
783 | 786 | }, |
784 | | - controller: function ($scope, $rootScope) { |
| 787 | + controller: ['$scope', '$rootScope', function ($scope, $rootScope) { |
785 | 788 | if (!Array.isArray($scope.list)) { |
786 | 789 | $scope.listArray = Object.keys($scope.list).map(function (key) { |
787 | 790 | return $scope.list[key]; |
|
792 | 795 | $scope.listArray = $scope.list; |
793 | 796 | } |
794 | 797 |
|
| 798 | + var getArrayTypes = function(arrayType) { |
| 799 | + if (arrayType.items.type || Array.isArray(arrayType.items.type)) { |
| 800 | + return arrayType.items.type; |
| 801 | + } |
| 802 | + |
| 803 | + return [arrayType.items]; |
| 804 | + }; |
| 805 | + |
795 | 806 | $scope.getType = function (type) { |
796 | 807 | var newType = $scope.mergeType(type); |
797 | 808 | newType.type = RAML.Inspector.Types.ensureArray(newType.type); |
798 | 809 |
|
799 | 810 | if (newType.type[0] === 'array') { |
800 | | - newType.type = newType.items.type.map(function (aType) { |
| 811 | + newType.type = getArrayTypes(newType).map(function (aType) { |
801 | 812 | return aType + '[]'; |
802 | 813 | }); |
803 | 814 | newType.properties = newType.items.properties; |
|
947 | 958 | $scope.unique = function (arr) { |
948 | 959 | return arr.filter (function (v, i, a) { return a.indexOf (v) === i; }); |
949 | 960 | }; |
950 | | - }, |
| 961 | + }], |
951 | 962 | compile: function (element) { |
952 | 963 | return RecursionHelper.compile(element); |
953 | 964 | } |
954 | 965 | }; |
955 | 966 | }; |
956 | 967 |
|
957 | 968 | angular.module('RAML.Directives') |
958 | | - .directive('properties', RAML.Directives.properties); |
| 969 | + .directive('properties', ['RecursionHelper', RAML.Directives.properties]); |
959 | 970 | })(); |
960 | 971 |
|
961 | 972 | (function () { |
|
1198 | 1209 | } |
1199 | 1210 | }; |
1200 | 1211 | }) |
1201 | | - .controller('RamlConsoleController', function RamlConsoleController( |
1202 | | - $attrs, |
1203 | | - $scope, |
1204 | | - $rootScope, |
1205 | | - $timeout, |
1206 | | - $window |
| 1212 | + .controller('RamlConsoleController', |
| 1213 | + ['$attrs', '$scope', '$rootScope', '$timeout', '$window', function RamlConsoleController( |
| 1214 | + $attrs, $scope, $rootScope, $timeout, $window |
1207 | 1215 | ) { |
1208 | 1216 | $scope.allowUnsafeMarkdown = $attrs.hasOwnProperty('allowUnsafeMarkdown'); |
1209 | 1217 | $scope.collapseAll = collapseAll; |
|
1456 | 1464 | } |
1457 | 1465 | } |
1458 | 1466 | } |
1459 | | - }) |
| 1467 | + }]) |
1460 | 1468 | ; |
1461 | 1469 | })(); |
1462 | 1470 |
|
|
1572 | 1580 | }; |
1573 | 1581 |
|
1574 | 1582 | angular.module('RAML.Directives') |
1575 | | - .directive('ramlField', RAML.Directives.ramlField); |
| 1583 | + .directive('ramlField', ['RecursionHelper', RAML.Directives.ramlField]); |
1576 | 1584 | })(); |
1577 | 1585 |
|
1578 | 1586 | (function () { |
|
1587 | 1595 | controller: 'RamlInitializerController' |
1588 | 1596 | }; |
1589 | 1597 | }) |
1590 | | - .controller('RamlInitializerController', function RamlInitializerController( |
1591 | | - $scope, |
1592 | | - $window, |
1593 | | - ramlParser |
| 1598 | + .controller('RamlInitializerController', ['$scope', '$window', 'ramlParser', function RamlInitializerController( |
| 1599 | + $scope, $window, ramlParser |
1594 | 1600 | ) { |
1595 | 1601 | $scope.vm = { |
1596 | 1602 | codeMirror: { |
|
1672 | 1678 | }); |
1673 | 1679 | }; |
1674 | 1680 | } |
1675 | | - }) |
| 1681 | + }]) |
1676 | 1682 | ; |
1677 | 1683 | })(); |
1678 | 1684 |
|
|
1833 | 1839 | scope: { |
1834 | 1840 | types: '=' |
1835 | 1841 | }, |
1836 | | - controller: function ($scope) { |
| 1842 | + controller: ['$scope', function ($scope) { |
1837 | 1843 | $scope.convertTypes = function () { |
1838 | 1844 | var types = {}; |
1839 | 1845 | $scope.types.forEach(function (type) { |
|
1845 | 1851 | $scope.$watch('types', function () { |
1846 | 1852 | $scope.convertTypes(); |
1847 | 1853 | }); |
1848 | | - } |
| 1854 | + }] |
1849 | 1855 | }; |
1850 | 1856 | }; |
1851 | 1857 |
|
|
2590 | 2596 | scope: { |
2591 | 2597 | type: '=' |
2592 | 2598 | }, |
2593 | | - controller: function ($scope) { |
| 2599 | + controller: ['$scope', function ($scope) { |
2594 | 2600 | $scope.properties = { |
2595 | 2601 | body: [$scope.type] |
2596 | 2602 | }; |
2597 | | - } |
| 2603 | + }] |
2598 | 2604 | }; |
2599 | 2605 | }; |
2600 | 2606 |
|
|
2615 | 2621 | hideTypeLinks: '=', |
2616 | 2622 | items: '=' |
2617 | 2623 | }, |
2618 | | - controller: function ($scope, $rootScope, $timeout) { |
| 2624 | + controller: ['$scope', '$rootScope', '$timeout', function ($scope, $rootScope, $timeout) { |
2619 | 2625 | $scope.typeInfo = RAML.Inspector.Types.getTypeInfo($scope.typeName, $scope.items); |
2620 | 2626 |
|
2621 | 2627 | $scope.closePopover = function () { |
|
2657 | 2663 |
|
2658 | 2664 | $event.stopPropagation(); |
2659 | 2665 | }; |
2660 | | - } |
| 2666 | + }] |
2661 | 2667 | }; |
2662 | 2668 | }; |
2663 | 2669 |
|
|
2744 | 2750 | 'use strict'; |
2745 | 2751 |
|
2746 | 2752 | angular.module('raml', []) |
2747 | | - .factory('ramlParser', function ramlParser( |
| 2753 | + .factory('ramlParser', ['$http', '$q', '$window', function ramlParser( |
2748 | 2754 | $http, |
2749 | 2755 | $q, |
2750 | 2756 | $window |
|
2841 | 2847 | throw new Error('ramlParser: loadPath: loadApi: content: ' + path + ': no such path'); |
2842 | 2848 | } |
2843 | 2849 | } |
2844 | | - }) |
| 2850 | + }]) |
2845 | 2851 | ; |
2846 | 2852 | })(); |
2847 | 2853 |
|
|
0 commit comments