Skip to content

Commit

Permalink
Merge pull request #93 from U2DJ2/be/refactor/enum-docs
Browse files Browse the repository at this point in the history
[BE] Enum 클래스 문서화 자동화
  • Loading branch information
Anak-2 authored May 3, 2024
2 parents 97575d6 + b699618 commit d7d5269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import moim_today.dto.auth.MemberRegisterRequest;
import moim_today.fake_class.auth.FakeAuthService;
import moim_today.util.ControllerTest;
import moim_today.util.EnumDocsUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -130,7 +131,8 @@ void registerTest() throws Exception {
fieldWithPath("departmentId").type(NUMBER).description("학과 ID"),
fieldWithPath("studentId").type(STRING).description("학번"),
fieldWithPath("birthDate").type(STRING).description("생년월일 (yyyy-MM-dd)"),
fieldWithPath("gender").type(VARIES).description("성별 (MALE, FEMALE, UNKNOWN)"),
fieldWithPath("gender").type(VARIES).description(String.format("성별 - %s",
EnumDocsUtils.getEnumNames(Gender.class))),
fieldWithPath("username").type(STRING).description("이름")
)
.build())
Expand Down
14 changes: 14 additions & 0 deletions backend/src/test/java/moim_today/util/EnumDocsUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package moim_today.util;

import java.util.Arrays;

public abstract class EnumDocsUtils {

public static String getEnumNames(Class<? extends Enum> enums){

return Arrays.stream(enums.getEnumConstants())
.map(Enum::name)
.toList()
.toString();
}
}

0 comments on commit d7d5269

Please sign in to comment.