Iva*_*van 1 documentation asp.net-mvc swagger
我想为我的 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>
Run Code Online (Sandbox Code Playgroud)
我将此用作参考文档:https : //github.com/Rebilly/ReDoc
如何在标签中添加选项对象而不使用 ReDoc 对象?以及如何使用供应商扩展名,例如 x-logo?在文档中,这是通过 json 文件设置的,但我的 json 文件是从 Swagger 自动生成的。
您只需将选项spec-url放在redoc标签中,如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
在 ReDoc 存储库上的这个示例中,您可以验证它(此时是第 22 行):
https://github.com/Rebilly/ReDoc/blob/master/config/docker/index.tpl.html#L22
请记住“kebab-casing the ReDoc options”,例如,如果您的选项是:
hideDownloadButton noAutoAuth disableSearch
你的_选项_这里
应该是(在用烤肉串包裹它们之后):
hide-download-button no-auto-auth disable-search
拥有这些选项的身体会变成这样:
<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>
Run Code Online (Sandbox Code Playgroud)
希望它对你有用。
| 归档时间: |
|
| 查看次数: |
5438 次 |
| 最近记录: |