ソースを参照

整合swagger 3.0

master
mail_yanpeng@163.com 4年前
コミット
fac8b39b19
  1. 4
      src/main/java/com/aiprose/mbp/conf/SwaggerConfiguration.java
  2. 2
      src/main/java/com/aiprose/mbp/conf/WebMvcConfig.java
  3. 5
      src/main/java/com/aiprose/mbp/controller/UserController.java

4
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();
}

2
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");
}
}

5
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> user() {
return userService.list();
}
@ApiOperation(value = "分页")
@GetMapping("page")
public Page<User> page() {
return userService.page();

読み込み中…
キャンセル
保存