1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

feat: add schema for change request strategies (#5578)

This change adds a property to the segmentStrategiesSchema to make sure
that change request strategies are listed in the openapi spec

It also renames the files that contains that schema and its tests from
`admin-strategies-schema` to `segment-strategies-schema`.
This commit is contained in:
Thomas Heartman 2023-12-11 12:01:47 +01:00 committed by GitHub
parent 0060697c01
commit fb5a487663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 4 deletions

View File

@ -22,7 +22,7 @@ import {
getStandardResponses,
} from '../../openapi/util/standard-responses';
import { ISegmentService } from '../../segments/segment-service-interface';
import { SegmentStrategiesSchema } from '../../openapi/spec/admin-strategies-schema';
import { SegmentStrategiesSchema } from '../../openapi/spec/segment-strategies-schema';
import { AccessService, OpenApiService } from '../../services';
import {
CREATE_SEGMENT,
@ -156,7 +156,7 @@ export class SegmentsController extends Controller {
description:
'Retrieve all strategies that reference the specified segment.',
responses: {
200: createResponseSchema('adminStrategiesSchema'),
200: createResponseSchema('segmentStrategiesSchema'),
},
}),
],

View File

@ -187,7 +187,7 @@ import { createApplicationSchema } from './spec/create-application-schema';
import { contextFieldStrategiesSchema } from './spec/context-field-strategies-schema';
import { advancedPlaygroundEnvironmentFeatureSchema } from './spec/advanced-playground-environment-feature-schema';
import { createFeatureNamingPatternSchema } from './spec/create-feature-naming-pattern-schema';
import { segmentStrategiesSchema } from './spec/admin-strategies-schema';
import { segmentStrategiesSchema } from './spec/segment-strategies-schema';
import { featureDependenciesSchema } from './spec/feature-dependencies-schema';
// Schemas must have an $id property on the form "#/components/schemas/mySchema".
@ -223,7 +223,7 @@ export const schemas: UnleashSchemas = {
adminCountSchema,
adminFeaturesQuerySchema,
adminSegmentSchema,
adminStrategiesSchema: segmentStrategiesSchema,
segmentStrategiesSchema,
addonParameterSchema,
addonSchema,
addonCreateUpdateSchema,

View File

@ -5,6 +5,7 @@ export const segmentStrategiesSchema = {
type: 'object',
required: ['strategies'],
description: 'A collection of strategies belonging to a specified segment.',
additionalProperties: false,
properties: {
strategies: {
description: 'The list of strategies',
@ -50,6 +51,51 @@ export const segmentStrategiesSchema = {
},
},
},
changeRequestStrategies: {
description:
'A list of strategies that use this segment in active change requests.',
type: 'array',
items: {
type: 'object',
required: [
'featureName',
'projectId',
'environment',
'strategyName',
],
properties: {
id: {
type: 'string',
description:
"The ID of the strategy. Not present on new strategies that haven't been added to the feature flag yet.",
example: 'e465c813-cffb-4232-b184-82b1d6fe9d3d',
},
featureName: {
type: 'string',
description:
'The name of the feature flag that this strategy belongs to.',
example: 'new-signup-flow',
},
projectId: {
type: 'string',
description:
'The ID of the project that the strategy belongs to.',
example: 'red-vista',
},
environment: {
type: 'string',
description:
'The ID of the environment that the strategy belongs to.',
example: 'development',
},
strategyName: {
type: 'string',
description: "The name of the strategy's type.",
example: 'flexibleRollout',
},
},
},
},
},
components: {},
} as const;