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