在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:pebble/joi-router-swagger-docs开源软件地址:https://github.com/pebble/joi-router-swagger-docs开源编程语言:JavaScript 100.0%开源软件介绍:joi-router-swagger-docsA node module for generating Swagger 2.0 JSON definitions from existing koa-joi-router routes. Aiming to be a replacement for koa-resourcer-docs which can take advantage of various Swagger 2.0 tools for generating client libraries, test suites, AWS Lambda/serverless, etc. This is very WIP (many things missing or broken), and thus is not available on npm yet. Exampleconst SwaggerAPI = require('joi-router-swagger-docs').SwaggerAPI;
const Router = require('koa-joi-router');
const Joi = Router.Joi;
const router = router();
router.get('/signup', {
validate: {
type: 'json',
body: {
name: Joi.string().max(100).description('new user name')
},
output: {
200: {
body: {
userId: Joi.string().description('newly created user id')
}
}
}
},
handler: function*() {
// ...
}
});
swaggerAPI.addJoiRouter(router);
let spec = swaggerAPI.generateSpec({
info: {
title: 'Example API',
description: 'API for creating and editing examples',
version: '1.1'
},
basePath: '/api/v1'
});
console.log(JSON.stringify(spec, null, ' ')); APInew SwaggerAPI()Creates a new SwaggerAPI instance. swaggerAPI.addJoiRouter(router, options)Add a joi-router instance to the API. The router should already have all its
routes set up before calling this method (which pulls the route definitions
from the router's Options:
swaggerAPI.generateSpec(baseSpec)Create a Swagger specification for this API. A base specification should be
provided with an Sponsored byLicense |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论