swagger-tools
swagger-tools copied to clipboard
TypeScript output
using VisualStudio Code and TypeScript, once compiling ts files, TSC generates js files and d.ts files. when the controllers folder passed to swagger-router the regular expression in the 10.2 and 10.3 versions is var jsFileRegex = /.(coffee|js|ts)$/; in the function handlerCacheFromDir. once the extentions removed from the files in the directory (var controllerName = file.replace(jsFileRegex, ''); what is remains is a bad module name for require to load. as an example, lets say i have ./controllers/controller.ts ofter TSC a ./dist/controllers/controller.d.ts and ./dist/controllers/controller.js files created. the ./dist/controllers folder passed to swagger-router middleware and handlerCacheFromDir tries to handle controller.d module by calling require on it and ofcourse fails with an exception cause there is no ./dist/controllers/controller.d.js file.
P.S. I've changed the regex jsFileRegex from /.(coffee|js|ts)$/; to /.(coffee|js|d.ts|ts|)$/; and all warked fine, so maybe just suggesting it as a patch