I have a Spring Boot project and I have an API documentation automatically created with swagger. With the following dependencies:
<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>
It looks very nice so i am curious if I can export it somehow as html (but with css to have the nice look) to use it in Confluence.
I did already try to do it via https://editor.swagger.io/
and pasted my swagger json in there, but the export as html, html2 or dynamichtml looks terrible.
Is there a way to get the same interactive swagger api documentation as in the project.
Instead of exporting the swagger UI I would reference in an iframe. Use the confluence html macro for that like this
Alternatively you can download the page with a website downloader e.g.: https://www.httrack.com/ . It will download all CSS, javascript etc. Once you have the files you should copy to a webserver and reference from your iframe in confluence.
If you don't have a webserver then a hackier solution is to download the swagger page as a single HTML using
https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle
Then attach the file to confluence and include this 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>
make sure to change the /download/attachments/... to the actual download url where the download button points to
See solution here :
https://community.atlassian.com/t5/Confluence-questions/HTML-file-as-attachment/qaq-p/641523#M86102