-
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
10 changed files
with
100 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 草稿文档 | ||
|
||
- [Swagger-OpenApi - http://localhost:8080/swagger-ui/](http://localhost:8080/swagger-ui/) | ||
- [Swagger-knife4j - http://localhost:8080/doc.html](http://localhost:8080/doc.html) |
3 changes: 3 additions & 0 deletions
3
pangu-core/src/main/java/com/yuebaix/pangu/core/PanGuCoreConst.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,6 +1,9 @@ | ||
package com.yuebaix.pangu.core; | ||
|
||
public interface PanGuCoreConst { | ||
String AUTHOR_NAME = "yuebaix"; | ||
String AUTHOR_EMAIL = "yuebaix@outlook.com"; | ||
String AUTHOR_GITHUB = "https://github.com/yuebaix"; | ||
String TRACE_ARROW = " ---> "; | ||
String PAN_GU_TRACE_PREFIX = "### PanGu ###" + TRACE_ARROW; | ||
} |
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
4 changes: 4 additions & 0 deletions
4
...ady-spring-boot-starter/src/main/java/com/yuebaix/pangu/ready/PanGuReadyStarterConst.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,4 +1,8 @@ | ||
package com.yuebaix.pangu.ready; | ||
|
||
public interface PanGuReadyStarterConst { | ||
String PAN_GU_READY_STARTER_ENABLED = "pangu.readystarter.enabled"; | ||
String PAN_GU_READY_STARTER_SWAGGER_ENABLED = "pangu.readystarter.swagger.enabled"; | ||
|
||
String PAN_GU_READY_STARTER_VERSION = "1.0"; | ||
} |
56 changes: 56 additions & 0 deletions
56
...y-spring-boot-starter/src/main/java/com/yuebaix/pangu/ready/SwaggerAutoConfiguration.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 com.yuebaix.pangu.ready; | ||
|
||
import com.yuebaix.pangu.core.PanGuCoreConst; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.oas.annotations.EnableOpenApi; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
@ConditionalOnProperty( | ||
value = PanGuReadyStarterConst.PAN_GU_READY_STARTER_SWAGGER_ENABLED, | ||
havingValue = "true", | ||
matchIfMissing = true | ||
) | ||
@EnableOpenApi | ||
@Slf4j | ||
public class SwaggerAutoConfiguration { | ||
@PostConstruct | ||
public void postInit() { | ||
log.info(PanGuCoreConst.PAN_GU_TRACE_PREFIX + "PanGu Ready Swagger Initialized"); | ||
} | ||
|
||
@Bean("DefaultDocket") | ||
@ConditionalOnMissingBean(Docket.class) | ||
public Docket defaultDocket() { | ||
return new Docket(DocumentationType.OAS_30) | ||
.groupName("default") | ||
.apiInfo(apiInfo()) | ||
.useDefaultResponseMessages(false) | ||
//.pathMapping(socialGraphServiceProperties.getContextPath()) | ||
.select() | ||
//扫描注解了@ApiOperation的方法生成API接口文档 | ||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("ApiDoc") | ||
.contact(new Contact(PanGuCoreConst.AUTHOR_NAME, PanGuCoreConst.AUTHOR_GITHUB, PanGuCoreConst.AUTHOR_EMAIL)) | ||
.version(PanGuReadyStarterConst.PAN_GU_READY_STARTER_VERSION) | ||
.description("ApiDoc generated by pangu-ready-spring-boot-starter") | ||
.build(); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...-boot-starter/src/main/java/com/yuebaix/pangu/autoconfigure/common/PanGuStarterConst.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,5 +1,5 @@ | ||
package com.yuebaix.pangu.autoconfigure.common; | ||
|
||
public interface PanGuStarterConst { | ||
String PANGU_STARTER_ENABLED = "pangu.starter.enabled"; | ||
String PAN_GU_STARTER_ENABLED = "pangu.starter.enabled"; | ||
} |
15 changes: 15 additions & 0 deletions
15
pangu-test/src/main/java/com/yuebaix/pangu/test/controller/demo/TestController.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,15 @@ | ||
package com.yuebaix.pangu.test.controller.demo; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/demo/test") | ||
public class TestController { | ||
|
||
@GetMapping("/check") | ||
public String check() { | ||
return "success"; | ||
} | ||
} |
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,2 +1,5 @@ | ||
#pangu.starter.enabled=false | ||
logging.level.com.yuebaix.pangu = debug | ||
#pangu.readystarter.enabled = false | ||
#pangu.readystarter.swagger.enabled = false | ||
|
||
logging.level.com.yuebaix.pangu = debug |