1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/services/addon-service-test-simple-addon.ts
olav fdebeef929
feat: add OpenAPI validation to a few endpoints (#1409)
* feat: add OpenAPI validation to a few endpoints (2)

* refactor: use package version as the OpenAPI version

* refactor: keep the existing OpenAPI page for now

* refactor: add snapshots tests for the OpenAPI output

* refactor: validate Content-Type by default

* refactor: update vulnerable deps

* refactor: fix documentation URL to match schema

* refactor: improve external type declaration

* refactor: remove unused package resolutions

* refactor: try express-openapi fork

* Update package.json

* Update src/lib/services/openapi-service.ts

* Update src/lib/types/openapi.d.ts

* Update src/lib/types/openapi.d.ts

Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2022-04-25 14:17:59 +02:00

76 lines
1.8 KiB
TypeScript

import Addon from '../addons/addon';
import getLogger from '../../test/fixtures/no-logger';
import { IAddonDefinition } from '../types/model';
import {
FEATURE_ARCHIVED,
FEATURE_CREATED,
FEATURE_REVIVED,
FEATURE_UPDATED,
IEvent,
} from '../types/events';
const definition: IAddonDefinition = {
name: 'simple',
displayName: 'Simple ADdon',
description: 'Some description',
parameters: [
{
name: 'url',
displayName: 'Some URL',
type: 'url',
required: true,
sensitive: false,
},
{
name: 'var',
displayName: 'Some var',
description: 'Some variable to inject',
type: 'text',
required: false,
sensitive: false,
},
{
name: 'sensitiveParam',
displayName: 'Some sensitive param',
description: 'Some variable to inject',
type: 'text',
required: false,
sensitive: true,
},
],
documentationUrl: 'https://www.example.com',
events: [
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
],
tagTypes: [
{
name: 'me',
description: 'Some tag',
icon: 'm',
},
],
};
export default class SimpleAddon extends Addon {
events: any[];
constructor() {
super(definition, { getLogger });
this.events = [];
}
getEvents(): any[] {
return this.events;
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
async handleEvent(event: IEvent, parameters: any): Promise<void> {
this.events.push({
event,
parameters,
});
}
}