Created
April 30, 2017 21:16
-
-
Save glenpike/01b896f8fdc5819019e192d26f6b3ad5 to your computer and use it in GitHub Desktop.
Serve Swagger Doc's with Koa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Serve a swagger doc with Koa */ | |
const Koa = require('koa'); | |
const koaSwagger = require('koa2-swagger-ui'); | |
//const yaml = require('yamljs'); | |
//const spec = yaml.load('./music-api.yml'); | |
const app = new Koa(); | |
app.use(koaSwagger({ | |
routePrefix: '/swagger', // host at /swagger instead of default /docs | |
swaggerOptions: { | |
url: 'https://raw.githubusercontent.com/glenpike/music-library-api/develop/music-api.yml' | |
//spec: spec | |
}, | |
})); | |
app.listen(3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "koa-swagger-ui-test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"koa": "^2.2.0", | |
"koa2-swagger-ui": "^2.3.0", | |
"yamljs": "^0.2.10" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment