我有以下版本:
fastify (3.20.1)和fastify-swagger(4.8.4)
我在Node /JavaScript环境中使用fastify。
现在在我的route.js中,当我指定fastify.route时--我正在编写这两个额外的标记(在response:部分之后):
"x-doc": {
title: 'foo1',
category: 'NSS',
filename: 'bar1',
},"my-custom-tag": {
title: 'foo2',
category: 'NSS',
filename: 'bar2',
},结果:

但是,在生成的JSON (swagger.json或swagger.yaml)中,我可以看到x-doc正在出现,而不是my-custom-tag。
当然,由于我没有使用自定义swagger-ui,所以在浏览器中查看时,我没有想到这些东西(x-doc或my-定制标记)都不会出现在swagger中。
但是,我想知道为什么x-doc会出现在结果JSON中,而不是my-custom-tag。
如果我想让my-custom-tag也出现在结果JSON/yaml中,我需要做什么?
发布于 2021-12-16 08:43:47
根据上面@Helen的评论,加上一个"x-“就会产生不同的效果。
在装腔作势的规范中:
'x-doc': {
field1: 'property1',
field2: 'property2',
field3: 'property3',
},
'x-my-custom-tag': {
field1: 'property1_custom',
field2: 'property2_custom',
field3: 'property3_custom',
}生成的JSON。

https://stackoverflow.com/questions/70311806
复制相似问题