1.1.0 • Published 6 years ago
koa-swagger-validator v1.1.0
koa-swagger-validator
Koa 2 + Swagger 2 + Swagger-tools
Install
$ npm install koa-swagger-validator --saveor
$ yarn add koa-swagger-validatorUsage
validator(spec) => koa2 middleware
import validator from "koa-swagger-validator";
import spec from "./swagger.json";
(async () => {
const app = new Koa();
app.use(await validator(spec));
})();validator(spec, options) => koa2 middleware
import validator from "koa-swagger-validator";
import spec from "./swagger.json";
(async () => {
const app = new Koa();
app.use(await validator(spec, { /* ... */ }));
})();Documentation
| Variable | Type | Required |
|---|---|---|
| spec | object | yes |
| options | object | no |
spec
Swagger RESTful API Documentation Specification
options
| Properties | Type | Required |
|---|---|---|
| security | object | no |
| validator | object | no |
| router | object | no |
| ui | object | no |
See also swagger-tools full documentation.
Limitations
- Koa 2
- Swagger 2