From fac8b39b190dce6f244d70aed5e93d056de50e46 Mon Sep 17 00:00:00 2001 From: "mail_yanpeng@163.com" Date: Tue, 25 Aug 2020 13:15:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88swagger=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java | 4 ++-- src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java | 2 -- src/main/java/com/aiprose/mbp/controller/UserController.java | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java b/src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java index cda902f..09792a8 100644 --- a/src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java +++ b/src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java @@ -1,5 +1,6 @@ package com.aiprose.mbp.conf; +import io.swagger.annotations.ApiOperation; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -11,10 +12,8 @@ import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration -@Import(BeanValidatorPluginsConfiguration.class) public class SwaggerConfiguration { @Bean public Docket createRestApi() { @@ -22,6 +21,7 @@ public class SwaggerConfiguration { .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.aiprose.mbp.controller")) +// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.any()) .build(); } diff --git a/src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java b/src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java index 2fbc0e9..c3a74a4 100644 --- a/src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java +++ b/src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java @@ -15,7 +15,6 @@ public class WebMvcConfig extends WebMvcConfigurationSupport { .allowedMethods("GET", "POST","DELETE","OPTIONS") .allowCredentials(false).maxAge(3600); } - @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry. @@ -30,5 +29,4 @@ public class WebMvcConfig extends WebMvcConfigurationSupport { registry.addViewController("/swagger-ui/") .setViewName("forward:/swagger-ui/index.html"); } - } diff --git a/src/main/java/com/aiprose/mbp/controller/UserController.java b/src/main/java/com/aiprose/mbp/controller/UserController.java index ad935a4..c219380 100644 --- a/src/main/java/com/aiprose/mbp/controller/UserController.java +++ b/src/main/java/com/aiprose/mbp/controller/UserController.java @@ -3,6 +3,8 @@ package com.aiprose.mbp.controller; import com.aiprose.mbp.entity.User; import com.aiprose.mbp.service.UserService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController +@Api(tags = "用户接口-用户信息相关") public class UserController { @Autowired private UserService userService; @@ -25,6 +28,8 @@ public class UserController { public List user() { return userService.list(); } + + @ApiOperation(value = "分页") @GetMapping("page") public Page page() { return userService.page();