I have spring-boot application with spring-restdocs and I want to create endpoint in that application for generated documentation. What is the best approach to expose endpoint with generated html documentation(by asciidoctor)?
I can include index.html to jar-file but don't really know how to create endpoint that will consume that html and expose outside.This html generated after test-stage and before build-jar-stage.
From official documentation: You could publish the HTML documentation you created to a static website, or package it up and serve it from the application itself.
e.g. I have index.html in 'build/asctiidoctor/html5' folder and want to create controller that will return that index.html.
According to documentation you can configure your build system (Maven, Gradle) to package HTML into spring-boot jar as static content so that it will be served by Spring Boot 'automagically'
In case of Gradle 4.6 and Spring Boot 2.0.0.RELEASE:
bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
Then it can be verified locally via 'localhost:<your-port>/<your-context-path/docs/index.html