1.0.0 • Published 2 years ago

@ykmmky/koa2-swagger-ui v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@ykmmky/koa2-swagger-ui

install

npm install @ykmmky/koa2-swagger-ui --save

基于 koa2-swagger-ui 扩展,由于cdn资源间接性无法访问,添加swaggerUICssRef, swaggerUIBundleRef, swaggerUIPresetRef 配置项,用于指定swaggerUI的静态资源加载地址

koa2-swagger-ui

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);