add schema fpr update interface

Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
Benny Samir Hierl 2022-02-02 20:19:41 +01:00
parent 8272237d50
commit ea2f6e7dc1

View file

@ -12,10 +12,23 @@ export const updateItem = <RouteOptions>{
method: 'PUT',
url: '/:wishlistId/item/:itemId',
schema: {
body: {
type: 'object',
additionalProperties: false,
properties: {
title: { type: 'string' },
url: { type: 'string' },
image: { type: 'string' },
description: { type: 'string' },
comment: { type: 'string' },
bought: { type: 'boolean' },
},
},
response: {
204: {
type: 'object',
properties: {
id: { type: 'number' },
title: { type: 'string' },
url: { type: 'string' },
image: { type: 'string' },
@ -28,6 +41,7 @@ export const updateItem = <RouteOptions>{
},
},
handler: async (request: GetBySlugUrlTextRequest, reply: FastifyReply) => {
request.log.debug(request.body)
const item = await wishlist.updateItem(
Number(request.params.itemId),
request.body