Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
村雨遥
java-learning-demos
提交
97d00933
J
java-learning-demos
项目概览
村雨遥
/
java-learning-demos
上一次同步 1 年多
通知
85
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
java-learning-demos
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
97d00933
编写于
1月 08, 2022
作者:
村雨遥
🎧
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎉
update springboot-swagger3-demo
上级
b8bb86e1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
5 deletion
+58
-5
springboot-swagger2-demo/src/main/java/com/cunyu/springbootswaggerdemo/controller/SwaggerDemoController.java
...ringbootswaggerdemo/controller/SwaggerDemoController.java
+9
-2
springboot-swagger2-demo/src/main/java/com/cunyu/springbootswaggerdemo/entity/User.java
...ain/java/com/cunyu/springbootswaggerdemo/entity/User.java
+36
-0
springboot-swagger3-demo/src/main/java/com/cunyu/springbootswagger3demo/controller/UserController.java
...nyu/springbootswagger3demo/controller/UserController.java
+10
-3
springboot-swagger3-demo/src/main/java/com/cunyu/springbootswagger3demo/entity/User.java
...in/java/com/cunyu/springbootswagger3demo/entity/User.java
+3
-0
未找到文件。
springboot-swagger2-demo/src/main/java/com/cunyu/springbootswaggerdemo/controller/SwaggerDemoController.java
浏览文件 @
97d00933
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
(
"demo
1
"
)
public
String
demo
1
(
@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
();
}
}
springboot-swagger2-demo/src/main/java/com/cunyu/springbootswaggerdemo/entity/User.java
0 → 100644
浏览文件 @
97d00933
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
;
}
springboot-swagger3-demo/src/main/java/com/cunyu/springbootswagger3demo/controller/UserController.java
浏览文件 @
97d00933
...
...
@@ -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!"
;
}
}
springboot-swagger3-demo/src/main/java/com/cunyu/springbootswagger3demo/entity/User.java
浏览文件 @
97d00933
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录