From 600ee7ee803328eb38533704926ca1ca3580d36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Thu, 29 May 2025 12:44:00 +0200 Subject: [PATCH] feat: fail in dev when usign deprecated endpoints (#10058) --- src/lib/services/openapi-service.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/services/openapi-service.ts b/src/lib/services/openapi-service.ts index def7d8ed06..66fc7ee6b0 100644 --- a/src/lib/services/openapi-service.ts +++ b/src/lib/services/openapi-service.ts @@ -51,6 +51,20 @@ export class OpenApiService { ` : ''; + + const failDeprecated = + (op.deprecated ?? false) && process.env.NODE_ENV === 'development'; + + if (failDeprecated) { + return (req, res, next) => { + this.logger.warn( + `Deprecated endpoint: ${op.operationId} at ${req.path}`, + ); + return res.status(410).json({ + message: `The endpoint ${op.operationId} at ${req.path} is deprecated and should not be used.`, + }); + }; + } return this.api.validPath({ ...rest, description: