提交 97d00933 编写于 作者: 村雨遥's avatar 村雨遥 🎧

🎉 update springboot-swagger3-demo

上级 b8bb86e1
package com.cunyu.springbootswaggerdemo.controller;
import com.cunyu.springbootswaggerdemo.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -34,8 +35,14 @@ public class SwaggerDemoController {
}
@ApiOperation(value = "有参接口")
@PostMapping("demo")
public String demo(@ApiParam(value = "姓名", required = true, example = "村雨遥") @RequestBody String name) {
@PostMapping("demo1")
public String demo1(@ApiParam(value = "姓名", required = true, example = "村雨遥") @RequestBody String name) {
return "hello," + name;
}
@ApiOperation(value = "有参接口")
@PostMapping("demo2")
public String demo2(@ApiParam(value = "用户对象", required = true) @RequestBody User user) {
return "hello," + user.getName();
}
}
package com.cunyu.springbootswaggerdemo.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Created with IntelliJ IDEA.
*
* @author : 村雨遥
* @version : 1.0
* @project : springboot-swagger2-demo
* @package : com.cunyu.springbootswaggerdemo.entity
* @className : User
* @createTime : 2022/1/8 18:24
* @email : 747731461@qq.com
* @微信 : cunyu1024
* @公众号 : 村雨遥
* @网站 : https://cunyu1943.github.io
* @description :
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("用户实体类")
public class User {
@ApiModelProperty(value = "姓名", required = true, example = "村雨遥")
private String name;
@ApiModelProperty(value = "年龄", required = true, example = "20")
private Integer age;
}
......@@ -3,6 +3,7 @@ package com.cunyu.springbootswagger3demo.controller;
import com.cunyu.springbootswagger3demo.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -29,9 +30,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/user")
public class UserController {
@ApiOperation("测试接口")
@PostMapping("/show")
public String show(@RequestBody User user) {
@ApiOperation("测试接口1")
@PostMapping("/show1")
public String show1(@ApiParam(value = "姓名", required = true, example = "村雨遥") @RequestBody String name) {
return "hello," + name + ",welcome to springboot swagger3!";
}
@ApiOperation("测试接口2")
@PostMapping("/show2")
public String show2(@ApiParam(value = "用户对象", required = true) @RequestBody User user) {
return "hello," + user.getName() + ",welcome to springboot swagger3!";
}
}
......@@ -29,4 +29,7 @@ import lombok.NoArgsConstructor;
public class User {
@ApiModelProperty(value = "姓名", required = true, example = "村雨遥")
private String name;
@ApiModelProperty(value = "年龄", required = true, example = "20")
private Integer age;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册