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

#41 Swagger Update #44

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.dnd.dndtravel.auth.controller.request;

import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

/*
ν΄λΌμ΄μ–ΈνŠΈμ—μ„œ μ„œλ²„λ‘œ λ³΄λ‚΄λŠ” μš”μ²­
*/
public record AppleWithdrawRequest(
@NotBlank(message = "인증 μ½”λ“œκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.")
@Size(max = 300, message = "인증 μ½”λ“œ 길이λ₯Ό μ΄ˆκ³Όν•˜μ˜€μŠ΅λ‹ˆλ‹€.")
@Schema(description = "authorization code", requiredMode = REQUIRED)
@NotBlank(message = "authorization codeλŠ” ν•„μˆ˜ μž…λ‹ˆλ‹€.")
@Size(max = 300, message = "authorization code ν˜•μ‹μ΄ μ•„λ‹™λ‹ˆλ‹€.")
String authorizationCode
) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dnd.dndtravel.auth.controller.swagger;

import com.dnd.dndtravel.auth.controller.request.AppleWithdrawRequest;
import com.dnd.dndtravel.config.AuthenticationMember;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;

Expand Down Expand Up @@ -64,4 +66,28 @@ ReissueTokenResponse reissueToken(
@Parameter(description = "refreshToken", required = true)
ReIssueTokenRequest reissueTokenRequest
);

@Operation(
summary = "μ• ν”Œ νšŒμ› νƒˆν‡΄ API"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "μ •μƒμ μœΌλ‘œ νƒˆν‡΄ λ˜μ—ˆμŠ΅λ‹ˆλ‹€."),
@ApiResponse(responseCode = "400", description = "인증 μ‹€νŒ¨ λ˜λŠ” μœ νš¨ν•˜μ§€ μ•Šμ€ μš”μ²­",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(example = STATUS_CODE_400_BODY_MESSAGE)
)
),
@ApiResponse(
responseCode = "500", description = "μ„œλ²„ 였λ₯˜",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(example = "{\"message\":\"Internal Server Error\"}")
)
)
})
void withdraw(
@Parameter(description = "μš”μ²­ 정보(authorization code)", required = true)
AppleWithdrawRequest appleWithdrawRequest,
@Parameter(hidden = true)
AuthenticationMember authenticationMember
);
}
25 changes: 24 additions & 1 deletion src/main/java/com/dnd/dndtravel/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.dnd.dndtravel.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -14,6 +17,26 @@ public OpenAPI openAPI() {
.info(new Info()
.title("MAPDDANG API")
.description("맡땅 μ•± κ΄€λ ¨ API")
.version("1.0.0"));
.version("1.0.0"))
.addSecurityItem(new SecurityRequirement()
.addList("Access Token")
.addList("Refresh Token"))
.components(new Components()
.addSecuritySchemes("Access Token", createAccessTokenScheme())
.addSecuritySchemes("Refresh Token", createRefreshTokenScheme()));
}

private SecurityScheme createAccessTokenScheme() {
return new SecurityScheme().type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer")
.description("Access Token");
}

private SecurityScheme createRefreshTokenScheme() {
return new SecurityScheme().type(SecurityScheme.Type.HTTP)
.bearerFormat("JWT")
.scheme("bearer")
.description("Refresh Token");
}
}
Loading