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: