Skip to content

Commit 8409c0a

Browse files
authored
Visit post (#234)
* make petId required since it's needed for POST method * preserve existing PUT method, since petId is not an editable field
1 parent 64b36a2 commit 8409c0a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/java/org/springframework/samples/petclinic/rest/controller/VisitRestController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.samples.petclinic.model.Visit;
2424
import org.springframework.samples.petclinic.rest.api.VisitsApi;
2525
import org.springframework.samples.petclinic.rest.dto.VisitDto;
26+
import org.springframework.samples.petclinic.rest.dto.VisitFieldsDto;
2627
import org.springframework.samples.petclinic.service.ClinicService;
2728
import org.springframework.security.access.prepost.PreAuthorize;
2829
import org.springframework.web.bind.annotation.*;
@@ -84,7 +85,7 @@ public ResponseEntity<VisitDto> addVisit(VisitDto visitDto) {
8485

8586
@PreAuthorize("hasRole(@roles.OWNER_ADMIN)")
8687
@Override
87-
public ResponseEntity<VisitDto> updateVisit(Integer visitId, VisitDto visitDto) {
88+
public ResponseEntity<VisitDto> updateVisit(Integer visitId, VisitFieldsDto visitDto) {
8889
Visit currentVisit = this.clinicService.findVisitById(visitId);
8990
if (currentVisit == null) {
9091
return new ResponseEntity<>(HttpStatus.NOT_FOUND);

src/main/resources/openapi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ paths:
11241124
content:
11251125
application/json:
11261126
schema:
1127-
$ref: '#/components/schemas/Visit'
1127+
$ref: '#/components/schemas/VisitFields'
11281128
required: true
11291129
responses:
11301130
200:
@@ -2086,9 +2086,9 @@ components:
20862086
format: int32
20872087
minimum: 0
20882088
example: 1
2089-
readOnly: true
20902089
required:
20912090
- id
2091+
- petId
20922092
PetTypeFields:
20932093
title: PetType fields
20942094
description: Editable fields of a pet type.

0 commit comments

Comments
 (0)