SpringDoc
SpringDoc

의존성 추가
maven
gradle
Spring Boot 설정

데모
문서 정보 설정
컨트롤러 명세 설정


매핑 명세 설정
Last updated




Last updated
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.12</version>
</dependency>implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.12'# OAS(Open Api Service) setting
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.packages-to-scan=com.hacademy.app.controller@OpenAPIDefinition(
info = @Info(
title = "API 제목",
description = "API 상세 설명",
version = "API 버전 정보"
)
)
@Configuration
public class RestAPIConfiguration {
}@Tag(name = "포켓몬스터 컨트롤러")
@RestController
public class PocketMonsterController {
}@Operation(
summary = "포켓몬 상세",
description = "포켓몬 상세",
responses = {
@ApiResponse(
responseCode = "200",
content = @Content(
mediaType = "application/json",
array = @ArraySchema(
schema = @Schema(
implementation = PocketMonsterDto.class
)
)
)
),
@ApiResponse(
responseCode = "404",
content = @Content(
mediaType = "text/plain",
schema = @Schema(implementation = String.class),
examples = {
@ExampleObject(value="not found")
}
)
),
@ApiResponse(
responseCode = "500",
content = @Content(
mediaType = "text/plain",
schema = @Schema(implementation = String.class),
examples = {
@ExampleObject(value="server error")
}
)
)
}
)
@GetMapping("/pocketmon/{no}")
public PocketMonsterDto find(
@Parameter(description = "포켓몬 번호")
@PathVariable int no) {
return dao.find(no);
}