refactor(ui): replace `$resource` with `$http`; it was trying to be too clever with JSON Schemas
MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperResourceImpl.java
@@ -74,9 +74,7 @@ public class DeveloperResourceImpl implements IDeveloperResource, DataAccessUtil
IStorage storage,
IStorageQuery query,
ISecurityContext securityContext,
- ContractService contractService,
- ApiService apiService,
- ClientAppService clientService
+ ApiService apiService
) {
this.storage = storage;
this.query = query;

MODIFY
manager/ui/war/package.json
manager/ui/war/package.json
"harmon": "^1.4.4",
"jquery": "3.5.1",
"js-logger": "1.6.1",
- "json-editor": "0.7.23",
+ "@json-editor/json-editor": "2.6.0",
"lodash": "^4.17.15",
"moment": "2.29.1",
"ng-file-upload": "9.1.1",

MODIFY
manager/ui/war/plugins/api-manager/ts/apimanPlugin.ts
manager/ui/war/plugins/api-manager/ts/apimanPlugin.ts
@@ -6,7 +6,6 @@ window.jQuery = $;
window.$ = $;
import 'bootstrap/dist/js/bootstrap.js';
import 'bootstrap-select/dist/js/bootstrap-select.js';
-import 'json-editor';
import 'patternfly/dist/js/patternfly.js';
import 'angular';
import 'angular-ui-bootstrap/ui-bootstrap.js';

MODIFY
manager/ui/war/plugins/api-manager/ts/policies.ts
manager/ui/war/plugins/api-manager/ts/policies.ts
import { _module } from './apimanPlugin';
import angular = require("angular");
import moment = require("moment");
+import { JSONEditor } from '@json-editor/json-editor/dist/jsoneditor'
export var isRegexpValid = function(v) {
var valid = true;
@@ -44,9 +45,9 @@ _module.controller('Apiman.JsonSchemaPolicyConfigFormController',
$scope.isEntityDisabled = EntityStatusSvc.isEntityDisabled;
var initEditor = function(schema) {
- var holder = document.getElementById('json-editor-holder');
+ const holder = document.getElementById('json-editor-holder');
- var editor = new window['JSONEditor'](holder, {
+ const editor = new JSONEditor(holder, {
// Disable fetching schemas via ajax
ajax: false,
// The schema for the editor
@@ -96,16 +97,19 @@ _module.controller('Apiman.JsonSchemaPolicyConfigFormController',
var pluginId = $scope.selectedDef.pluginId;
var policyDefId = $scope.selectedDef.id;
- PluginSvcs.getPolicyForm(pluginId, policyDefId, function(schema) {
+ PluginSvcs.getPolicyForm(pluginId, policyDefId).then(
+ (schema: string) => {
destroyEditor();
initEditor(schema);
$scope.editor.setValue($scope.config);
$scope.schemaState = 'loaded';
- }, function (error) {
+ },
+ error => {
// TODO handle the error better here!
Logger.error(error);
$scope.schemaState = 'loaded';
- });
+ }
+ );
};
// Watch for changes to selectedDef - if the user changes from one schema-based policy

MODIFY
manager/ui/war/plugins/api-manager/ts/rpc.ts
manager/ui/war/plugins/api-manager/ts/rpc.ts
@@ -221,14 +221,18 @@ _module.factory('UserAuditSvcs', ['$resource', 'Configuration',
}]);
-_module.factory('PluginSvcs', ['$resource', 'Configuration',
- function($resource, Configuration) {
+_module.factory('PluginSvcs', ['$http', 'Configuration', '$q',
+ function($http, Configuration, $q) {
return {
- getPolicyForm: function(pluginId, policyDefId, handler, errorHandler) {
- var endpoint = Configuration.api.endpoint + '/plugins/:pluginId/policyDefs/:policyDefId/form';
- $resource(endpoint, { pluginId: '@pluginId', policyDefId: '@policyDefId' }).get(
- {pluginId: pluginId, policyDefId: policyDefId},
- handler, errorHandler);
+ getPolicyForm: function(pluginId, policyDefId): Promise<string> {
+ const endpoint = `${Configuration.api.endpoint}/plugins/${pluginId}/policyDefs/${policyDefId}/form`;
+ return $http({
+ method: 'GET',
+ url: endpoint
+ }).then(
+ ok => $q.resolve(ok.data),
+ failure => $q.reject(failure)
+ );
}
}
}]);

MODIFY
manager/ui/war/yarn.lock
manager/ui/war/yarn.lock
dependencies:
"@hapi/hoek" "^9.0.0"
+"@json-editor/json-editor@2.6.0":
+ version "2.6.0"
+ resolved "https://registry.yarnpkg.com/@json-editor/json-editor/-/json-editor-2.6.0.tgz#ee4d687c4ca4794f4ac9246f61fcc01cb3e48c38"
+ integrity sha512-6yWvdpBirBENLdRKSfoCbEzQycZrqegSiWYkRV2X7n9F4PwULmQB0GPuG/7A2FJzwKM8m/Vpz6ywOBNE8jY9dw==
+ dependencies:
+ core-js "^3.12.1"
+
"@kyleshockey/object-assign-deep@^0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@kyleshockey/object-assign-deep/-/object-assign-deep-0.4.2.tgz#84900f0eefc372798f4751b5262830b8208922ec"
@@ -2111,6 +2118,11 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==
+core-js@^3.12.1:
+ version "3.19.0"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.0.tgz#9e40098a9bc326c7e81b486abbd5e12b9d275176"
+ integrity sha512-L1TpFRWXZ76vH1yLM+z6KssLZrP8Z6GxxW4auoCj+XiViOzNPJCAuTIkn03BGdFe6Z5clX5t64wRIRypsZQrUg==
+
core-util-is@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -4929,11 +4941,6 @@ jsesc@^0.5.0:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
integrity sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=
-json-editor@0.7.23:
- version "0.7.23"
- resolved "https://registry.yarnpkg.com/json-editor/-/json-editor-0.7.23.tgz#87e5f4e855c7c69f8a2fb83ffd09dfb564c5a6e5"
- integrity sha1-h+X06FXHxp+KL7g//QnftWTFpuU=
-
json-parse-better-errors@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"

refactor(ui): replace `$resource` with `$http`; it was trying to be too clever with JSON Schemas