bvanderlaan / swagger-ui-restify

Adds middleware to your restify app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
3 stars 10 forks source link

AssertionError #1

Open antonov-abto opened 6 years ago

antonov-abto commented 6 years ago

hello. when I try to write: app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec)); I get a message: throw new assert.AssertionError({ ^

AssertionError [ERR_ASSERTION]: handler (func) is required at new AssertionError (internal/errors.js:315:11)

bvanderlaan commented 6 years ago

Hi @antonov-abto, I'll need to update the README. I had to use the .get() API to make it work. See my test file for an example. That was one of the differences between Express and Restify.

Oh and sorry for the late reply.

coreyperkins commented 6 years ago

@bvanderlaan @antonov-abto after changing the .use to .get I get the following, see attachment.

screen shot 2018-10-30 at 9 36 15 am

I confirmed my swagger.json file is in the right directory. Any advice would be appreciated!

Thanks,

Corey

rahulraykor commented 5 years ago

I am getting same Error

lomaka1313 commented 5 years ago

@bvanderlaan in your test file you have a wrong route for static files, try change to

app.get(/\/swagger-ui+.*/, ...swaggerUi.serveFiles(swaggerSpec))
app.get('/swagger', swaggerUi.setup(swaggerSpec));

P.S.: i use swagger-jsdoc

zhecky commented 5 years ago

worked for me:

server.get('/api/:whatever', swaggerUi.serveFiles(swaggerDocument));
server.get('/api/', swaggerUi.setup(swaggerDocument));
chowington commented 4 years ago

The documentation for this repo is out-of-date. See this comment for help: https://github.com/bvanderlaan/swagger-ui-restify/issues/3#issuecomment-621388734

chowington commented 4 years ago

Updated fix: https://github.com/bvanderlaan/swagger-ui-restify/issues/6#issuecomment-624268765