Repository navigation
fix(swagger): correct malformed path annotations in experiment and flag controllers - #3405
Merged
Merged
Conversation
…ag controllers Ten @Swagger annotations did not describe the routes they document, so the generated spec advertised paths and payloads that do not exist. Literal path segments were wrapped in braces, making swagger-jsdoc read them as path parameters that were then never declared: /experiments/{validation} -> /experiments/validation /experiments/{import} -> /experiments/import /experiments/{export} -> /experiments/export PUT /experiments used an Express-style parameter rather than Swagger templating, so it appeared as a path of its own instead of joining the DELETE on the same route: /experiments/:id -> /experiments/{id} Five path parameters were declared with the wrong key — `id:` or, from a copy-paste out of the flag controller, `flagId:` — where OpenAPI expects `name:`. The parameter was therefore nameless and matched nothing in the path template: /experiments/export/includeLists/{id} /experiments/export/excludeLists/{id} /flags/export/{id} /flags/export/includeLists/{id} /flags/export/excludeLists/{id} GET /experiments/export had the import endpoint's annotation copied onto it wholesale: it documented a required request body of experiment files, when the handler takes @queryParams() and reads params.ids, and its 200 response claimed an array of {fileName, error} when it returns ExperimentDTO[]. Replaced with an in: query array of uuids and a response referencing ExperimentResponse, matching the idiom used by GET /experiments/single/{id}. Comment-only; no routing or behaviour changes. Operation count is unchanged at 111, and path count drops 94 -> 93 because PUT and DELETE now share /experiments/{id}. Regenerating the spec reports 0 malformed paths, down from 9. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the Swagger annotation updates.
No open issues 🎉
What changed in this PR
This comment-only PR aligns the backend’s Swagger annotations with existing experiment and feature flag endpoints, correcting generated API documentation without changing routing or runtime behavior.
Changes:
- Corrects literal route segments and Swagger path-parameter syntax.
- Replaces malformed parameter keys with
name: idon five export operations. - Documents experiment export with an
idsquery array and anExperimentResponsearray response.
| File | Description |
|---|---|
packages/backend/src/api/controllers/FeatureFlagController.ts |
Corrects path-parameter names in three export annotations. |
packages/backend/src/api/controllers/ExperimentController.ts |
Corrects documented paths, export parameters, and the export response schema. |
Review effort: Balanced
danoswaltCL
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ten
@swaggerannotations didn't describe the routes they document, so the generated spec advertises paths and payloads that don't exist. Comment-only — no routing or behaviour changes.Found while regenerating the spec for the GitBook API reference: GitBook rejected the upload with processing errors, all of which traced back to these.
1. Literal path segments wrapped in braces
swagger-jsdoc reads
{validation}as a path parameter namedvalidation, which is then never declared:/experiments/{validation}/experiments/validation@Post('/validation')/experiments/{import}/experiments/import@Post('/import')/experiments/{export}/experiments/export@Get('/export')2. Express-style parameter instead of Swagger templating
PUT /experiments/:id→/experiments/{id}. TheDELETEon the same route was already annotated correctly, so the spec listed the two as separate paths. They now share one entry with both methods.3. Path parameters declared with the wrong key
Five operations used
id:or — copy-pasted out of the flag controller —flagId:where OpenAPI expectsname:. The parameter was nameless and matched nothing in the path template:/experiments/export/includeLists/{id}/experiments/export/excludeLists/{id}/flags/export/{id}/flags/export/includeLists/{id}/flags/export/excludeLists/{id}All five handlers bind
:id, soname: idis correct for each.4.
GET /experiments/exporthad the import annotation copied onto it wholesaleIt documented a required request body of experiment files, but the handler is
@QueryParams() params: ExperimentIdsand readsparams.ids. Its200also claimed an array of{fileName, error}when it returnsExperimentDTO[].Replaced with an
in: queryarray of uuids (matchingExperimentIds:@IsArray @IsNotEmpty @IsUUID('all', {each: true}) ids: string[]) and a response referencingExperimentResponse, the idiomGET /experiments/single/{id}already uses.Verification
Regenerated the spec with the same
swagger-jsdocoptions asswaggerLoader.ts, before and after:PUT/DELETEnow share/experiments/{id})Confirmed the two POST body annotations on
/experiments/validationand/experiments/importare correct as-is —in: bodyis right for a POST, and their schema matchesExperimentFile { fileName, fileContent }.Not included
ExperimentClientController.v6.ts:1039annotatesDELETE /clearDB, but the handler sits under@JsonController('/v6/'), so the real route is/v6/clearDB. Left out deliberately — fixing it also means re-publishing the GitBook spec and updating the operation reference on the API reference page, so it's better handled alongside those.🤖 Generated with Claude Code