Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

unable to mount two routers to koa #46

Open
dancju opened this issue Sep 1, 2018 · 2 comments
Open

unable to mount two routers to koa #46

dancju opened this issue Sep 1, 2018 · 2 comments
Assignees

Comments

@dancju
Copy link

dancju commented Sep 1, 2018

what I did:

const routerV0 = new Router({
  apiDoc: path.join(__dirname, 'api-v0'),
  apiExplorerVisible: true,
})
routerV0.mount(middleware, path.join(__dirname, 'controllers-v0'))
app.use(routerV0.routes())

const routerDash = new Router({
  apiDoc: path.join(__dirname, 'api-dash'),
  apiExplorerVisible: true,
})
routerDash.mount(middleware, path.join(__dirname, 'controllers-dash'))
app.use(routerDash.routes())

what I got:

$ curl http://localhost:8081/api-explorer
{"result":"<!-- HTML for static distribution bundle build -->\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\">\n    <title>Swagger UI</title>\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"./swagger-ui.css\" >\n    <link rel=\"icon\" type=\"image/png\" href=\"./favicon-32x32.png\" sizes=\"32x32\" />\n    <link rel=\"icon\" type=\"image/png\" href=\"./favicon-16x16.png\" sizes=\"16x16\" />\n    <style>\n      html\n      {\n        box-sizing: border-box;\n        overflow: -moz-scrollbars-vertical;\n        overflow-y: scroll;\n      }\n\n      *,\n      *:before,\n      *:after\n      {\n        box-sizing: inherit;\n      }\n\n      body\n      {\n        margin:0;\n        background: #fafafa;\n      }\n    </style>\n  </head>\n\n  <body>\n    <div id=\"swagger-ui\"></div>\n\n    <script src=\"./swagger-ui-bundle.js\"> </script>\n    <script src=\"./swagger-ui-standalone-preset.js\"> </script>\n    <script>\n    window.onload = function() {\n\n      // Build a system\n      const ui = SwaggerUIBundle({\n        configUrl: \"./api-explorer-config.json\",\n        dom_id: '#swagger-ui',\n        deepLinking: true,\n        presets: [\n          SwaggerUIBundle.presets.apis,\n          SwaggerUIStandalonePreset\n        ],\n        plugins: [\n          SwaggerUIBundle.plugins.DownloadUrl\n        ],\n        layout: \"StandaloneLayout\"\n      })\n\n      window.ui = ui\n    }\n  </script>\n  </body>\n</html>\n","statusCode":200}⏎

Was it I made some mistake or two-router is not supported yet?

@amazing-gao
Copy link
Collaborator

Two-router is not supported yet. api-explorer will not work fine.

@jsdevel
Copy link

jsdevel commented Oct 18, 2018

@Nerddan check out https://github.com/kogosoftwarellc/open-api/tree/master/packages/koa-openapi. 2 routers can be used no problem.

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

No branches or pull requests

3 participants