From aad715923dafe919f271b2dcef16ca17fa9d7bb8 Mon Sep 17 00:00:00 2001 From: Razvan Bordeanu Date: Thu, 22 Feb 2018 10:45:29 +0100 Subject: [PATCH] sanitize operationId remove special chars in swagger 'operationId', because this property is used in code generation tools for method names, and it can lead to invalid code --- lib/nodegen.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/nodegen.js b/lib/nodegen.js index e85951b..005fd75 100644 --- a/lib/nodegen.js +++ b/lib/nodegen.js @@ -199,6 +199,8 @@ function swagger2node(data, options) { } } else if (key === 'default') { // 3. Handle swagger-js-codegen bug return undefined; + } else if (key === 'operationId') { // 4. Sanitize 'operationId' (remove special chars) + return value.replace(/(?!\w|\s)./g, ''); } else { return value; }