diff --git a/src/lib/openapi/meta-schema-rules.test.ts b/src/lib/openapi/meta-schema-rules.test.ts index fbed48cd03..ea3b2e1f5c 100644 --- a/src/lib/openapi/meta-schema-rules.test.ts +++ b/src/lib/openapi/meta-schema-rules.test.ts @@ -123,7 +123,6 @@ const metaRules: Rule[] = [ 'tagWithVersionSchema', 'uiConfigSchema', 'updateFeatureSchema', - 'updateFeatureStrategySchema', 'updateTagTypeSchema', 'upsertContextFieldSchema', 'upsertStrategySchema', @@ -151,7 +150,6 @@ const metaRules: Rule[] = [ 'batchStaleSchema', 'cloneFeatureSchema', 'createFeatureSchema', - 'createFeatureStrategySchema', 'createInvitedUserSchema', 'dateSchema', 'environmentsSchema', @@ -183,7 +181,6 @@ const metaRules: Rule[] = [ 'tagWithVersionSchema', 'uiConfigSchema', 'updateFeatureSchema', - 'updateFeatureStrategySchema', 'updateTagTypeSchema', 'upsertContextFieldSchema', 'upsertStrategySchema', diff --git a/src/lib/openapi/spec/create-feature-strategy-schema.ts b/src/lib/openapi/spec/create-feature-strategy-schema.ts index f8488ee13c..cd319f5583 100644 --- a/src/lib/openapi/spec/create-feature-strategy-schema.ts +++ b/src/lib/openapi/spec/create-feature-strategy-schema.ts @@ -6,10 +6,11 @@ export const createFeatureStrategySchema = { $id: '#/components/schemas/createFeatureStrategySchema', type: 'object', required: ['name'], + description: 'Create a strategy configuration in a feature', properties: { name: { type: 'string', - description: 'The name or type of strategy', + description: 'The name of the strategy type', example: 'flexibleRollout', }, title: { @@ -32,7 +33,8 @@ export const createFeatureStrategySchema = { }, constraints: { type: 'array', - description: 'A list of the constraints attached to the strategy', + description: + 'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints', example: [ { values: ['1', '2'], diff --git a/src/lib/openapi/spec/feature-strategy-schema.ts b/src/lib/openapi/spec/feature-strategy-schema.ts index 063496af08..c20a1a441f 100644 --- a/src/lib/openapi/spec/feature-strategy-schema.ts +++ b/src/lib/openapi/spec/feature-strategy-schema.ts @@ -53,7 +53,8 @@ export const featureStrategySchema = { }, constraints: { type: 'array', - description: 'A list of the constraints attached to the strategy', + description: + 'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints', items: { $ref: '#/components/schemas/constraintSchema', }, diff --git a/src/lib/openapi/spec/update-feature-strategy-schema.ts b/src/lib/openapi/spec/update-feature-strategy-schema.ts index 0faf9d768f..5faaef99f4 100644 --- a/src/lib/openapi/spec/update-feature-strategy-schema.ts +++ b/src/lib/openapi/spec/update-feature-strategy-schema.ts @@ -5,18 +5,24 @@ import { constraintSchema } from './constraint-schema'; export const updateFeatureStrategySchema = { $id: '#/components/schemas/updateFeatureStrategySchema', type: 'object', + description: 'Update a strategy configuration in a feature', properties: { name: { type: 'string', + description: 'The name of the strategy type', }, sortOrder: { type: 'number', + description: + 'The order of the strategy in the list in feature environment configuration', }, constraints: { type: 'array', items: { $ref: '#/components/schemas/constraintSchema', }, + description: + 'A list of the constraints attached to the strategy. See https://docs.getunleash.io/reference/strategy-constraints', }, title: { type: 'string', diff --git a/src/lib/routes/admin-api/project/project-features.ts b/src/lib/routes/admin-api/project/project-features.ts index 28d30546c0..7099e8381d 100644 --- a/src/lib/routes/admin-api/project/project-features.ts +++ b/src/lib/routes/admin-api/project/project-features.ts @@ -261,9 +261,13 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Get feature toggle strategies.', operationId: 'getFeatureStrategies', + description: + 'Get strategies defined for a feature toggle in the specified environment.', responses: { 200: createResponseSchema('featureStrategySchema'), + ...getStandardResponses(401, 403, 404), }, }), ], @@ -277,12 +281,16 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Add a strategy to a feature toggle.', + description: + 'Add a strategy to a feature toggle in the specified environment.', operationId: 'addFeatureStrategy', requestBody: createRequestSchema( 'createFeatureStrategySchema', ), responses: { 200: createResponseSchema('featureStrategySchema'), + ...getStandardResponses(401, 403, 404), }, }), ], @@ -296,6 +304,9 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Get a strategy configuration.', + description: + 'Get a strategy configuration for an environment in a feature toggle.', operationId: 'getFeatureStrategy', responses: { 200: createResponseSchema('featureStrategySchema'), @@ -312,12 +323,14 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Set the order of strategies on the list.', operationId: 'setStrategySortOrder', requestBody: createRequestSchema( 'setStrategySortOrderSchema', ), responses: { 200: emptyResponse, + ...getStandardResponses(401, 403), }, }), ], @@ -331,6 +344,9 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Update a strategy.', + description: + 'Replace strategy configuration for a feature toggle in the specified environment.', operationId: 'updateFeatureStrategy', requestBody: createRequestSchema( 'updateFeatureStrategySchema', @@ -350,6 +366,9 @@ export default class ProjectFeaturesController extends Controller { middleware: [ openApiService.validPath({ tags: ['Features'], + summary: 'Change specific properties of a strategy.', + description: + 'Change specific properties of a strategy configuration in a feature toggle.', operationId: 'patchFeatureStrategy', requestBody: createRequestSchema('patchesSchema'), responses: { @@ -367,9 +386,15 @@ export default class ProjectFeaturesController extends Controller { permission: DELETE_FEATURE_STRATEGY, middleware: [ openApiService.validPath({ - operationId: 'deleteFeatureStrategy', tags: ['Features'], - responses: { 200: emptyResponse }, + summary: 'Delete a strategy from a feature toggle.', + description: + 'Delete a strategy configuration from a feature toggle in the specified environment.', + operationId: 'deleteFeatureStrategy', + responses: { + 200: emptyResponse, + ...getStandardResponses(401, 403, 404), + }, }), ], }); @@ -798,7 +823,7 @@ export default class ProjectFeaturesController extends Controller { const { features } = req.body; if (this.flagResolver.isEnabled('disableBulkToggle')) { - res.status(409).end(); + res.status(403).end(); return; } @@ -830,7 +855,7 @@ export default class ProjectFeaturesController extends Controller { const { features } = req.body; if (this.flagResolver.isEnabled('disableBulkToggle')) { - res.status(409).end(); + res.status(403).end(); return; }