是否可以将 swagger interactive api 文档导出为静态 html 以放入 Confluence?

Is it possible to export swagger interactive api Documentation as static html to put into Confluence?

我有一个 Spring 引导项目,我有一个 API 文档是用 swagger 自动创建的。具有以下依赖项:

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>

它看起来非常好,所以我很好奇我是否可以以某种方式将它导出为 html(但使用 css 以获得漂亮的外观)以在 Confluence 中使用它。

我确实已经尝试通过 https://editor.swagger.io/ 进行操作并在其中粘贴了我的 swagger json,但是导出为 html、html2 或动态html 看起来很糟糕。

有没有办法获得与项目中相同的交互式 swagger api 文档。

我会在 iframe 中引用,而不是导出 swagger UI。像这样使用 confluence html 宏

或者,您可以使用网站下载器下载该页面,例如:https://www.httrack.com/。它将下载所有 CSS、javascript 等。一旦你有了文件,你应该复制到网络服务器并从你的 iframe 中引用。

如果您没有网络服务器,那么更黑客的解决方案是使用

将 swagger 页面作为单个 HTML 下载

https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle

然后将文件附加到 confluence 并包含此 iframe :

<iframe id="result" style="width: 100%; height: 100vh;border:none;" 
scrolling="no"></iframe>
<script>
$(document).ready(function() {
$.ajax({
 method: 'GET',
 url: '/download/attachments/...',
 dataType: 'text',
 success: function(data) {
 var iframe = document.getElementById('result');
iframe = iframe.contentWindow || ( iframe.contentDocument.document || iframe.contentDocument);

iframe.document.open();
iframe.document.write(data);
iframe.document.close();
 }
});
});
</script>

确保将 /download/attachments/... 更改为下载按钮指向

的实际下载 url

在此处查看解决方案:

https://community.atlassian.com/t5/Confluence-questions/HTML-file-as-attachment/qaq-p/641523#M86102