build.gradle 설정
plugin
- gradle 7부터는 플러그인을 jvm을 사용하므로
org.asciidoctor.jvm.convert
로 변경이 필요합니다.
id "org.asciidoctor.jvm.convert" version "3.3.2"
dependency
- 기존에는 dependency를
asciidoctor
로 사용하였으나asciidoctorExt
로 변경되었습니다.
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor:2.0.6.RELEASE'
configurations
configurations { asciidoctorExt //asciidoc }
asciidoctorExt
를 configurations로 등록합니다.
asciidoctor
asciidoctor { configurations "asciidoctorExt" inProcess = JAVA_EXEC forkOptions { jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED") } baseDirFollowsSourceFile() inputs.dir snippetsDir dependsOn test } asciidoctor.doFirst { delete file('src/main/resources/static/docs') } bootJar { dependsOn asciidoctor copy { from "${asciidoctor.outputDir}" into 'BOOT-INF/classes/static/docs' } } build { dependsOn copyDocument }
- build시 html 파일이 resources/static에 복사되도록 하였습니다.
- 17버전의 경우 복사하는 과정에서 권한문제가 생겨 forkOptions를 통해 해결했습니다.
- 참고 : [Java 16] FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Rest Docs 양식
ifndef::snippets[] :snippets: ../../../build/generated-snippets endif::[] :doctype: book :icons: font :source-highlighter: highlightjs :toc: left :toclevels: 3 :sectlinks: :docinfo: shared-head == API === 공통 === 기능 ==== Request ===== Request HTTP Example ==== Response ===== Response HTTP Example
이미지 업로드 기능 Documentation
multipart/form-data로 요청을 보내는 경우는 requestFields로 문서화할 수 없다. 이 경우는 requestParts 메서드로 문서화해야한다.