Spring Boot 与 swagger 结合

. 配置pom.xmlhtml

2. 更改端口号,api

在src/main/resources 下面添加一个application.yml文件.浏览器

3. 添加一个ModelCase entity.app

4. 添加一个interface.ui

说明:rest

@Api: 做用在class上,对class的说明.xml

@ApiOperation: 做用在method上,对method的说明.htm

@ApiResponses: 表示响应.blog

@ApiResponse: 在ApiResponses中,表示一组响应.it

@RequestMapping: 表示rest api 地址及方法

@ApiParam: 对参数进行说明

@Valid: 表示启用验证功能,可是你的entity必须包含相关注解,好比NotNull/Min等.

@RequestBody: 为了映射到entity从 request body中.

 

5. 添加实现

 

6. 添加一个Swagger 配置class

说明:

里面包含了一些描述及版本信息.

 

到这里就所有完成,如今能够去浏览器访问 http://localhost:8081/swagger-ui.html

可以看到以下: 包含了2个controller 以及上面的一些描述

相关文章
相关标签/搜索