提交 ac26b52f 作者: 方治民

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

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