-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Mojacknong/feature_56/스웨거
Feature 56/스웨거
- Loading branch information
Showing
4 changed files
with
98 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 46 additions & 25 deletions
71
src/main/java/com/modernfarmer/farmusspring/global/config/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,58 @@ | ||
package com.modernfarmer.farmusspring.global.config; | ||
|
||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
//import springfox.documentation.builders.ApiInfoBuilder; | ||
//import springfox.documentation.builders.PathSelectors; | ||
//import springfox.documentation.builders.RequestHandlerSelectors; | ||
//import springfox.documentation.service.ApiInfo; | ||
//import springfox.documentation.spi.DocumentationType; | ||
//import springfox.documentation.spring.web.plugins.Docket; | ||
|
||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
|
||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
private static final String API_NAME = "Farmus Farm Service API"; | ||
private static final String API_VERSION = "0.0.2"; | ||
private static final String API_DESCRIPTION = "팜어스 팜 서비스 api 명세서입니다."; | ||
public class SwaggerConfig implements WebMvcConfigurer { | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.useDefaultResponseMessages(false) //기본 응답코드 표시 | ||
.apiInfo(apiInfo()) //Api 정보 | ||
.select() | ||
.apis(RequestHandlerSelectors.basePackage("com.example.farmusfarm.domain")) //적용할 패키지명 | ||
.paths(PathSelectors.any()) //패키지 하위에서 적용할 url path 지정 | ||
.build(); | ||
public OpenAPI customOpenAPI() { | ||
return new OpenAPI() | ||
.info(new Info().title("My API").version("1.0")) | ||
.addSecurityItem(new SecurityRequirement().addList("bearerAuth")) | ||
.components(new io.swagger.v3.oas.models.Components() | ||
.addSecuritySchemes("bearerAuth", new SecurityScheme() | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT"))); | ||
} | ||
|
||
public ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title(API_NAME) | ||
.version(API_VERSION) | ||
.description(API_DESCRIPTION) | ||
.build(); | ||
} | ||
// private static final String API_NAME = "Farmus Farm Service API"; | ||
// private static final String API_VERSION = "0.0.2"; | ||
// private static final String API_DESCRIPTION = "팜어스 팜 서비스 api 명세서입니다."; | ||
// | ||
// @Bean | ||
// public Docket api() { | ||
// return new Docket(DocumentationType.SWAGGER_2) | ||
// .useDefaultResponseMessages(false) //기본 응답코드 표시 | ||
// .apiInfo(apiInfo()) //Api 정보 | ||
// .select() | ||
// .apis(RequestHandlerSelectors.basePackage("com.modernfarmer.farmusspring")) //적용할 패키지명 | ||
// .paths(PathSelectors.any()) //패키지 하위에서 적용할 url path 지정 | ||
// .build(); | ||
// } | ||
// | ||
// public ApiInfo apiInfo() { | ||
// return new ApiInfoBuilder() | ||
// .title(API_NAME) | ||
// .version(API_VERSION) | ||
// .description(API_DESCRIPTION) | ||
// .build(); | ||
// } | ||
} | ||
|