Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This PR aims to expose the composer creation API (POST /composers) in Swagger documentation by adding REST Docs tests. However, the underlying implementation of the composer creation logic contains a significant security flaw: the administrative check is hardcoded to a single user ID, leading to broken access control. It is recommended to replace this with a proper role-based authorization check. Additionally, while the changes generally align with the purpose, some improvements are suggested to increase test code maintainability and ensure API documentation completeness.
| Map<String, Object> requestBody = Map.of( | ||
| "koreanName", "베토벤", | ||
| "englishName", "Ludwig van Beethoven", | ||
| "gender", "MALE", | ||
| "nationality", "독일", | ||
| "birthYear", 1770, | ||
| "deathYear", 1827, | ||
| "bio", "독일의 작곡가", | ||
| "era", "CLASSICAL", | ||
| "continent", "EUROPE" | ||
| ); |
There was a problem hiding this comment.
테스트의 견고함과 유지보수성을 높이기 위해, Map<String, Object>을 사용하여 요청 본문을 생성하는 대신 ComposerCreateDto를 직접 사용하는 것이 좋습니다. 이렇게 하면 ComposerCreateDto의 필드명이 변경되거나 타입이 바뀔 경우 컴파일 시점에 오류를 발견할 수 있어 테스트가 깨지는 것을 방지할 수 있습니다. 제안된 코드를 적용한 후, IDE를 사용하여 import 문을 정리하는 것을 권장합니다.
| Map<String, Object> requestBody = Map.of( | |
| "koreanName", "베토벤", | |
| "englishName", "Ludwig van Beethoven", | |
| "gender", "MALE", | |
| "nationality", "독일", | |
| "birthYear", 1770, | |
| "deathYear", 1827, | |
| "bio", "독일의 작곡가", | |
| "era", "CLASSICAL", | |
| "continent", "EUROPE" | |
| ); | |
| com.daramg.server.composer.dto.ComposerCreateDto requestBody = new com.daramg.server.composer.dto.ComposerCreateDto( | |
| "베토벤", | |
| "Ludwig van Beethoven", | |
| null, | |
| com.daramg.server.composer.domain.Gender.MALE, | |
| "독일", | |
| (short) 1770, | |
| (short) 1827, | |
| "독일의 작곡가", | |
| com.daramg.server.composer.domain.Era.CLASSICAL, | |
| com.daramg.server.composer.domain.Continent.EUROPE | |
| ); |
| .requestFields( | ||
| fieldWithPath("koreanName").type(JsonFieldType.STRING).description("한국어 이름"), | ||
| fieldWithPath("englishName").type(JsonFieldType.STRING).description("영어 이름"), | ||
| fieldWithPath("gender").type(JsonFieldType.STRING).description("성별 (MALE / FEMALE / UNKNOWN)"), | ||
| fieldWithPath("nationality").type(JsonFieldType.STRING).description("국적").optional(), | ||
| fieldWithPath("birthYear").type(JsonFieldType.NUMBER).description("출생 연도").optional(), | ||
| fieldWithPath("deathYear").type(JsonFieldType.NUMBER).description("사망 연도").optional(), | ||
| fieldWithPath("bio").type(JsonFieldType.STRING).description("소개").optional(), | ||
| fieldWithPath("era").type(JsonFieldType.STRING).description("시대 (MEDIEVAL_RENAISSANCE / BAROQUE / CLASSICAL / ROMANTIC / MODERN_CONTEMPORARY)").optional(), | ||
| fieldWithPath("continent").type(JsonFieldType.STRING).description("대륙 (ASIA / NORTH_AMERICA / EUROPE / SOUTH_AMERICA / AFRICA_OCEANIA)").optional() | ||
| ) |
There was a problem hiding this comment.
ComposerCreateDto에 nativeName 필드가 존재하지만, API 문서에는 누락되어 있습니다. API 사용자가 모든 필드를 알 수 있도록 문서에 추가하는 것이 좋습니다.
| .requestFields( | |
| fieldWithPath("koreanName").type(JsonFieldType.STRING).description("한국어 이름"), | |
| fieldWithPath("englishName").type(JsonFieldType.STRING).description("영어 이름"), | |
| fieldWithPath("gender").type(JsonFieldType.STRING).description("성별 (MALE / FEMALE / UNKNOWN)"), | |
| fieldWithPath("nationality").type(JsonFieldType.STRING).description("국적").optional(), | |
| fieldWithPath("birthYear").type(JsonFieldType.NUMBER).description("출생 연도").optional(), | |
| fieldWithPath("deathYear").type(JsonFieldType.NUMBER).description("사망 연도").optional(), | |
| fieldWithPath("bio").type(JsonFieldType.STRING).description("소개").optional(), | |
| fieldWithPath("era").type(JsonFieldType.STRING).description("시대 (MEDIEVAL_RENAISSANCE / BAROQUE / CLASSICAL / ROMANTIC / MODERN_CONTEMPORARY)").optional(), | |
| fieldWithPath("continent").type(JsonFieldType.STRING).description("대륙 (ASIA / NORTH_AMERICA / EUROPE / SOUTH_AMERICA / AFRICA_OCEANIA)").optional() | |
| ) | |
| .requestFields( | |
| fieldWithPath("koreanName").type(JsonFieldType.STRING).description("한국어 이름"), | |
| fieldWithPath("englishName").type(JsonFieldType.STRING).description("영어 이름"), | |
| fieldWithPath("nativeName").type(JsonFieldType.STRING).description("현지어 이름").optional(), | |
| fieldWithPath("gender").type(JsonFieldType.STRING).description("성별 (MALE / FEMALE / UNKNOWN)"), | |
| fieldWithPath("nationality").type(JsonFieldType.STRING).description("국적").optional(), | |
| fieldWithPath("birthYear").type(JsonFieldType.NUMBER).description("출생 연도").optional(), | |
| fieldWithPath("deathYear").type(JsonFieldType.NUMBER).description("사망 연도").optional(), | |
| fieldWithPath("bio").type(JsonFieldType.STRING).description("소개").optional(), | |
| fieldWithPath("era").type(JsonFieldType.STRING).description("시대 (MEDIEVAL_RENAISSANCE / BAROQUE / CLASSICAL / ROMANTIC / MODERN_CONTEMPORARY)").optional(), | |
| fieldWithPath("continent").type(JsonFieldType.STRING).description("대륙 (ASIA / NORTH_AMERICA / EUROPE / SOUTH_AMERICA / AFRICA_OCEANIA)").optional() | |
| ) |
Summary
POST /composersREST Docs 테스트 추가Cause
Swagger UI가 코드 자동 스캔이 아닌 정적 YAML(
/docs/openapi3.yaml)을 사용하므로,REST Docs 테스트가 없으면 Swagger에 노출되지 않음.