diff --git a/src/lib/app.ts b/src/lib/app.ts index 6de9ec9fc41e..737d0e970400 100644 --- a/src/lib/app.ts +++ b/src/lib/app.ts @@ -193,10 +193,6 @@ export default async function getApp( // Setup API routes app.use(`${baseUriPath}/`, new IndexRouter(config, services, db).router); - if (services.openApiService) { - services.openApiService.useErrorHandler(app); - } - if (process.env.NODE_ENV !== 'production') { app.use(errorHandler()); } else { diff --git a/src/lib/services/openapi-service.ts b/src/lib/services/openapi-service.ts index f678bfb413a6..4cec32699074 100644 --- a/src/lib/services/openapi-service.ts +++ b/src/lib/services/openapi-service.ts @@ -11,7 +11,6 @@ import type { ApiOperation } from '../openapi/util/api-operation'; import type { Logger } from '../logger'; import { validateSchema } from '../openapi/validate'; import type { IFlagResolver } from '../types'; -import { fromOpenApiValidationErrors } from '../error/bad-data-error'; export class OpenApiService { private readonly config: IUnleashConfig; @@ -60,21 +59,6 @@ export class OpenApiService { }); } - useErrorHandler(app: Express): void { - app.use((err, req, res, next) => { - if (err?.status && err.validationErrors) { - const apiError = fromOpenApiValidationErrors( - req, - err.validationErrors, - ); - - res.status(apiError.statusCode).json(apiError); - } else { - next(err); - } - }); - } - respondWithValidation( status: number, res: Response,