@ykmmky/koa2-swagger-ui
v1.0.0
Published
Swagger UI middleware for koa
Downloads
5
Maintainers
Readme
@ykmmky/koa2-swagger-ui
install
npm install @ykmmky/koa2-swagger-ui --save
基于 koa2-swagger-ui 扩展,由于cdn资源间接性无法访问,添加swaggerUICssRef, swaggerUIBundleRef, swaggerUIPresetRef 配置项,用于指定swaggerUI的静态资源加载地址
example
import Koa from 'koa';
import { koaSwagger } from 'koa2-swagger-ui';
const app = new Koa();
app.use(
koaSwagger({
routePrefix: '/swagger', // host at /swagger instead of default /docs
swaggerUICssRef: "/swagger-ui/swagger-ui.min.css",
swaggerUIBundleRef: "/swagger-ui/swagger-ui-bundle.js",
swaggerUIPresetRef: "/swagger-ui/swagger-ui-standalone-preset.js",
swaggerOptions: {
url: 'http://petstore.swagger.io/v2/swagger.json', // example path to json
},
}),
);
app.listen(3000);