Comments (1)
Spring REST Docs
- API 문서를 자동화하는 도구.
- 테스트를 성공해야 문서를 작성하기 때문에 API 의 신뢰도를 높히고 테스트 코드를 강제할 수 있는 장점이 있다.
- production code 에 문서화를 위한 추가 코드가 작성되지 않기 때문에 코드의 가독성을 유지할 수 있다.
([Tecoble] API 문서 자동화 - Spring REST Docs 팔아보겠습니다)
Build Configuration (by. gradle)
plugins {
id "org.asciidoctor.jvm.convert" version "3.3.2" // (1)
}
configurations {
asciidoctorExt // (2)
}
dependencies {
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor:{project-version}' // (3)
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc:{project-version}' // (4)
}
ext {
snippetsDir = file('build/generated-snippets') // (5)
}
test {
outputs.dir snippetsDir// (6)
}
asciidoctor { // (7)
inputs.dir snippetsDir // (8)
configurations 'asciidoctorExt' // (9)
dependsOn test // (10)
}
- Asciidocttor plugin 을 적용한다.
- Asciidoctor를 확장하는 dependency 에 대한 asciidoctorExt 구성을 선언한다.
- asciidoctorExt 구성에서 spring-restdocs-asciidoctor에 대한 dependency 을 추가한다. 이렇게 하면 /build/generated-snippets 을 가리키는 .adoc 파일에서 사용할 snippets 속성을 자동으로 구성한다.
- testImplementation 설정으로
spring-restdocs-mockmvc
dependency 를 추가한다. - 생성된 snippet 의 출력 위치를 정의하도록 속성을 구성한다.
- snippet 디렉토리를 생성하기 위해 test task 에 설정을 추가해야 한다.
- asciidoctor task 를 설정한다.
- 입력으로서의 snippet 디렉토리를 설정한다.
- 확장에 대한 asciidoctorExt 사용을 환경 설정한다.
- 문서가 생성되기 이전에 테스트가 실행되도록 task 가 test 에 의존하도록 설정한다.
([spring.io] Spring Rest Docs.Build configuration)
packaging the Documentation
bootJar {
dependsOn asciidoctor // (1)
from ("${asciidoctor.outputDir}/html5") { // (2)
into 'static/docs'
}
}
- jar이 빌드되기 전에 문서가 생성되었는지 확인한다.
- 생성된 문서를 jar의 static/docs 디렉토리에 복사한다.
from be-tutorials.
Related Issues (13)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from be-tutorials.