1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

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}`
This commit is contained in:
Gastón Fournier 2023-08-09 15:07:17 +02:00 committed by GitHub
parent 2531819222
commit 75c15e5cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<void>,
): Promise<void> {
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();