|
|
@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
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;
|
|
|
@@ -27,7 +28,7 @@ import java.time.LocalDateTime;
|
|
|
public class SwaggerConfig {
|
|
|
|
|
|
@Value("${swagger.basePackage:com.mrxu}")
|
|
|
- private String basePackage = "com.mrxu";
|
|
|
+ private String basePackage;
|
|
|
|
|
|
@Value("${swagger.version:1.0}")
|
|
|
private String version ;
|
|
|
@@ -38,34 +39,34 @@ public class SwaggerConfig {
|
|
|
@Value("${swagger.description:Rest API 接口}")
|
|
|
private String description ;
|
|
|
|
|
|
+ @Bean
|
|
|
+ @ConditionalOnMissingBean
|
|
|
+ public Docket api() {
|
|
|
+ return new Docket(DocumentationType.SWAGGER_2)
|
|
|
+ .select()
|
|
|
+ .apis(RequestHandlerSelectors.basePackage(basePackage))
|
|
|
+ .paths(PathSelectors.any())
|
|
|
+ .build()
|
|
|
+ .apiInfo(apiInfo());
|
|
|
+ }
|
|
|
+
|
|
|
private ApiInfo apiInfo() {
|
|
|
ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
|
|
|
apiInfoBuilder.title(title);
|
|
|
apiInfoBuilder.description(description);
|
|
|
- //apiInfoBuilder.license("爱小灶");
|
|
|
- apiInfoBuilder.licenseUrl("");
|
|
|
+ apiInfoBuilder.license("爱小灶");
|
|
|
apiInfoBuilder.version(version);
|
|
|
apiInfoBuilder.contact(new Contact("爱小灶-研发中心", "", ""));
|
|
|
return apiInfoBuilder.build();
|
|
|
}
|
|
|
|
|
|
- @Bean
|
|
|
- @ConditionalOnMissingBean
|
|
|
- public Docket customImplementation() {
|
|
|
- return new Docket(DocumentationType.SWAGGER_2)
|
|
|
- .select()
|
|
|
- .apis(RequestHandlerSelectors.basePackage(basePackage))
|
|
|
- .build()
|
|
|
- .directModelSubstitute(LocalDate.class, java.sql.Date.class)
|
|
|
- .directModelSubstitute(LocalDateTime.class, java.util.Date.class)
|
|
|
- .apiInfo(apiInfo());
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
@Target({ElementType.TYPE})
|
|
|
@Documented
|
|
|
@Import({SwaggerConfig.class})
|
|
|
- public @interface EnableMrxuSwagger {
|
|
|
+ public @interface Enable {
|
|
|
}
|
|
|
|
|
|
}
|