提交 ac26b52f 作者: 方治民

fix: 修复 swagger default docket 缺失导致 pont 无法正常解析

上级 f1f252f4
......@@ -30,9 +30,7 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.data.domain.Example;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 示例接口
......@@ -54,6 +52,7 @@ public class ExampleController {
final Auths auths;
final UserExtensionRepository userExtensionRepository;
@ApiOperation("Hello World")
@GetMapping
public Result<String> hello() {
return Result.ok("example.hello");
......@@ -62,15 +61,17 @@ public class ExampleController {
/**
* 测试失败自定义状态信息输出
*/
@ApiOperation("测试失败")
@GetMapping("fail")
public Result<String> fail() {
throw BusinessException.i18n("Code.100000");
}
@SaCheckLogin
@ApiOperation("分页条件查询")
@GetMapping("page")
public Result<PageVo<String>> page(@Validated PageParam pageParam) {
log.info("PageParam: {}", pageParam);
public Result<PageVo<String>> page(@Validated PageParam param) {
log.debug("PageParam: {}", param);
String text = i18n.get("example.hello");
List<String> data = Arrays.asList(text.split(" "));
......@@ -78,9 +79,15 @@ public class ExampleController {
return Result.ok(vo);
}
@ApiOperation(value = "JSON 传参")
@PostMapping("json")
public Result<PageVo<String>> json(@RequestBody @Validated PageParam param) {
return page(param);
}
@AuthIgnore
@SneakyThrows
@ApiOperation(value = "download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ApiOperation(value = "文件下载", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@GetMapping("download")
public void download(HttpServletResponse response) {
ClassPathResource resource = new ClassPathResource("static/cat.jpg");
......
......@@ -59,29 +59,29 @@ public class SwaggerConfig implements CommandLineRunner {
@Resource
OpenApiExtensionResolver openApiExtensionResolver;
@Bean(name = "api.all")
public Docket all() {
return api("① 全部", List.of(""), PathSelectors.any());
@Bean(name = "api.any")
public Docket any() {
return api("default", List.of(""), PathSelectors.any());
}
@Bean(name = "api.auth")
public Docket auth() {
return api(" Auth", List.of("com.yiring.auth.web"), Predicate.not(PathSelectors.ant(path + "/sys/**")));
return api(" Auth", List.of("com.yiring.auth.web"), Predicate.not(PathSelectors.ant(path + "/sys/**")));
}
@Bean(name = "api.common")
public Docket common() {
return api(" 公共", List.of("com.yiring.common.web", "com.yiring.app.web.common"), PathSelectors.any());
return api(" 公共", List.of("com.yiring.common.web", "com.yiring.app.web.common"), PathSelectors.any());
}
@Bean(name = "api.manage")
public Docket manage() {
return api(" 系统管理", List.of("com.yiring.auth.web.sys"), PathSelectors.any());
return api(" 系统管理", List.of("com.yiring.auth.web.sys"), PathSelectors.any());
}
@Bean(name = "api.example")
public Docket example() {
return api(" 示例", List.of("com.yiring.app.web.example"), PathSelectors.any());
return api(" 示例", List.of("com.yiring.app.web.example"), PathSelectors.any());
}
private Docket api(String group, List<String> basePackages, Predicate<String> paths) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论