大家好,时尚专家,
我正在使用fastify和fastify-swagger从我的模式定义创建OAS-3 (3.0.3) API规范。
我能够创建漂亮的html,所以嵌入其中。
然而,当我使用标记时(富文本,如===标题,-水平线等)它似乎不承认这一点。
也许我遗漏了一些东西或其他一些为了支持标记而添加的fastify插件。
如果可能的话,请帮帮我。
"fastify": "^3.20.1",
"fastify-swagger": "^4.8.4",谢谢,Pradip
发布于 2021-10-28 08:01:15
我可以使用markdown-it npm包完成这项工作。
fasify-swagger支持表单GFM Syntax的标记。
const markdown = require('markdown-it')({
html: true, // Enable HTML tags in source
xhtmlOut: true, // Use '/' to close single tags (<br />).
});
const readMarkDown = () => {
const markdownDir = './src/markdown';
const introMDFile = `introduction.md`;
const descriptionMDFileContent = fs.readFileSync(`${markdownDir}/${introMDFile}`, 'utf8');
const descNoteMD = markdown.render(descriptionMDFileContent);
return {descNoteMD};
}
const {descNoteMD} = readMarkDown();
console.log(descNoteMD);
...
const swaggerConfig = {
swagger: {
info: {
title: 'My swagger',
description: `My intro: ${descNoteMD}`,
version: '2.0.0'
},
....
}https://stackoverflow.com/questions/69732601
复制相似问题