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

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.
This commit is contained in:
Nuno Góis 2024-09-05 08:17:04 +01:00 committed by GitHub
parent b1ce02369a
commit 7bfc8b23ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -195,9 +195,10 @@ export class SegmentsController extends Controller {
openApiService.validPath({ openApiService.validPath({
summary: 'Update segment by id', summary: 'Update segment by id',
description: 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'], tags: ['Segments'],
operationId: 'updateSegment', operationId: 'updateSegment',
requestBody: createRequestSchema('upsertSegmentSchema'),
responses: { responses: {
204: emptyResponse, 204: emptyResponse,
...getStandardResponses(400, 401, 403, 409, 415), ...getStandardResponses(400, 401, 403, 409, 415),