Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for restify 7.x and 8.x #24

Open
LiborVilimekMassive opened this issue Jan 2, 2020 · 2 comments
Open

Support for restify 7.x and 8.x #24

LiborVilimekMassive opened this issue Jan 2, 2020 · 2 comments

Comments

@LiborVilimekMassive
Copy link

We are using this library for all routes on Restify 4.x and 6.x without issues. There is however change in path resolver in restify 7.x and it is causing this issue:

Generated 'api.yml'
13:44:51.878Z FATAL rocket: Uncaught exception, aborting Node (err.code=ERR_ASSERTION)
    AssertionError [ERR_ASSERTION]: The first character of a path should be `/` or `*`
        at Router.on (...\node_modules\find-my-way\index.js:69:3)
        at RouterRegistryRadix.add (...\node_modules\restify\lib\routerRegistryRadix.js:42:21)
        at Router.mount (...\node_modules\restify\lib\router.js:212:20)
        at Server.serverMethod [as get] (...\node_modules\restify\lib\server.js:1686:33)
        at registerDocsRoute (...\node_modules\swagger-routes\src\routeRegister.js:36:7)
        at Object.registerRoutes (...\node_modules\swagger-routes\src\routeRegister.js:12:3)
        at addHandlers (...\node_modules\swagger-routes\src\index.js:19:17)

It happens ^^ when we call swaggerRoutes(server, {

To see what exactly is happening I logged data from https://github.com/mikestead/swagger-routes/blob/master/src/routeRegister.js#L34

And if I update it with this:

function registerDocsRoute(app, options) {
  console.log(`/${options.api.basePath}/${options.docsPath}`)
  const docsPath = path.normalize(`/${options.api.basePath}/${options.docsPath}`)
  console.log(docsPath);
  app.get(docsPath, options.docsMiddleware, function handler(req, res) { res.json(options.api) })
}

Then this is logged before error:

////spec
\spec

For new restify resolver, path cannot start with \.

When I tried to just comment this line https://github.com/mikestead/swagger-routes/blob/master/src/routeRegister.js#L36 then everything else is working correctly and it loads all paths same as before.

@james-skinner-deltatre
Copy link

Testing this with node v16 and restify v8.6 and cant reproduce this. maybe path.normalise worked differently in older node version?

@jan-zaruba-ententee
Copy link

When I run it on Windows update of node.js and restify does not seem to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants