From d4e8b8c0bc7099d8bb2ae7f0c41826423093fe04 Mon Sep 17 00:00:00 2001 From: 7474 Date: Sun, 9 Dec 2018 16:16:58 +0900 Subject: [PATCH] Fixed the condition of `hasServiceParams` `swagger.security` is a definition for the whole API. It is not necessarily set when there is security on individual methods. Therefore it is better to refer to `swagger.securityDefinitions` to see if you need ` hasServiceParams`. `isSecure` judgment also refers to ` swagger.securityDefinitions`. Ref: https://github.com/wcandillon/swagger-js-codegen/blob/master/lib/codegen.js#L41 --- lib/nodegen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nodegen.js b/lib/nodegen.js index 2c630d0..9a474ec 100644 --- a/lib/nodegen.js +++ b/lib/nodegen.js @@ -404,7 +404,7 @@ function swagger2node(data, options) { return params.split(',').filter(p => p).some(p => p !== 'body') ? render(content) : ''; }; }; - var hasServiceParams = swagger.host === undefined || swagger.security !== undefined; + var hasServiceParams = swagger.host === undefined || swagger.securityDefinitions !== undefined; // Create node.js var nodeSourceCode = CodeGen.getCustomCode({