<!-- Swagger -->
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.7.1.RELEASE</version>
</dependency>
@EnableSwagger2Doc @SpringBootApplication public class AuthApplication { public static void main(String[] args) { SpringApplication.run(AuthApplication.class, args); } }
@ApiOperation(value = "新增用户") @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = UserDto.class) }) @PostMapping("/user") public UserDto addUser(@RequestBody AddUserParam param) { System.err.println(param.getName()); return new UserDto(); }参数类定义代码如下所示。
@Data @ApiModel(value = "com.biancheng.auth.param.AddUserParam", description = "新增用户参数") public class AddUserParam { @ApiModelProperty(value = "ID") private String id; @ApiModelProperty(value = "名称") private String name; @ApiModelProperty(value = "年龄") private int age; }
Copyright © 广州京杭网络科技有限公司 2005-2024 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有