1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-19 17:52:45 +02:00

openapi: remove redundant openapiservice param from route

This commit is contained in:
Thomas Heartman 2023-08-17 10:03:42 +02:00
parent d8c9bb61d6
commit a2723adad9
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
2 changed files with 38 additions and 40 deletions

View File

@ -36,7 +36,7 @@ class AddonController extends Controller {
super(config, { openApiService }); super(config, { openApiService });
this.logger = config.getLogger('/admin-api/addon.ts'); this.logger = config.getLogger('/admin-api/addon.ts');
this.addonService = addonService; this.addonService = addonService;
this.routeWithOpenApi(this.openApiService)({ this.routeWithOpenApi({
method: 'get', method: 'get',
path: '', path: '',
permission: NONE, permission: NONE,
@ -53,7 +53,7 @@ class AddonController extends Controller {
}, },
}); });
this.routeWithOpenApi(this.openApiService)({ this.routeWithOpenApi({
method: 'post', method: 'post',
path: '', path: '',
handler: this.createAddon, handler: this.createAddon,
@ -71,7 +71,7 @@ class AddonController extends Controller {
}, },
}); });
this.routeWithOpenApi(this.openApiService)({ this.routeWithOpenApi({
method: 'get', method: 'get',
path: `${PATH}:id`, path: `${PATH}:id`,
handler: this.getAddon, handler: this.getAddon,
@ -88,7 +88,7 @@ class AddonController extends Controller {
}, },
}); });
this.routeWithOpenApi(this.openApiService)({ this.routeWithOpenApi({
method: 'put', method: 'put',
path: `${PATH}:id`, path: `${PATH}:id`,
handler: this.updateAddon, handler: this.updateAddon,
@ -107,7 +107,7 @@ Note: passing \`null\` as a value for the description property will set it to an
}, },
}); });
this.routeWithOpenApi(this.openApiService)({ this.routeWithOpenApi({
method: 'delete', method: 'delete',
path: `${PATH}:id`, path: `${PATH}:id`,
handler: this.deleteAddon, handler: this.deleteAddon,

View File

@ -119,11 +119,10 @@ export default class Controller {
); );
} }
routeWithOpenApi(openApiService: OpenApiService) { routeWithOpenApi({
return ({
openApi, openApi,
...options ...options
}: IRouteOptions & { openApi: ApiOperation }): void => { }: IRouteOptions & { openApi: ApiOperation }): void {
const errorCodes = new Set<StandardResponseCodes>([401]); const errorCodes = new Set<StandardResponseCodes>([401]);
if ( if (
@ -155,10 +154,9 @@ export default class Controller {
...options, ...options,
middleware: [ middleware: [
...(options.middleware ?? []), ...(options.middleware ?? []),
openApiService.validPath(openApiWithErrorCodes), this.openApiService.validPath(openApiWithErrorCodes),
], ],
}); });
};
} }
get( get(