Skip to content

Commit

Permalink
✨feature : SpringRestDocs 작업
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkYunHo committed Aug 11, 2023
1 parent 00f1da0 commit ee7e996
Show file tree
Hide file tree
Showing 27 changed files with 1,532 additions and 136 deletions.
80 changes: 75 additions & 5 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
id("com.google.cloud.tools.jib") version "3.3.2"
id("groovy")
id("com.google.cloud.tools.jib") version "3.3.2" // JIB 설정
id("groovy") // Spock Groovy문법 설정
id("org.asciidoctor.jvm.convert") version "3.3.2" // Spring Rest Docs 설정
}

val asciidoctorExt: Configuration by configurations.creating

dependencies {
implementation(project(":core"))

Expand Down Expand Up @@ -37,6 +42,10 @@ dependencies {
testImplementation("org.spockframework:spock-spring:2.3-groovy-4.0")
testImplementation("org.apache.groovy:groovy:4.0.12")

// spring restdocs
testImplementation("org.springframework.restdocs:spring-restdocs-webtestclient")
asciidoctorExt("org.springframework.restdocs:spring-restdocs-asciidoctor")

// Cucumber
testImplementation("io.cucumber:cucumber-java:7.12.1")
testImplementation("io.cucumber:cucumber-spring:7.12.1")
Expand All @@ -46,6 +55,69 @@ dependencies {
testImplementation("io.projectreactor:reactor-test")
}

// Spring Rest Docs 설정
tasks {
val snippetsDir = file("build/generated-snippets")

test {
outputs.dir(snippetsDir)
useJUnitPlatform()

testLogging {
showStandardStreams = true
showCauses = true
showExceptions = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}

options {
systemProperty("cucumber.features", "src/test/resources")
systemProperty("cucumber.glue", "cucumber.feature")
}
}

asciidoctor {
dependsOn(test)

inputs.dir(snippetsDir)
configurations(asciidoctorExt.name)

baseDirFollowsSourceFile()

doFirst {
delete("src/main/resources/static/docs")
}

doLast {
copy {
from(file("build/docs/asciidoc"))
into(file("src/main/resources/static/docs"))
}
}
}

build {
dependsOn(asciidoctor)
}

jar {
enabled = false
dependsOn(asciidoctor)
}

bootJar {
enabled = true
dependsOn(asciidoctor)

copy {
from(file("${asciidoctor.get().outputDir}/html5"))
into(file("static/docs"))
}
}
}


// JIB 설정
val tagName = project.properties["tagName"] ?: ""
val regex = Regex("^v")
Expand Down Expand Up @@ -77,6 +149,4 @@ jib {
"-Dspring.profiles.active=prod" // profile 설정
)
}
}


}
76 changes: 76 additions & 0 deletions api/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
= Lotto-Folio API Spec Docs
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 3
:sectlinks:
:hardbreaks:
:operation-curl-request-title: Example request
:operation-http-response-title: Example response

// == Other Page
// [[overview-other-page]]
// http://cbt-internal-melon-alliance.melon.devel.kakao.com/docs/common.html[COMMON]
// http://cbt-internal-melon-alliance.melon.devel.kakao.com/docs/code.html[API CODES]
// http://cbt-internal-melon-alliance.melon.devel.kakao.com/docs/logging.html[LOGGING]


:sectnums:


== API Docs

=== 인증

==== 인가코드 요청

===== 요청
include::{snippets}/authorize_step/http-request.adoc[]

===== cUrl Request
include::{snippets}/authorize_step/curl-request.adoc[]

===== Response
include::{snippets}/authorize_step/http-response.adoc[]

'''



=== 당첨번호

==== 특정 당첨번호 조회

===== 요청
include::{snippets}/number_step/http-request.adoc[]

===== Request parameter
include::{snippets}/number_step/query-parameters.adoc[]

===== cUrl Request
include::{snippets}/number_step/curl-request.adoc[]

===== Response Field
include::{snippets}/number_step/response-fields.adoc[]

===== Response
include::{snippets}/number_step/http-response.adoc[]

'''

==== 최신 당첨번호 조회

===== 요청
include::{snippets}/number_latest_step/http-request.adoc[]

===== cUrl Request
include::{snippets}/number_latest_step/curl-request.adoc[]

===== Response Field
include::{snippets}/number_latest_step/response-fields.adoc[]

===== Response
include::{snippets}/number_latest_step/http-response.adoc[]

'''
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AuthorizationFilter(

// 개발자테스트인 경우 인증제외처리
if(DEV_PREFIX in authorization) {
exchange.attributes[USER_ID_ATTRIBUTE] = "TEST_USER_ID"
return chain.filter(exchange)
}

Expand Down
Loading

0 comments on commit ee7e996

Please sign in to comment.