¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yssh.config; |
| | | |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | 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.service.Contact; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | |
| | | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; |
| | | |
| | | @Configuration |
| | | @EnableKnife4j |
| | | public class Knife4jConfig { |
| | | |
| | | @Value("${knife4j.enabled}") |
| | | private boolean enabled; |
| | | |
| | | @Value("${knife4j.pathMapping}") |
| | | private String pathMapping; |
| | | |
| | | @Bean |
| | | public Docket createRestApi() { |
| | | return new Docket(new DocumentationType("openApi", "3.0")) |
| | | // æ¯å¦å¯ç¨Swagger |
| | | .enable(enabled) |
| | | // ç¨æ¥å建该APIçåºæ¬ä¿¡æ¯ï¼å±ç¤ºå¨ææ¡£ç页é¢ä¸ï¼èªå®ä¹å±ç¤ºçä¿¡æ¯ï¼ |
| | | .apiInfo(apiInfo()) |
| | | // åç»åç§° |
| | | .groupName("æå¡") |
| | | // 设置åªäºæ¥å£æ´é²ç»Swaggerå±ç¤º |
| | | .select() |
| | | // æ«æææææ³¨è§£çapiï¼ç¨è¿ç§æ¹å¼æ´çµæ´» |
| | | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| | | // æ«ææå®å
ä¸çswagger注解 |
| | | // .apis(RequestHandlerSelectors.basePackage("com.cn.project.tool.swagger")) |
| | | // æ«æææ .apis(RequestHandlerSelectors.any()) |
| | | .paths(PathSelectors.any()) |
| | | .build() |
| | | /* 设置å®å
¨æ¨¡å¼ï¼swaggerå¯ä»¥è®¾ç½®è®¿é®token */ |
| | | // .securitySchemes(securitySchemes()) |
| | | .pathMapping(pathMapping); |
| | | } |
| | | |
| | | private ApiInfo apiInfo() { |
| | | return new ApiInfoBuilder() |
| | | .description("æçæ¥å£æµè¯ææ¡£") |
| | | .contact(new Contact("å¼ è
¾é£", "http://127.0.0.1:9001/doc.html", "893732661@qq.com")) |
| | | .version("2.0.0") |
| | | .title("çå±±ç³åAPIæ¥å£æµè¯ææ¡£") |
| | | .build(); |
| | | } |
| | | } |