From 7bfc8b23eed36d4573618a1d5d4adfd6e2c5ba60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 5 Sep 2024 08:17:04 +0100 Subject: [PATCH] fix: add request body schema in update segment endpoint (#8085) https://linear.app/unleash/issue/2-2592/updateimprove-a-segment-via-api-call Related to https://github.com/Unleash/unleash/issues/7987 This does not make the endpoint necessarily better - It's still a PUT that acts as a PUT in some ways (expects specific required fields to be present, resets the project to `null` if it's not included in the body) and a PATCH in others (ignores most fields if they're not included in the body). We need to have a more in-depth discussion about developing long-term strategies for our API and respective OpenAPI spec. However this at least includes the proper schema for the request body, which is slightly better than before. --- src/lib/features/segment/segment-controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/features/segment/segment-controller.ts b/src/lib/features/segment/segment-controller.ts index e5c1b9573519..5ee69b8f59b3 100644 --- a/src/lib/features/segment/segment-controller.ts +++ b/src/lib/features/segment/segment-controller.ts @@ -195,9 +195,10 @@ export class SegmentsController extends Controller { openApiService.validPath({ summary: 'Update segment by id', description: - 'Updates the content of the segment with the provided payload. Any fields not specified will be left untouched.', + 'Updates the content of the segment with the provided payload. Requires `name` and `constraints` to be present. If `project` is not present, it will be set to `null`. Any other fields not specified will be left untouched.', tags: ['Segments'], operationId: 'updateSegment', + requestBody: createRequestSchema('upsertSegmentSchema'), responses: { 204: emptyResponse, ...getStandardResponses(400, 401, 403, 409, 415),