我正在尝试在springboot项目中配置swagger 2,以针对每个控制器类单独编写文档。
在文档中找不到这样的东西。
控制器示例:
@Api(description = "giftcard controller")
@RestController
@RequestMapping("/giftcard")
public class GiftCardController {
@ApiOperation(value = "get info about requested cards")
@GetMapping(value = "/getInfo")
public HttpStatus getInfo(String id) {
return HttpStatus.NOT_ACCEPTABLE;
}
}
swagger.yaml
swagger: "2.0"
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/users:
get:
summary: Returns a list of users.
description: Optional extended description in Markdown.
produces:
- application/json
responses:
200:
description: OK
Swagger- SpringBoot启用:
@Configuration
@EnableSwagger2
public class SwaggerConfig {}