959510
根据Joi 参数判断,去实现文档的request部分,但是总感觉文档用起来还是不是太顺手,求star与提建议。
地址:https://github.com/ufo-parts/joi2md Example
const Joi = require('joi');
const Joi2md = require('joi2md');
const Jm = new Joi2md();
// 设置schema
Jm.setSchema({
name: Joi.number().default(1).required().notes('用户名'),
})
// schema 转换为行数据
Jm.transferRows()
// 得到markdown字符串
Jm.setPrintHeaders([
['path', '参数名'],
['type', '类型'],
['presence', '必填'],
['default', '默认值'],
['notes', '说明'],
]);
const result = Jm.printMd()
console.log(result)
Result
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| name | number | true | 1 | 用户名 |