Skip to content

Commit d4e8b8c

Browse files
authored
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
1 parent b39ecda commit d4e8b8c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/nodegen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function swagger2node(data, options) {
404404
return params.split(',').filter(p => p).some(p => p !== 'body') ? render(content) : '';
405405
};
406406
};
407-
var hasServiceParams = swagger.host === undefined || swagger.security !== undefined;
407+
var hasServiceParams = swagger.host === undefined || swagger.securityDefinitions !== undefined;
408408

409409
// Create node.js
410410
var nodeSourceCode = CodeGen.getCustomCode({

0 commit comments

Comments
 (0)