2022-06-22 12:49:18 +02:00
import { FromSchema } from 'json-schema-to-ts' ;
import { addonSchema } from './addon-schema' ;
import { addonTypeSchema } from './addon-type-schema' ;
import { addonParameterSchema } from './addon-parameter-schema' ;
import { tagTypeSchema } from './tag-type-schema' ;
export const addonsSchema = {
$id : '#/components/schemas/addonsSchema' ,
type : 'object' ,
required : [ 'addons' , 'providers' ] ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
description : ` An object containing two things:
1 . A list of all [ addons ] ( https : //docs.getunleash.io/reference/addons) defined on this Unleash instance
2 . A list of all addon providers defined on this instance ` ,
2022-06-22 12:49:18 +02:00
properties : {
addons : {
type : 'array' ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
description :
'All the addons that exist on this instance of Unleash.' ,
2022-06-22 12:49:18 +02:00
items : {
$ref : '#/components/schemas/addonSchema' ,
} ,
} ,
providers : {
type : 'array' ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
description :
'A list of all available addon providers, along with their parameters and descriptions.' ,
example : [
{
name : 'webhook' ,
displayName : 'Webhook' ,
description :
'A Webhook is a generic way to post messages from Unleash to third party services.' ,
documentationUrl :
'https://docs.getunleash.io/docs/addons/webhook' ,
parameters : [
{
name : 'url' ,
displayName : 'Webhook URL' ,
description :
'(Required) Unleash will perform a HTTP Post to the specified URL (one retry if first attempt fails)' ,
type : 'url' ,
required : true ,
sensitive : true ,
} ,
{
name : 'contentType' ,
displayName : 'Content-Type' ,
placeholder : 'application/json' ,
description :
'(Optional) The Content-Type header to use. Defaults to "application/json".' ,
type : 'text' ,
required : false ,
sensitive : false ,
} ,
{
name : 'authorization' ,
displayName : 'Authorization' ,
placeholder : '' ,
description :
'(Optional) The Authorization header to use. Not used if left blank.' ,
type : 'text' ,
required : false ,
sensitive : true ,
} ,
{
name : 'bodyTemplate' ,
displayName : 'Body template' ,
2023-09-20 10:21:30 +02:00
placeholder : ` {
"event" : "{{event.type}}" ,
"createdBy" : "{{event.createdBy}}" ,
"featureToggle" : "{{event.data.name}}" ,
"timestamp" : "{{event.data.createdAt}}"
} ` ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
description :
"(Optional) You may format the body using a mustache template. If you don't specify anything, the format will similar to the events format (https://docs.getunleash.io/reference/api/legacy/unleash/admin/events)" ,
type : 'textfield' ,
required : false ,
sensitive : false ,
} ,
] ,
events : [
'feature-created' ,
'feature-updated' ,
'feature-archived' ,
'feature-revived' ,
'feature-stale-on' ,
'feature-stale-off' ,
'feature-environment-enabled' ,
'feature-environment-disabled' ,
'feature-strategy-remove' ,
'feature-strategy-update' ,
'feature-strategy-add' ,
'feature-metadata-updated' ,
'feature-variants-updated' ,
'feature-project-change' ,
'feature-tagged' ,
'feature-untagged' ,
'change-request-created' ,
'change-request-discarded' ,
'change-added' ,
'change-discarded' ,
'change-request-approved' ,
'change-request-approval-added' ,
'change-request-cancelled' ,
'change-request-sent-to-review' ,
'change-request-applied' ,
] ,
} ,
{
name : 'slack' ,
displayName : 'Slack' ,
description : 'Allows Unleash to post updates to Slack.' ,
documentationUrl :
'https://docs.getunleash.io/docs/addons/slack' ,
parameters : [
{
name : 'url' ,
displayName : 'Slack webhook URL' ,
description : '(Required)' ,
type : 'url' ,
required : true ,
sensitive : true ,
} ,
{
name : 'username' ,
displayName : 'Username' ,
placeholder : 'Unleash' ,
description :
'The username to use when posting messages to slack. Defaults to "Unleash".' ,
type : 'text' ,
required : false ,
sensitive : false ,
} ,
{
name : 'emojiIcon' ,
displayName : 'Emoji Icon' ,
placeholder : ':unleash:' ,
description :
'The emoji_icon to use when posting messages to slack. Defaults to ":unleash:".' ,
type : 'text' ,
required : false ,
sensitive : false ,
} ,
{
name : 'defaultChannel' ,
displayName : 'Default channel' ,
description :
'(Required) Default channel to post updates to if not specified in the slack-tag' ,
type : 'text' ,
required : true ,
sensitive : false ,
} ,
] ,
events : [
'feature-created' ,
'feature-updated' ,
'feature-archived' ,
'feature-revived' ,
'feature-stale-on' ,
'feature-stale-off' ,
'feature-environment-enabled' ,
'feature-environment-disabled' ,
'feature-strategy-remove' ,
'feature-strategy-update' ,
'feature-strategy-add' ,
'feature-metadata-updated' ,
'feature-variants-updated' ,
'feature-project-change' ,
] ,
tagTypes : [
{
name : 'slack' ,
description :
'Slack tag used by the slack-addon to specify the slack channel.' ,
icon : 'S' ,
} ,
] ,
} ,
{
name : 'teams' ,
displayName : 'Microsoft Teams' ,
description :
'Allows Unleash to post updates to Microsoft Teams.' ,
documentationUrl :
'https://docs.getunleash.io/docs/addons/teams' ,
parameters : [
{
name : 'url' ,
displayName : 'Microsoft Teams webhook URL' ,
description : '(Required)' ,
type : 'url' ,
required : true ,
sensitive : true ,
} ,
] ,
events : [
'feature-created' ,
'feature-updated' ,
'feature-archived' ,
'feature-revived' ,
'feature-stale-on' ,
'feature-stale-off' ,
'feature-environment-enabled' ,
'feature-environment-disabled' ,
'feature-strategy-remove' ,
'feature-strategy-update' ,
'feature-strategy-add' ,
'feature-metadata-updated' ,
'feature-variants-updated' ,
'feature-project-change' ,
] ,
} ,
{
name : 'datadog' ,
displayName : 'Datadog' ,
description : 'Allows Unleash to post updates to Datadog.' ,
documentationUrl :
'https://docs.getunleash.io/docs/addons/datadog' ,
parameters : [
{
name : 'url' ,
displayName : 'Datadog Events URL' ,
description :
2023-09-14 14:01:29 +02:00
"Default URL: https://api.datadoghq.com/api/v1/events. Needs to be changed if your're not using the US1 site." ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
type : 'url' ,
required : false ,
sensitive : false ,
} ,
{
name : 'apiKey' ,
displayName : 'Datadog API key' ,
placeholder : 'j96c23b0f12a6b3434a8d710110bd862' ,
2023-09-14 14:01:29 +02:00
description :
'(Required) API key to connect to Datadog' ,
OpenAPI: addon operations (#3421)
This PR updates the OpenAPI schemas for all the operations tagged with
"addons". In doing so, I also uncovered a few bugs and inconsistencies.
These have also been fixed.
## Changes
I've added inline comments to the changed files to call out anything
that I think is worth clarifying specifically. As an overall
description, this PR does the following:
Splits `addon-schema` into `addon-schema` and
`addon-create-update-schema`. The former is used when describing addons
that exist within Unleash and contain IDs and `created_at` timestamps.
The latter is used when creating or updating addons.
Adds examples and descriptions to all relevant schemas (and their
dependencies).
Updates addons operations descriptions and response codes (including the
recently introduced 413 and 415).
Fixes a bug where the server would crash if it didn't recognize the
addon provider (test added).
Fixes a bug where updating an addon wouldn't return anything, even if
the API said that it would. (test added)
Resolves some inconsistencies in handling of addon description. (tests
added)
### Addon descriptions
when creating addons, descriptions are optional. The original
`addonSchema` said they could be `null | string | undefined`. This
caused some inconsistencies in return values. Sometimes they were
returned, other times not. I've made it so that `descriptions` are now
always returned from the API. If it's not defined or if it's set to
`null`, the API will return `description: null`.
### `IAddonDto`
`IAddonDto`, the type we used internally to model the incoming addons
(for create and update) says that `description` is required. This hasn't
been true at least since we introduced OpenAPI schemas. As such, the
update and insert methods that the service uses were incompatible with
the **actual** data that we require.
I've changed the type to reflect reality for now. Assuming the tests
pass, this **should** all be good, but I'd like the reviewer(s) to give
this a think too.
---------
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
2023-04-18 12:50:34 +02:00
type : 'text' ,
required : true ,
sensitive : true ,
} ,
] ,
events : [
'feature-created' ,
'feature-updated' ,
'feature-archived' ,
'feature-revived' ,
'feature-stale-on' ,
'feature-stale-off' ,
'feature-environment-enabled' ,
'feature-environment-disabled' ,
'feature-strategy-remove' ,
'feature-strategy-update' ,
'feature-strategy-add' ,
'feature-metadata-updated' ,
'feature-project-change' ,
'feature-variants-updated' ,
] ,
tagTypes : [
{
name : 'datadog' ,
description :
'All Datadog tags added to a specific feature are sent to datadog event stream.' ,
icon : 'D' ,
} ,
] ,
} ,
] ,
2022-06-22 12:49:18 +02:00
items : {
$ref : '#/components/schemas/addonTypeSchema' ,
} ,
} ,
} ,
components : {
schemas : {
addonSchema ,
addonTypeSchema ,
tagTypeSchema ,
addonParameterSchema ,
} ,
} ,
} as const ;
export type AddonsSchema = FromSchema < typeof addonsSchema > ;