oaijs / koa-oai-router

Koa Router, based on OpenAPI, Swagger and Json Schema.
105 stars 15 forks source link

ctx.renderSwaggerApiExplorer is undefined #36

Closed MarcoPasqualini closed 7 years ago

MarcoPasqualini commented 7 years ago

Hello, First of all, I wanted to excuse myself for my terrible english and the quality of this issue.

While testing your module for my work project I bumped into this error, while requesting the docs/swagger-ui page:

> pollerExpress@1.0.0 start /home/marco/Projects/pollerExpress
> node --harmony api/server.js

ApiExplorer: http://127.0.0.1:9000/docs

  TypeError: ctx.renderSwaggerApiExplorer is not a function
      at /home/marco/Projects/pollerExpress/node_modules/koa-oai-router/dist/oai-explorer.js:53:17
      at Generator.next (<anonymous>)
      at step (/home/marco/Projects/pollerExpress/node_modules/koa-oai-router/dist/oai-explorer.js:33:191)
      at /home/marco/Projects/pollerExpress/node_modules/koa-oai-router/dist/oai-explorer.js:33:437
      at Promise (<anonymous>)
      at /home/marco/Projects/pollerExpress/node_modules/koa-oai-router/dist/oai-explorer.js:33:99
      at /home/marco/Projects/pollerExpress/node_modules/koa-oai-router/dist/oai-explorer.js:57:19
      at /home/marco/Projects/pollerExpress/node_modules/koa-mount/index.js:58:28
      at dispatch (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:44:32)
      at next (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:45:18)
      at /home/marco/Projects/pollerExpress/node_modules/koa-mount/index.js:52:26
      at dispatch (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:44:32)
      at next (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:45:18)
      at /home/marco/Projects/pollerExpress/node_modules/koa-mount/index.js:52:26
      at dispatch (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:44:32)
      at next (/home/marco/Projects/pollerExpress/node_modules/koa-compose/index.js:45:18)

the error is generated at ./koa-oai-router/lib/oai-explorer.js:24: await tx.renderSwaggerApiExplorer('index', options);

ctx.renderSwaggerApiExplorer should be provided by the koa-views-swagger package but looking at it, the function exposed is, instead, ctx.render

In fact after correcting the name of the function everything was working correctly.

amazing-gao commented 7 years ago

I'm so sorry for this bug in version 1.0.0 Do you install without next tag? The lastest tag is version 1.0.0 and there is some bug. Please install as the Installation doc

npm install koa-oai-router@next --save

Why not use koa-views? I rename render to renderSwaggerApiExplorer of koa-views to avoid the side effect when the pages render function calling.

MarcoPasqualini commented 7 years ago

I'm so sorry too, I missed that installation note. Now everything works fine, thank you

yetithefoot commented 6 years ago

Missed as well.