Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,15 @@ public interface PetsApi {
method = RequestMethod.GET)
ResponseEntity<List<Pet>> findPets(@ApiParam(value = "tags to filter by") @Valid @RequestParam(value = "tags", required = false) List<String> tags,@ApiParam(value = "maximum number of results to return") @Valid @RequestParam(value = "limit", required = false) Integer limit);


@ApiOperation(value = "", nickname = "updatePet", notes = "Update a pet based on the ID", response = Pet.class, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "pet response", response = Pet.class),
@ApiResponse(code = 200, message = "unexpected error", response = Error.class) })
@RequestMapping(value = "/pets/{id}",
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.PUT)
ResponseEntity<Pet> updatePet(@ApiParam(value = "ID of pet to fetch",required=true) @PathVariable("id") Long id,@ApiParam(value = "" ) @Valid @RequestBody NewPet newPet);

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ public ResponseEntity<List<Pet>> findPets(@ApiParam(value = "tags to filter by")
return delegate.findPets(tags, limit);
}

public ResponseEntity<Pet> updatePet(@ApiParam(value = "ID of pet to fetch",required=true) @PathVariable("id") Long id,@ApiParam(value = "" ) @Valid @RequestBody NewPet newPet) {
return delegate.updatePet(id, newPet);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public interface PetsApiDelegate {
ResponseEntity<List<Pet>> findPets( List<String> tags,
Integer limit);

/**
* @see PetsApi#updatePet
*/
ResponseEntity<Pet> updatePet( Long id,
NewPet newPet);

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ public ResponseEntity<List<Pet>> findPets(List<String> tags, Integer limitObject
return new ResponseEntity<>(filteredPets, HttpStatus.ACCEPTED);
}

@Override
public ResponseEntity<Pet> updatePet(Long id, NewPet newPet) {
if (!pets.containsKey(id)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
pets.get(id).name(newPet.getName()).tag(newPet.getTag());
return new ResponseEntity<>(pets.get(id), HttpStatus.ACCEPTED);
}

}
31 changes: 31 additions & 0 deletions Expanded Pet Store (v3)/models/petstore-expanded.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,37 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'

put:
description: Update a pet based on the ID
operationId: updatePet
requestBody:
content:
"application/json":
schema:
$ref: "#/components/schemas/NewPet"
parameters:
- name: id
in: path
description: ID of pet to fetch
required: true
schema:
type: integer
format: int64
responses:
200:
description: pet response
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

components:
schemas:
Pet:
Expand Down