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/constraint-schema.ts
Gastón Fournier c1a1a0fdeb
docs: open api examples for segment schemas (#3503)
## About the changes
Add additional documentation for segments

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-04-12 09:29:51 +00:00

61 lines
2.4 KiB
TypeScript

import { FromSchema } from 'json-schema-to-ts';
import { ALL_OPERATORS } from '../../util/constants';
export const constraintSchemaBase = {
type: 'object',
required: ['contextName', 'operator'],
description:
'A strategy constraint. For more information, refer to [the strategy constraint reference documentation](https://docs.getunleash.io/reference/strategy-constraints)',
properties: {
contextName: {
description:
'The name of the context field that this constraint should apply to.',
example: 'appName',
type: 'string',
},
operator: {
description:
'The operator to use when evaluating this constraint. For more information about the various operators, refer to [the strategy constraint operator documentation](https://docs.getunleash.io/reference/strategy-constraints#strategy-constraint-operators).',
type: 'string',
enum: ALL_OPERATORS,
example: 'IN',
},
caseInsensitive: {
description:
'Whether the operator should be case sensitive or not. Defaults to `false` (being case sensitive).',
type: 'boolean',
default: false,
},
inverted: {
description:
'Whether the result should be negated or not. If `true`, will turn a `true` result into a `false` result and vice versa.',
type: 'boolean',
default: false,
},
values: {
type: 'array',
description:
'The context values that should be used for constraint evaluation. Use this property instead of `value` for properties that accept multiple values.',
items: {
type: 'string',
},
example: ['my-app', 'my-other-app'],
},
value: {
description:
'The context value that should be used for constraint evaluation. Use this property instead of `values` for properties that only accept single values.',
type: 'string',
example: 'my-app',
},
},
components: {},
} as const;
export const constraintSchema = {
$id: '#/components/schemas/constraintSchema',
additionalProperties: false,
...constraintSchemaBase,
} as const;
export type ConstraintSchema = FromSchema<typeof constraintSchema>;