Meu codigo:
@RestController
@RequestMapping("/medico")
public class MedicoController {
@Autowired
private MedicoRepository medicoRepository;
@PostMapping
@Transactional
public void cadastrar(@RequestBody @Valid MedicoDto medicoDto) {
medicoRepository.save(new Medico(medicoDto));
}
@GetMapping
public ResponseEntity<Page<MedicoListDto>> listar(Pageable pageable) {
return ResponseEntity.ok(medicoRepository.findAll(pageable).map(MedicoListDto::new));
}
}
Console:
2024-08-24T20:51:24.479-03:00 WARN 980 --- [api] [nio-8080-exec-1] PageModule$PlainPageSerializationWarning : Serializing PageImpl instances as-is is not supported, meaning that there is no guarantee about the stability of the resulting JSON structure!
For a stable JSON structure, please use Spring Data's PagedModel (globally via @EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO))
or Spring HATEOAS and Spring Data's PagedResourcesAssembler as documented in https://docs.spring.io/spring-data/commons/reference/repositories/core-extensions.html#core.web.pageables.