zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

REST Handler requires id in the body while it already present on URL #1222

Closed vgarmash closed 4 months ago

vgarmash commented 6 months ago

Description and expected behavior It is confusing that we need to repeat the Id of the entity that we are updating by POST or PUT operations. I can provide one Id in URL and another in the body and the update is done to the object with Id in the Body while I assume the Id in the URL should be updated. . If I omit the id in the body, then I get error 404.

Screenshots image

Environment (please complete the following information):

ymc9 commented 6 months ago

Hi @vgarmash , thanks for reporting this. I understand it feels redundant, but currently ZenStack's RESTful API follows the JSON:API specification: https://jsonapi.org/format/#crud-updating. The "id" field in the payload is required.