Swagger交互式文档
1、首先我们实现一个Controller类,用来当做交互的信息。
先给一个实体类:
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel("用户实体类") //生成一个Swagger注释
public class User {
@ApiModelProperty("用户ID")
public int Id;
@ApiModelProperty("用户名")
public String name;
}
Controller:
import com.zm.swaggerdemo.pojo.User;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {