From 41ee31e0c5d75bdf702141cb768ad5c14b93e89b Mon Sep 17 00:00:00 2001 From: Xander Endre <45239432+ShadyAlexCodes@users.noreply.github.com> Date: Mon, 22 May 2023 21:32:34 -0600 Subject: [PATCH] Update index.ts Windows path names are not being converted correctly. This modified function will take an OpenAPI path, replace all '{param}' style parameters with ':param' style (as used by Express), and also replace all backslashes (\) with forward slashes (/), making it compatible with all operating systems. --- packages/express-openapi/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/express-openapi/index.ts b/packages/express-openapi/index.ts index 635a9295..638db369 100644 --- a/packages/express-openapi/index.ts +++ b/packages/express-openapi/index.ts @@ -252,7 +252,8 @@ function optionallyAddQueryNormalizationMiddleware( } function toExpressParams(part) { - return part.replace(/\{([^}]+)}/g, ':$1'); + // Replace '{param}' with ':param' and replace any '\\' with '/' + return part.replace(/\{([^}]+)}/g, ':$1').replace(/\\/g, '/'); } function toPromiseCompatibleMiddleware(fn) {