This repository has been archived by the owner on May 4, 2021. It is now read-only.
forked from Hexlet/hexlet-correction
-
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.
- Loading branch information
Showing
2 changed files
with
75 additions
and
5 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
56 changes: 56 additions & 0 deletions
56
src/main/java/io/hexlet/hexletcorrection/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,56 @@ | ||
package io.hexlet.hexletcorrection.config; | ||
|
||
import com.google.common.base.Predicate; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.MediaType; | ||
import springfox.documentation.RequestHandler; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
import java.util.Set; | ||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public Docket fullApi() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("full-api") | ||
.produces(Set.of(MediaType.APPLICATION_JSON_VALUE)) | ||
.select() | ||
.apis(baseControllersPackage()) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Docket usersApi() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("users-api") | ||
.produces(Set.of(MediaType.APPLICATION_JSON_VALUE)) | ||
.select() | ||
.apis(baseControllersPackage()) | ||
.paths(PathSelectors.regex("/users.*")) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Docket correctionsApi() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.groupName("corrections-api") | ||
.produces(Set.of(MediaType.APPLICATION_JSON_VALUE)) | ||
.select() | ||
.apis(baseControllersPackage()) | ||
.paths(PathSelectors.regex("/corrections.*")) | ||
.build(); | ||
} | ||
|
||
private Predicate<RequestHandler> baseControllersPackage() { | ||
return RequestHandlerSelectors.basePackage("io.hexlet.hexletcorrection.controller"); | ||
} | ||
} |