`@PostMapping("/insert")
@Operation(summary = "Создать раздел и подразделы")
@SecurityRequirement(name = "Bearer Authentication")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Раздел/подраздел успешно создан/обновлен"),
@ApiResponse(responseCode = "401", description = "Требуется авторизация"),
@ApiResponse(responseCode = "400", description = "Не найден объект", content = {@Content(schema = @Schema(implementation = ExceptionDto.class))}),
@ApiResponse(responseCode = "500", description = "Внутренняя ошибка", content = {@Content(schema = @Schema(implementation = ExceptionDto.class))})})
public List<Section> insert(@RequestBody @Validated @NotNull Section dto) {
return sectionService.insertSection(dto);
}
@Transactional
public Section insertSection(@NotNull Section dto) {
if (dto.getId() != null && (!sectionRepository.existsById(dto.getId()))) {
throw new EntityNotFoundException("Section not found");
}
UUID uuid = UUID.randomUUID();
Section section = new Section();
section.setId(dto.getId());
section.setCode(uuid.toString());
section.setSectionName(dto.getSectionName());
return sectionRepository.save(section);
}`
为什么swagger会抛出403错误?在应用程序日志中,它表示找不到该部分。如何让swagger显示这个错误
ExceptionDto.class <- RuntimeException
我尝试将 400、403、404 错误放入错误中