-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: π‘ SwaggerConfig μμ± ν κ΄λ ¨ μ€μ μ΄λ
- Loading branch information
Showing
3 changed files
with
49 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
package com.postsquad.scoup; | ||
|
||
import com.google.common.base.Predicates; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@EnableSwagger2 | ||
@EnableJpaAuditing | ||
@SpringBootApplication | ||
public class ScoupApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ScoupApplication.class, args); | ||
} | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("Scoup") | ||
.apiInfo(apiInfo()) | ||
.select() | ||
.paths(Predicates.not(PathSelectors.regex("/error"))) | ||
.paths(PathSelectors.ant("/**")) | ||
.build(); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("Scoup API Documentation") | ||
.version("1.0") | ||
.description("Scoupμ API λ¬Έμμ λλ€.") | ||
.build(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/postsquad/scoup/web/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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.postsquad.scoup.web.config; | ||
|
||
import com.google.common.base.Predicates; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.hateoas.client.LinkDiscoverer; | ||
import org.springframework.hateoas.client.LinkDiscoverers; | ||
import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer; | ||
import org.springframework.plugin.core.SimplePluginRegistry; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@EnableSwagger2 | ||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("Scoup") | ||
.apiInfo(apiInfo()) | ||
.select() | ||
.paths(Predicates.not(PathSelectors.regex("/error"))) | ||
.paths(PathSelectors.ant("/**")) | ||
.build(); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("Scoup API Documentation") | ||
.version("1.0") | ||
.description("Scoupμ API λ¬Έμμ λλ€.") | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public LinkDiscoverers discoverers() { | ||
List<LinkDiscoverer> plugins = new ArrayList<>(); | ||
plugins.add(new CollectionJsonLinkDiscoverer()); | ||
return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); | ||
} | ||
} |
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