在 spring boot 3 应用程序中使用 openapi 3 文档(swagger)时,swagger 文档控制器和我不知道的方法,可能是什么问题?
@OpenAPIDefinition(
info = @Info(
title = "Billing System Api",
description = "Billing System", version = "1.0.0",
contact = @Contact(
name = "Protchenko Kirill",
email = "[email protected]",
url = "https://github.com/kirlozavr/BillingSystem"
)
)
)
public class OpenApiConfig {
}
这是一个示例控制器:
@RestController
@RequestMapping("\*/tariff")
@Tag(name = "Тариф", description = "Контроллер отвечает за crud операции с тарифами")
public class TariffController {
private final TariffService service;
private final TariffMapper mapper = new TariffMapper();
public TariffController(TariffService service) {
this.service = service;
}
@GetMapping("/all/")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "Получить все тарифы")
public List<TariffDto> getAll() {
return service.gelAll()
.stream()
.map(mapper::getEntityToDto)
.toList();
}
依赖:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
结果:
有一个我记录的控制器,然后是任意名称和方法的控制器。