From 75c15e5cac6dee6b1260bbf1cd3a6313f15ed538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Wed, 9 Aug 2023 15:07:17 +0200 Subject: [PATCH] fix: proper aggregation of strategies (#4456) ## About the changes Open API is creating 2 resources under the same URL path, we want them aggregated: ```shell $ curl -s https://us.app.unleash-hosted.com/ushosted/docs/openapi.json | jq '.paths."/api/admin/strategies/{name}" | keys' [ "delete", "get" ] gaston@gaston-Summit-E16Flip-A12UCT: ~/poc/terraform-provider-unleash on main [!$] $ curl -s https://us.app.unleash-hosted.com/ushosted/docs/openapi.json | jq '.paths."/api/admin/strategies/{strategyName}" | keys' [ "put" ] ``` Note one is under `{name}` while the other is under `{strategyName}` --- src/lib/routes/admin-api/strategy.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/routes/admin-api/strategy.ts b/src/lib/routes/admin-api/strategy.ts index 16c6489e40..d49958612b 100644 --- a/src/lib/routes/admin-api/strategy.ts +++ b/src/lib/routes/admin-api/strategy.ts @@ -138,7 +138,7 @@ class StrategyController extends Controller { this.route({ method: 'put', - path: '/:strategyName', + path: '/:name', handler: this.updateStrategy, permission: UPDATE_STRATEGY, middleware: [ @@ -257,13 +257,13 @@ class StrategyController extends Controller { } async updateStrategy( - req: IAuthRequest<{ strategyName: string }, UpdateStrategySchema>, + req: IAuthRequest<{ name: string }, UpdateStrategySchema>, res: Response, ): Promise { const userName = extractUsername(req); await this.strategyService.updateStrategy( - { ...req.body, name: req.params.strategyName }, + { ...req.body, name: req.params.name }, userName, ); res.status(200).end();