Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
ldp-docs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
doc
ldp-docs
Commits
cd921366
Commit
cd921366
authored
Dec 30, 2020
by
马超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc: 新增Knife4j
parent
4c39f5d0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
1 deletion
+63
-1
LDP框架ChangeLog&升级方式.md
LDP框架ChangeLog&升级方式.md
+1
-1
knife4j-example.png
imgs/knife4j/knife4j-example.png
+0
-0
swagger2-controller.png
imgs/knife4j/swagger2-controller.png
+0
-0
swagger2-entity.png
imgs/knife4j/swagger2-entity.png
+0
-0
Knife4j&Swagger使用文档.md
开发文档/Knife4j&Swagger使用文档.md
+62
-0
No files found.
LDP框架ChangeLog&升级方式.md
View file @
cd921366
...
...
@@ -153,7 +153,7 @@
- 前端脚手架联调配置说明文档:[LDP前端脚手架工程联调配置说明]
(
http://gitlab.dev.shxrtech.com/doc/ldp-docs/blob/master/开发文档/LDP前端脚手架工程联调配置说明.md
)
- Knife4j、Swagger使用文档:
待补充
- Knife4j、Swagger使用文档:
[Knife4j&Swagger使用文档.md]
(
http://gitlab.dev.shxrtech.com/doc/ldp-docs/blob/master/开发文档/Knife4j&Swagger使用文档.md
)
- 数据权限授权模式说明文档:[LDP-MCS组织数据授权操作说明]
(
http://gitlab.dev.shxrtech.com/doc/ldp-docs/blob/master/操作文档/LDP-MCS组织数据授权操作说明.md
)
...
...
imgs/knife4j/knife4j-example.png
0 → 100644
View file @
cd921366
71.2 KB
imgs/knife4j/swagger2-controller.png
0 → 100644
View file @
cd921366
133 KB
imgs/knife4j/swagger2-entity.png
0 → 100644
View file @
cd921366
82.5 KB
开发文档/Knife4j&Swagger使用文档.md
0 → 100644
View file @
cd921366
# Knife4j&Swagger使用文档
knife4j是为Java MVC框架集成Swagger生成Api文档的增强解决方案,前身是swagger-bootstrap-ui,取名kni4j是希望它能像一把匕首一样小巧,轻量,并且功能强悍。
-
文档说明:根据Swagger的规范说明,网页方式详细列出接口文档的说明,包括接口地址、类型、请求示例、请求参数、响应示例、响应参数、响应码等信息。
-
在线调试:提供在线接口联调的强大功能,自动解析当前接口参数,同时包含表单验证,调用参数可返回接口响应内容、headers、Curl请求命令实例、响应时间、响应状态码等信息,帮助开发者在线调试。
官网参考:https://doc.xiaominfo.com/knife4j/documentation/
项目启动后,接口文档访问地址:http://localhost:8800/doc.html

## Swagger2注解使用
### 实体类注解
**@ApiModel**
用于注解实体类
**@ApiModelProperty**
用于注解实体类字段
样例:

### Controller层注解
**@Api**
用于注解Contoller
**@ApiOperation**
用于注解Contoller接口
**@ApiImplicitParams**
用于注解非对象参数集
**@ApiImplicitParam**
用于描述非对象参数
样例:

常用注解介绍:
| 作用范围 | API | API常用参数 | 作用位置 |
| ------------------ | ------------------ | ------------------------------------------------------------ | ---------------------------- |
| 协议集描述 | @Api | @Api(tags = {"tag1","tag2","..."}) | controller类 |
| 协议描述 | @ApiOperation | @ApiOperation(value = "功能描述",notes = "备注") | controller类的方法 |
| 描述返回对象的意义 | @ApiModel | @ApiModel(value="类名",description="类描述") | 实体对象类 |
| 对象属性 | @ApiModelProperty | @ApiModelProperty(value = "类属性描述",required =
*true*
,example = "属性举例",notes = "备注") | 出入参数对象的字段 |
| 非对象参数集 | @ApiImplicitParams | @ApiImplicitParams({@ApiImplicitParam(),@ApiImplicitParam(),...}) | controller的方法 |
| 非对象参数描述 | @ApiImplicitParam | @ApiImplicitParam(name = "参数名",value = "参数描述",required =
*true*
,paramType = "接口传参类型",dataType = "参数数据类型") | @ApiImplicitParams的方法里用 |
| Response集 | @ApiResponses | @ApiResponses({ @ApiResponse(),@ApiResponse(),..}) | controller的方法 |
| Response | @ApiResponse | @ApiResponse(code = 10001, message = "返回信息") | @ApiResponses里用 |
| 忽略注解 | @ApiIgnore | @ApiIgnore | 类,方法,方法参数 |
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment