fix: allow zeroing out asset ids (#624)

This commit is contained in:
Hayden 2023-11-15 21:46:47 -06:00 committed by GitHub
parent afbc6a49ac
commit 8cc0f30291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -47,6 +47,11 @@ func (aid AssetID) MarshalJSON() ([]byte, error) {
}
func (aid *AssetID) UnmarshalJSON(d []byte) error {
if len(d) == 0 || bytes.Equal(d, []byte(`""`)) {
*aid = -1
return nil
}
d = bytes.Replace(d, []byte(`"`), []byte(``), -1)
d = bytes.Replace(d, []byte(`-`), []byte(``), -1)

View file

@ -68,7 +68,7 @@ type (
ItemUpdate struct {
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"`
ID uuid.UUID `json:"id"`
AssetID AssetID `json:"assetId,string"`
AssetID AssetID `json:"assetId"`
Name string `json:"name"`
Description string `json:"description"`
Quantity int `json:"quantity"`