- [url=]1. 官网[/url]
- [url=]2. API发布路径[/url]
- [url=]3. 自定义包路径,配置其扫描路径[/url]
- [url=]4. 配置扫描多个包[/url]
1. 官网 组件 - Swagger-tools
- Swagger-core java
- Swagger-js js
- Swagger-node-express:
- Swagger-ui
- Swagger-codegen
2. API发布路径 3. 自定义包路径,配置其扫描路径 org.jeecg.config.Swagger2Config .apis(RequestHandlerSelectors.basePackage("com.xxx.core")) 4. 配置扫描多个包 import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Predicate; import springfox.documentation.RequestHandler; .apis(basePackage("org.jeecg.modules"+";"+"com.xxx.core")) public static Predicate<RequestHandler> basePackage(finalString basePackage) { returninput -> declaringClass(input).transform(handlerPackage(basePackage)).or(true); } private static Function<Class<?>, Boolean> handlerPackage(finalString basePackage) { return input ->{ // 循环判断匹配 for (StringstrPackage : basePackage.split(splitor)) { booleanisMatch = input.getPackage().getName().startsWith(strPackage); if (isMatch){ returntrue; } } return false; }; } private static Optional<? extends Class<?>> declaringClass(RequestHandlerinput) { return Optional.fromNullable(input.declaringClass()); }
|