From 9de82e87f2a3a43842dd1e4599e971c08859c265 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Fri, 14 Nov 2025 08:47:31 +0200 Subject: [PATCH] chore: start validating getFeature endpoint (#10975) --- .../feature-toggle/feature-toggle-controller.ts | 14 +++++++++----- src/lib/openapi/spec/feature-environment-schema.ts | 14 ++++++++++++++ src/lib/openapi/spec/feature-schema.ts | 13 +++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/lib/features/feature-toggle/feature-toggle-controller.ts b/src/lib/features/feature-toggle/feature-toggle-controller.ts index 3380a61a09..e60efbaeec 100644 --- a/src/lib/features/feature-toggle/feature-toggle-controller.ts +++ b/src/lib/features/feature-toggle/feature-toggle-controller.ts @@ -742,11 +742,15 @@ export default class ProjectFeaturesController extends Controller { userId: user.id, }); const maybeAnonymized = this.maybeAnonymise(feature); - res.status(200).json( - serializeDates({ - ...maybeAnonymized, - stale: maybeAnonymized.stale || false, - }), + const responseData = { + ...maybeAnonymized, + stale: maybeAnonymized.stale || false, + }; + this.openApiService.respondWithValidation( + 200, + res, + featureSchema.$id, + serializeDates(responseData), ); } diff --git a/src/lib/openapi/spec/feature-environment-schema.ts b/src/lib/openapi/spec/feature-environment-schema.ts index b735c53244..4b017dd355 100644 --- a/src/lib/openapi/spec/feature-environment-schema.ts +++ b/src/lib/openapi/spec/feature-environment-schema.ts @@ -120,6 +120,20 @@ export const featureEnvironmentSchema = { $ref: '#/components/schemas/releasePlanSchema', }, }, + yes: { + type: 'integer', + description: + 'How many times the feature evaluated to true (enabled)', + example: 974, + minimum: 0, + }, + no: { + type: 'integer', + description: + 'How many times the feature evaluated to false (disabled)', + example: 50, + minimum: 0, + }, }, components: { schemas: { diff --git a/src/lib/openapi/spec/feature-schema.ts b/src/lib/openapi/spec/feature-schema.ts index 727b9791a0..baf1b2ad69 100644 --- a/src/lib/openapi/spec/feature-schema.ts +++ b/src/lib/openapi/spec/feature-schema.ts @@ -181,6 +181,13 @@ export const featureSchema = { ], example: 'initial', }, + status: { + type: 'string', + nullable: true, + example: 'kept', + description: + 'The name of the detailed status of a given stage. E.g. completed stage can be kept or discarded.', + }, enteredStageAt: { description: 'When the feature entered this stage', type: 'string', @@ -281,6 +288,12 @@ export const featureSchema = { description: 'The description of the link', nullable: true, }, + feature: { + type: 'string', + example: 'disable-comments', + description: + 'The name of the feature this link belongs to', + }, }, }, description: