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

[#15] chore: Swagger 적용 #16

Merged
merged 5 commits into from
Jul 25, 2023
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
1 change: 1 addition & 0 deletions TodaysFail-Interface/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation('org.springdoc:springdoc-openapi-ui:1.6.15')
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
import com.todaysfail.api.web.example.dto.response.ExampleResponse;
import com.todaysfail.api.web.example.mapper.ExampleMapper;
import com.todaysfail.example.usecase.ExampleReadUseCase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "X. Example")
@RestController
@RequestMapping("/api/v1/examples")
@RequiredArgsConstructor
public class ExampleController {
private final ExampleReadUseCase exampleReadUseCase;
private final ExampleMapper exampleMapper;

@Operation(summary = "Example 조회 API")
@GetMapping("/{example-id}")
public ExampleResponse getExamples(@PathVariable("example-id") Long exampleId) {
return exampleMapper.toResponse(exampleReadUseCase.execute(exampleId));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.todaysfail.config.swagger;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;

public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
Info info =
new Info()
.title("오늘의 실패 API 문서")
.description("오늘의 실패 API 문서입니다.")
.version("v0.0.1");
return new OpenAPI().info(info);
}

private Info swaggerInfo() {
License license = new License();
license.url("https://github.com/TodaysFail/TodaysFail-Backend");
license.setName("TodaysFail");
return new Info()
.title("TodaysFail API 문서")
.description("TodaysFail API 문서입니다.")
.version("v0.0.1")
.license(license);
}
}
5 changes: 5 additions & 0 deletions TodaysFail-Interface/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ spring:
include:
- infrastructure
- domain
springdoc:
default-produces-media-type: application/json
default-consumes-media-type: application/json
swagger-ui:
tags-sorter: alpha
---
spring:
config:
Expand Down
Loading