-
Notifications
You must be signed in to change notification settings - Fork 109
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
10 changed files
with
500 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.leanstacks.ws; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
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 com.google.common.base.Predicate; | ||
|
||
/** | ||
* The ApiDocsConfiguration class provides configuration beans for the Swagger | ||
* API documentation generator. | ||
* | ||
* @author Matt Warman | ||
*/ | ||
@Profile("docs") | ||
@Configuration | ||
@EnableSwagger2 | ||
public class ApiDocsConfiguration { | ||
|
||
/** | ||
* Create a Docket class to be used by Springfox's Swagger API Documentation | ||
* framework. See http://springfox.github.io/springfox/ for more | ||
* information. | ||
* @return A Docket instance. | ||
*/ | ||
@Bean | ||
public Docket docket() { | ||
Predicate<String> paths = PathSelectors.ant("/api/**"); | ||
|
||
ApiInfo apiInfo = new ApiInfoBuilder() | ||
.title("Project Skeleton for Spring Boot Web Services") | ||
.description( | ||
"The Spring Boot web services starter project provides a foundation to rapidly construct a RESTful web services application.") | ||
.contact("LeanStacks.com").version("1.2.0").build(); | ||
|
||
Docket docket = new Docket(DocumentationType.SWAGGER_2) | ||
.apiInfo(apiInfo).select().paths(paths).build(); | ||
|
||
return docket; | ||
} | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/leanstacks/ws/web/docs/ApiDocsController.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,28 @@ | ||
package com.leanstacks.ws.web.docs; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
/** | ||
* The ApiDocsController is a Spring MVC web controller class which serves the | ||
* Swagger user interface HTML page. | ||
* | ||
* @author Matt Warman | ||
*/ | ||
@Profile("docs") | ||
@Controller | ||
public class ApiDocsController { | ||
|
||
/** | ||
* Request handler to serve the Swagger user interface HTML page configured | ||
* to the mapped context path. | ||
* | ||
* @return A String name of the Swagger user interface HTML page name. | ||
*/ | ||
@RequestMapping("/docs") | ||
public String getSwaggerApiDocsPage() { | ||
return "swagger-ui.html"; | ||
} | ||
|
||
} |
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
Oops, something went wrong.