mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
update return type to be nullable
This commit is contained in:
parent
88bb9a4f52
commit
63406747df
4 changed files with 58 additions and 8 deletions
|
@ -1232,6 +1232,10 @@ const docTemplate = `{
|
|||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1270,6 +1274,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/repo.ItemAttachment"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
}
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -1277,7 +1287,6 @@ const docTemplate = `{
|
|||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"description": "Future",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemField"
|
||||
|
@ -1316,6 +1325,11 @@ const docTemplate = `{
|
|||
"description": "Extras",
|
||||
"type": "string"
|
||||
},
|
||||
"parent": {
|
||||
"x-nullable": true,
|
||||
"x-omitempty": true,
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
},
|
||||
"purchaseFrom": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -1439,6 +1453,10 @@ const docTemplate = `{
|
|||
"description": "Extras",
|
||||
"type": "string"
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"purchaseFrom": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -1224,6 +1224,10 @@
|
|||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1262,6 +1266,12 @@
|
|||
"$ref": "#/definitions/repo.ItemAttachment"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
}
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -1269,7 +1279,6 @@
|
|||
"type": "string"
|
||||
},
|
||||
"fields": {
|
||||
"description": "Future",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/repo.ItemField"
|
||||
|
@ -1308,6 +1317,11 @@
|
|||
"description": "Extras",
|
||||
"type": "string"
|
||||
},
|
||||
"parent": {
|
||||
"x-nullable": true,
|
||||
"x-omitempty": true,
|
||||
"$ref": "#/definitions/repo.ItemSummary"
|
||||
},
|
||||
"purchaseFrom": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -1431,6 +1445,10 @@
|
|||
"description": "Extras",
|
||||
"type": "string"
|
||||
},
|
||||
"parentId": {
|
||||
"type": "string",
|
||||
"x-nullable": true
|
||||
},
|
||||
"purchaseFrom": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -62,6 +62,9 @@ definitions:
|
|||
type: string
|
||||
name:
|
||||
type: string
|
||||
parentId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
type: object
|
||||
repo.ItemField:
|
||||
properties:
|
||||
|
@ -86,12 +89,15 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/repo.ItemAttachment'
|
||||
type: array
|
||||
children:
|
||||
items:
|
||||
$ref: '#/definitions/repo.ItemSummary'
|
||||
type: array
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
fields:
|
||||
description: Future
|
||||
items:
|
||||
$ref: '#/definitions/repo.ItemField'
|
||||
type: array
|
||||
|
@ -118,6 +124,10 @@ definitions:
|
|||
notes:
|
||||
description: Extras
|
||||
type: string
|
||||
parent:
|
||||
$ref: '#/definitions/repo.ItemSummary'
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
purchaseFrom:
|
||||
type: string
|
||||
purchasePrice:
|
||||
|
@ -202,6 +212,9 @@ definitions:
|
|||
notes:
|
||||
description: Extras
|
||||
type: string
|
||||
parentId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
purchaseFrom:
|
||||
type: string
|
||||
purchasePrice:
|
||||
|
|
|
@ -40,7 +40,7 @@ type (
|
|||
|
||||
ItemCreate struct {
|
||||
ImportRef string `json:"-"`
|
||||
ParentID uuid.UUID `json:"parentId"`
|
||||
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
|
||||
|
@ -49,7 +49,7 @@ type (
|
|||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
}
|
||||
ItemUpdate struct {
|
||||
ParentID uuid.UUID `json:"parentId"`
|
||||
ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
|
@ -102,7 +102,7 @@ type (
|
|||
}
|
||||
|
||||
ItemOut struct {
|
||||
Parent ItemSummary `json:"parent,omitempty"`
|
||||
Parent *ItemSummary `json:"parent,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
ItemSummary
|
||||
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
|
@ -202,9 +202,10 @@ func mapItemOut(item *ent.Item) ItemOut {
|
|||
children = mapEach(item.Edges.Children, mapItemSummary)
|
||||
}
|
||||
|
||||
var parent ItemSummary
|
||||
var parent *ItemSummary
|
||||
if item.Edges.Parent != nil {
|
||||
parent = mapItemSummary(item.Edges.Parent)
|
||||
v := mapItemSummary(item.Edges.Parent)
|
||||
parent = &v
|
||||
}
|
||||
|
||||
return ItemOut{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue