개발일지

[개발일지_safeHome] 9. swagger 세팅

woopii 2025. 12. 28. 18:54

 

API 호출 테스트를 위한 swagger-ui 세팅 진행

 

1. 의존성 추가


val springdocVersion = "2.8.9"

dependencies {
	.....

    // Swagger
    implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springdocVersion")

	.....
}

 

 

 

2. 프로퍼티 설정 추가

springdoc:
  cache:
    disabled: true
  default-consumes-media-type: application/json
  default-produces-media-type: application/json

---
spring:
  config:
    activate:
      on-profile: local

springdoc:
  swagger-ui:
    path: /swagger-ui.html    # 접속 경로
    tags-sorter: alpha            # 태그 알파벳 정렬
    operations-sorter: method     # GET, POST, 등 정렬
    doc-expansion: none           # 태그 펼침 여부
  api-docs:
    path: /api/v3/api-docs

 

spring:
  application:
    name: safehome
  config:
    import:
      - classpath:application-db.yml
      - classpath:application-swagger.yml

 

 

 

3. swagger config 는 나중에 필요하면 작성