Skip to content

Commit

Permalink
Merge pull request #10 from KUSITMS-Team-A/docs/9-swagger
Browse files Browse the repository at this point in the history
[#9] Swagger 문서 추가
  • Loading branch information
pdohyung authored Nov 16, 2023
2 parents f33a684 + 03866b7 commit 705a36f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
// mail
implementation 'org.springframework.boot:spring-boot-starter-mail'
//swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
}

tasks.named('test') {
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/com/backend/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.backend.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.utils.SpringDocUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.components(new Components()
.addSecuritySchemes("bearer-key",
new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")))
.info(apiInfo());
}

private Info apiInfo() {
return new Info()
.title("Jedero API")
.description("Jedero API 문서")
.version("1.0.0");
}

static {
var schema = new Schema<LocalTime>();
schema.example(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"))).type("string");
SpringDocUtils.getConfig().replaceWithSchema(LocalTime.class, schema);
}
}

0 comments on commit 705a36f

Please sign in to comment.