gpt4 book ai didi

asp.net-mvc - 如何在 中添加选项?

转载 作者:行者123 更新时间:2023-12-05 00:59:41 26 4
gpt4 key购买 nike

我想为我的 ReDoc 添加一些附加选项。对于当前的实现,我使用的是从 Swagger 生成的 json 文件,它被添加到 html 页面中。示例如何完成:

  <body>
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>

我将此用作引用文档:https://github.com/Rebilly/ReDoc

如何在标签中添加选项对象而不使用 ReDoc 对象?以及如何使用供应商扩展,例如x标志?在文档中这是通过 json 文件设置的,但我的 json 文件是从 Swagger 自动生成的。

最佳答案

您只需将选项放在 redoc 标记中的 spec-url 之后,如下所示:

<body>
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json' YOUR_OPTIONS_HERE></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>

在这个 ReDoc 存储库的示例中,您可以对其进行验证(此时为第 22 行):

https://github.com/Rebilly/ReDoc/blob/master/config/docker/index.tpl.html#L22

重要:

请记住“kebab-casing the ReDoc options”,例如,如果您的选项是:

hideDownloadButton noAutoAuth disableSearch

YOUR_OPTIONS_HERE

应该是(在烤肉串后):

hide-download-button no-auto-auth disable-search

你的 body 会变成这样:

<body>
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json' hide-download-button no-auto-auth disable-search></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>

希望对你有用。

关于asp.net-mvc - 如何在 <redoc> 中添加选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52763862/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com