Swagger2 구성하여 API 문서 자동화하기

오피셜 프로젝트 : https://github.com/SpringForAll/spring-boot-starter-swagger

일단 관련 Library 부터 추가해 보자, 22년 12월 21일 기준으로 아직도 해당 버전이 제일 인기가 많은것 같다.

<!-- https://mvnrepository.com/artifact/com.spring4all/swagger-spring-boot-starter -->
<dependency>
    <groupId>com.spring4all</groupId>
    <artifactId>swagger-spring-boot-starter</artifactId>
    <version>1.9.0.RELEASE</version>
</dependency>

application.properties 파일작성

swagger.title=spring-boot-starter-swagger
swagger.description=Starter for swagger 2.x
swagger.version=1.4.0.RELEASE
swagger.license=Apache License, Version 2.0
swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
swagger.termsOfServiceUrl=https://github.com/dyc87112/spring-boot-starter-swagger
swagger.contact.name=blake
swagger.contact.url=https://rainsister.tistory.com
swagger.contact.email=dyc87112@qq.com
swagger.base-package=com.blake
swagger.base-path=/**

.yml

swagger:
    base-package: com.http:rainsister
    base-path: /**
    contact:
        email: luxury515@naver.com
        name: blake
        url: https://rainsister.tistory.com
    description: Starter for swagger 2.x
    license: Apache License, Version 2.0
    licenseUrl: https://www.apache.org/licenses/LICENSE-2.0.html
    termsOfServiceUrl: 
    title: spring-boot-starter-swagger
    version: 1.4.0.RELEASE

시작후 http://localhost:8080/swagger-ui.html 에 접속하면

끝!

Last updated