-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52195f5
commit cb4c7b9
Showing
8 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
week_3/3rdSeminar/src/main/java/com/sopt/seminar/common/dto/SuccessStatusResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
week_3/3rdSeminar/src/main/java/com/sopt/seminar/config/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sopt.seminar.config; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
//JWT를 사용하지 않은 경우 (JWT 사용 여부에 따라 입력해야 할 내용이 달라진다.) | ||
@Bean | ||
public OpenAPI openAPI() { | ||
Info info = new Info() | ||
.title("Seminar Swagger") | ||
.description("NOW SOPT 34th Server Part Seminar Swagger dev API") | ||
.version("v1"); | ||
|
||
return new OpenAPI() | ||
.components(new Components()) | ||
.info(info); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
week_3/3rdSeminar/src/main/java/com/sopt/seminar/controller/PostControllerSwagger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.sopt.seminar.controller; | ||
|
||
import com.sopt.seminar.common.dto.ErrorResponse; | ||
import com.sopt.seminar.common.dto.SuccessStatusResponse; | ||
import com.sopt.seminar.service.dto.Request.PostCreateRequest; | ||
import com.sopt.seminar.service.dto.Response.PostDetailResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
@Tag(name = "Posts", description = "블로그 글 API") | ||
public interface PostControllerSwagger { | ||
|
||
@Operation(summary = "글 작성 API") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "글 등록 성공"), | ||
@ApiResponse(responseCode = "400", description = "제목과 내용은 필수입니다.", | ||
content = {@Content(schema = @Schema(implementation = ErrorResponse.class))}) | ||
}) | ||
ResponseEntity<SuccessStatusResponse> createPost( | ||
@RequestHeader Long memberId, | ||
@RequestHeader Long blogId, | ||
@Valid @RequestBody PostCreateRequest postCreateRequest | ||
); | ||
|
||
@Operation(summary = "글 조회 API") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "글 조회 성공"), | ||
@ApiResponse(responseCode = "400", description = "ID에 해당하는 작성된 글이 존재하지 않습니다.", | ||
content = {@Content(schema = @Schema(implementation = ErrorResponse.class))}) | ||
}) | ||
ResponseEntity<SuccessStatusResponse<PostDetailResponse>> getSinglePost(@PathVariable Long postId); | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
week_3/3rdSeminar/src/main/java/com/sopt/seminar/service/dto/Request/PostCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
..._3/3rdSeminar/src/main/java/com/sopt/seminar/service/dto/Response/PostDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters