Skip to content

Commit

Permalink
refactor: asciidocs 자동 생성된 태그로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Jan 10, 2025
1 parent 92ae220 commit 6f112c2
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 79 deletions.
4 changes: 2 additions & 2 deletions server/src/docs/asciidoc/auth.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

=== 나의 정보 조회

operation::api/v1/auth/get-me[]
operation::auth-document-test/get-my-info[]

=== 로그아웃

operation::api/v1/auth/post-logout[]
operation::auth-document-test/logout[]
20 changes: 10 additions & 10 deletions server/src/docs/asciidoc/exam.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@

=== 출제된 시험 요약 목록 조회

operation::api/v1/exams/get-exams[]
operation::exam-document-test/get-published-exam-summaries[]

=== 내가 출제한 시험 요약 목록 조회

operation::api/v1/exams/get-mine[]
operation::exam-document-test/get-my-exam-summaries[]

=== 시험 상세 조회

operation::api/v1/exams/get-exam-(examId)[]
operation::exam-document-test/get-exam-detail[]

=== 시험 상세 정보와 답안을 함께 조회

operation::api/v1/exams/get-(examId)-with-answers[]
operation::exam-document-test/get-exam-detail-with-answers[]

=== 출제된 시험 요약 목록 조회

operation::api/v1/exams/get-submitted[]
operation::exam-document-test/get-submitted-exam-summaries[]

=== 시험 생성

operation::api/v1/exams/post[]
operation::exam-document-test/create-exam[]

=== 시험 출제

operation::api/v1/exams/post-publish[]
operation::exam-document-test/publish[]

=== 시험 문제 수정

operation::api/v1/exams/put-(examId)-questions[]
operation::exam-document-test/update-questions[]

=== 시험 제목 수정

operation::api/v1/exams/patch-title[]
operation::exam-document-test/update-title[]

=== 시험 설명 수정

operation::api/v1/exams/patch-description[]
operation::exam-document-test/update-description[]
2 changes: 1 addition & 1 deletion server/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:toclevels: 2
:sectlinks:

= Fluffy API 문서
= Fluffy API 명세서

include::auth.adoc[]
include::oauth2.adoc[]
Expand Down
4 changes: 2 additions & 2 deletions server/src/docs/asciidoc/oauth2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

=== OAuth2 로그인 페이지로 리다이렉트

operation::api/v1/auth/oauth2/get-redirect-(provider)[]
operation::o-auth2-document-test/oauth2-redirect[]

=== OAuth2 로그인 콜백 처리

operation::api/v1/auth/oauth2/get-callback-(provider)[]
operation::o-auth2-document-test/oauth2-callback[]
8 changes: 4 additions & 4 deletions server/src/docs/asciidoc/submission.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

=== 시험 제출 요약 목록 조회

operation::api/v1/exams/get-(examId)-submissions[]
operation::submission-document-test/get-summaries[]

=== 시험 제출 상세 조회

operation::api/v1/exams/get-(examId)-submissions-(submissionId)[]
operation::submission-document-test/get-detail[]

=== 나의 시험 제출 요약 목록 조회

operation::api/v1/exams/get-(examId)-submissions-me[]
operation::submission-document-test/get-my-submission-summaries[]

=== 시험 제출

operation::api/v1/exams/post-(examId)-submissions[]
operation::submission-document-test/submit[]
10 changes: 2 additions & 8 deletions server/src/test/java/com/fluffy/auth/api/AuthDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down Expand Up @@ -47,13 +45,11 @@ void getMyInfo() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.cookie(new Cookie("access_token", "{ACCESS_TOKEN}"))
)
.andDo(print())
.andExpectAll(
status().isOk(),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/auth/get-me",
.andDo(restDocs.document(
responseFields(
fieldWithPath("id").description("사용자 식별자"),
fieldWithPath("email").description("사용자 이메일"),
Expand All @@ -80,13 +76,11 @@ void logout() throws Exception {
.contentType(MediaType.APPLICATION_JSON)
.cookie(new Cookie("access_token", "{ACCESS_TOKEN}"))
)
.andDo(print())
.andExpectAll(
status().isOk(),
header().doesNotExist("access_token")
)
.andDo(document(
"api/v1/auth/post-logout"
.andDo(restDocs.document(
));
}
}
40 changes: 10 additions & 30 deletions server/src/test/java/com/fluffy/exam/api/ExamDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
Expand Down Expand Up @@ -86,13 +85,11 @@ void getPublishedExamSummaries() throws Exception {
.param("size", "2")
.accept(MediaType.APPLICATION_JSON)
)
.andDo(print())
.andExpectAll(
status().isOk(),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/exams/get-exams",
.andDo(restDocs.document(
queryParameters(
parameterWithName("page").description("페이지 번호").optional(),
parameterWithName("size").description("페이지당 항목 수").optional()
Expand Down Expand Up @@ -144,10 +141,8 @@ void getMyExamSummaries() throws Exception {
.accept(MediaType.APPLICATION_JSON)
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document(
"api/v1/exams/get-mine",
.andDo(restDocs.document(
queryParameters(
parameterWithName("page").description("페이지 번호").optional(),
parameterWithName("size").description("페이지당 항목 수").optional()
Expand Down Expand Up @@ -203,13 +198,11 @@ void getExamDetail() throws Exception {
.param("size", "2")
.accept(MediaType.APPLICATION_JSON)
)
.andDo(print())
.andExpectAll(
status().isOk(),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/exams/get-exam-(examId)",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand Down Expand Up @@ -271,13 +264,11 @@ void getExamDetailWithAnswers() throws Exception {
.accept(MediaType.APPLICATION_JSON)
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
)
.andDo(print())
.andExpectAll(
status().isOk(),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/exams/get-(examId)-with-answers",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand Down Expand Up @@ -324,13 +315,11 @@ void getSubmittedExamSummaries() throws Exception {
.param("size", "9")
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
)
.andDo(print())
.andExpectAll(
status().isOk(),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/exams/get-submitted",
.andDo(restDocs.document(
queryParameters(
parameterWithName("page").description("페이지 번호").optional(),
parameterWithName("size").description("페이지당 항목 수").optional()
Expand Down Expand Up @@ -372,14 +361,12 @@ void createExam() throws Exception {
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
.content(objectMapper.writeValueAsString(request))
)
.andDo(print())
.andExpectAll(
status().isCreated(),
header().string("Location", "/api/v1/exams/1"),
content().json(objectMapper.writeValueAsString(response))
)
.andDo(document(
"api/v1/exams/post",
.andDo(restDocs.document(
requestFields(
fieldWithPath("title").description("시험 제목")
),
Expand Down Expand Up @@ -418,8 +405,7 @@ void publish() throws Exception {
.andExpectAll(
status().isOk()
)
.andDo(document(
"api/v1/exams/post-publish",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand Down Expand Up @@ -458,12 +444,10 @@ void updateQuestions() throws Exception {
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
.content(objectMapper.writeValueAsString(request))
)
.andDo(print())
.andExpectAll(
status().isNoContent()
)
.andDo(document(
"api/v1/exams/put-(examId)-questions",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand Down Expand Up @@ -491,10 +475,8 @@ void updateTitle() throws Exception {
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
.content(objectMapper.writeValueAsString(request))
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document(
"api/v1/exams/patch-title",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand All @@ -514,10 +496,8 @@ void updateDescription() throws Exception {
.cookie(new Cookie("accessToken", "{ACCESS_TOKEN}"))
.content(objectMapper.writeValueAsString(request))
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document(
"api/v1/exams/patch-description",
.andDo(restDocs.document(
pathParameters(
parameterWithName("examId").description("시험 ID")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

Expand Down Expand Up @@ -40,13 +38,11 @@ void oauth2Redirect() throws Exception {
mockMvc.perform(RestDocumentationRequestBuilders.get("/api/v1/auth/oauth2/redirect/{provider}", "github")
.param("next", "/")
)
.andDo(print())
.andExpectAll(
status().is3xxRedirection(),
header().string("Location", redirectUrl)
)
.andDo(document(
"api/v1/auth/oauth2/get-redirect-(provider)",
.andDo(restDocs.document(
pathParameters(
parameterWithName("provider").description("OAuth2 제공자")
),
Expand Down Expand Up @@ -76,14 +72,12 @@ void oauth2Callback() throws Exception {
.param("code", "{CODE}")
.param("next", "{NEXT}")
)
.andDo(print())
.andExpectAll(
status().is3xxRedirection(),
header().string("Location", "https://fluffy.run/{NEXT}"),
header().exists("Set-Cookie")
)
.andDo(document(
"api/v1/auth/oauth2/get-callback-(provider)",
.andDo(restDocs.document(
pathParameters(
parameterWithName("provider").description("OAuth2 제공자")
),
Expand Down
Loading

0 comments on commit 6f112c2

Please sign in to comment.