๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽฎ ํ”„๋กœ๊ทธ๋ž˜๋ฐ/๐Ÿ‘ฉ‍๐Ÿ’ป ๊ฐœ๋ฐœ ๊ณต๋ถ€

[Springboot] ์ž๋ฐ” ์Šคํ”„๋ง๋ถ€ํŠธ Swagger ๊ธฐ๋ณธ ์„ค์ •

by xxilliant 2025. 5. 1.
728x90
๋ฐ˜์‘ํ˜•

 

 

ํ’€์Šคํƒ ๋ฏธ๋‹ˆ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ๋ฉ”๋ชจํ•˜๋Š”

์ž๋ฐ” ์Šคํ”„๋ง๋ถ€ํŠธ ์Šค์›จ๊ฑฐ ์„ค์ •

 

๐Ÿ”ฅ ๊ธฐ๋ณธ URL = http://localhost:8080/swagger-ui/index.html#/

 

๊ฒฝ๋กœ

๐Ÿ”ฅ ๋””๋ ‰ํ† ๋ฆฌ = java/com/example/{ํ”„๋กœ์ ํŠธ ์ด๋ฆ„}/global/config

 

๐Ÿ”ฅ build.gradle ์˜์กด์„ฑ ์ถ”๊ฐ€ ๋‚ด์šฉ

// swagger
   implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'

 

 

๐Ÿ”ฅ SwaggerConfig ๊ธฐ๋ณธ ์ฝ”๋“œ

package com.example.kiosk_be.global.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages = {"com.example.kiosk_be.domain.*.controller"})
@OpenAPIDefinition(
        info = @Info(
                title = "Kiosk Project",
                description = "This Project is simple kiosk service",
                version = "1.0.0"
        )
)
public class SwaggerConfig {
    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI().components(new Components());
    }
}
728x90
๋ฐ˜์‘ํ˜•