1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/src/lib/openapi/spec/feature-strategy-schema.ts
2023-07-13 13:50:03 +02:00

84 lines
2.7 KiB
TypeScript

import { FromSchema } from 'json-schema-to-ts';
import { constraintSchema } from './constraint-schema';
import { parametersSchema } from './parameters-schema';
import { strategyVariantSchema } from './strategy-variant-schema';
export const featureStrategySchema = {
$id: '#/components/schemas/featureStrategySchema',
description:
'A single activation strategy configuration schema for a feature',
type: 'object',
additionalProperties: false,
required: ['name'],
properties: {
id: {
type: 'string',
description: 'A uuid for the feature strategy',
example: '6b5157cb-343a-41e7-bfa3-7b4ec3044840',
},
name: {
type: 'string',
description: 'The name or type of strategy',
example: 'flexibleRollout',
},
title: {
type: 'string',
description: 'A descriptive title for the strategy',
example: 'Gradual Rollout 25-Prod',
nullable: true,
},
disabled: {
type: 'boolean',
description:
'A toggle to disable the strategy. defaults to false. Disabled strategies are not evaluated or returned to the SDKs',
example: false,
nullable: true,
},
featureName: {
type: 'string',
description: 'The name or feature the strategy is attached to',
example: 'myAwesomeFeature',
},
sortOrder: {
type: 'number',
description: 'The order of the strategy in the list',
example: 9999,
},
segments: {
type: 'array',
description: 'A list of segment ids attached to the strategy',
example: [1, 2],
items: {
type: 'number',
},
},
constraints: {
type: 'array',
description:
'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints',
items: {
$ref: '#/components/schemas/constraintSchema',
},
},
variants: {
type: 'array',
description: 'Strategy level variants',
items: {
$ref: '#/components/schemas/strategyVariantSchema',
},
},
parameters: {
$ref: '#/components/schemas/parametersSchema',
},
},
components: {
schemas: {
constraintSchema,
parametersSchema,
strategyVariantSchema,
},
},
} as const;
export type FeatureStrategySchema = FromSchema<typeof featureStrategySchema>;