Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore: πŸ”§ Swagger μ—λŸ¬ μ •μ˜ μ–΄λ…Έν…Œμ΄μ…˜ #150

Merged
merged 9 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename: explanation μ˜€νƒ€ μˆ˜μ •
  • Loading branch information
psychology50 committed Aug 13, 2024
commit 9d0d68084a5f9bee25226a587fff1247dc97b8c6
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiExceptionExplain {
public @interface ApiExceptionExplanation {
Class<? extends BaseErrorCode> value();

String name() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiResponseExplainations {
ApiExceptionExplain[] errors() default {};
public @interface ApiResponseExplanations {
ApiExceptionExplanation[] errors() default {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import kr.co.pennyway.api.common.annotation.ApiExceptionExplain;
import kr.co.pennyway.api.common.annotation.ApiResponseExplainations;
import kr.co.pennyway.api.common.annotation.ApiExceptionExplanation;
import kr.co.pennyway.api.common.annotation.ApiResponseExplanations;
import kr.co.pennyway.api.common.response.ErrorResponse;
import kr.co.pennyway.common.exception.BaseErrorCode;
import lombok.AccessLevel;
Expand All @@ -22,14 +22,14 @@

public final class ApiExceptionExplainParser {
public static void parse(Operation operation, HandlerMethod handlerMethod) {
ApiResponseExplainations annotation = handlerMethod.getMethodAnnotation(ApiResponseExplainations.class);
ApiResponseExplanations annotation = handlerMethod.getMethodAnnotation(ApiResponseExplanations.class);

if (annotation != null) {
generateExceptionResponseDocs(operation, annotation.errors());
}
}

private static void generateExceptionResponseDocs(Operation operation, ApiExceptionExplain[] exceptions) {
private static void generateExceptionResponseDocs(Operation operation, ApiExceptionExplanation[] exceptions) {
ApiResponses responses = operation.getResponses();

Map<Integer, List<ExampleHolder>> holders = Arrays.stream(exceptions)
Expand All @@ -55,7 +55,7 @@ private static void addExamplesToResponses(ApiResponses responses, Map<Integer,

@Builder(access = AccessLevel.PRIVATE)
private record ExampleHolder(int httpStatus, String name, String mediaType, String description, Example holder) {
static ExampleHolder from(ApiExceptionExplain annotation) {
static ExampleHolder from(ApiExceptionExplanation annotation) {
if (annotation instanceof BaseErrorCode errorCode) {
return ExampleHolder.builder()
.httpStatus(errorCode.causedBy().statusCode().getCode())
Expand Down