You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gohan allows to update a part of resource with PUT API. However, update of subproperty of object property results in replace with the object. For example,
Sample Schema
schemas:
- id: simple
description: simple resource
singular: simple
plural: simples
prefix: /v1.0
schema:
properties:
id:
description: The ID of the resource
title: ID
type: string
format: uuid
permission:
- create
view:
- detail
name:
description: The name of the resource
title: Name
type: string
permission:
- create
- update
info:
description: The detail info
title: Info
type: object
permission:
- create
- update
properties:
address:
type: string
title: Address
tel:
type: string
title: Telephone Number
tenant_id:
description: The Tenant ID
title: Tenant ID
type: string
permission:
- create
view:
- detail
propertiesOrder:
- id
- name
- info
- tenant_id
type: object
title: Simple
+--------+--------+----------------------------------------------------------------------------------------+
| id | name | info
+--------+--------+----------------------------------------------------------------------------------------+
| google | Google | {"address": "160 Amphitheatre Pkwy, Mountain View, CA 94043", "tel": "(650) 253-0000"} |
+--------+--------+----------------------------------------------------------------------------------------+
However, real address is wrong, so user tried to modify 'only' address by:
curl -X PUT -H "X-Auth-Token: <token>" http://localhost:9091/simples/google -d '{"name": "Google", "info": {"address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043"}}'
Then, data will unfortunately lose 'tel' info.
+--------+--------+----------------------------------------------------------------+
| id | name | info
+--------+--------+----------------------------------------------------------------+
| google | Google | {"address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043"} |
+--------+--------+----------------------------------------------------------------+
Of course, one workaround is bringing all properties to '1st level'. However, sometimes this workaround becomes unreasonable from the viewpoint of schema architecture.
The text was updated successfully, but these errors were encountered:
Gohan allows to update a part of resource with PUT API. However, update of subproperty of object property results in replace with the object. For example,
Sample Schema
Sample Use Case
Create data as follows:
Then, data will be
However, real address is wrong, so user tried to modify 'only' address by:
Then, data will unfortunately lose 'tel' info.
Of course, one workaround is bringing all properties to '1st level'. However, sometimes this workaround becomes unreasonable from the viewpoint of schema architecture.
The text was updated successfully, but these errors were encountered: