Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

fix: API should expect actual floats now

Matt Kilgore908bfb530ebd
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go
index b5fa2dcb..79d62ccc 100644
--- a/backend/app/api/static/docs/docs.go
+++ b/backend/app/api/static/docs/docs.go
@@ -2347,6 +2347,9 @@ const docTemplate = `{
},
"repo.ItemUpdate": {
"type": "object",
+ "required": [
+ "name"
+ ],
"properties": {
"archived": {
"type": "boolean"
@@ -2355,7 +2358,8 @@ const docTemplate = `{
"type": "string"
},
"description": {
- "type": "string"
+ "type": "string",
+ "maxLength": 1000
},
"fields": {
"type": "array",
@@ -2390,7 +2394,9 @@ const docTemplate = `{
"type": "string"
},
"name": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
},
"notes": {
"description": "Extras",
@@ -2402,11 +2408,11 @@ const docTemplate = `{
"x-omitempty": true
},
"purchaseFrom": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255
},
"purchasePrice": {
- "type": "string",
- "example": "0"
+ "type": "number"
},
"purchaseTime": {
"description": "Purchase",
@@ -2423,15 +2429,15 @@ const docTemplate = `{
"type": "string"
},
"soldPrice": {
- "type": "string",
- "example": "0"
+ "type": "number"
},
"soldTime": {
"description": "Sold",
"type": "string"
},
"soldTo": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255
},
"warrantyDetails": {
"type": "string"
@@ -2763,7 +2769,6 @@ const docTemplate = `{
"type": "string"
},
"url": {
- "description": "URL field is not exposed to the client",
"type": "string"
},
"userId": {
diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json
index 12e556ce..addf7280 100644
--- a/backend/app/api/static/docs/swagger.json
+++ b/backend/app/api/static/docs/swagger.json
@@ -2340,6 +2340,9 @@
},
"repo.ItemUpdate": {
"type": "object",
+ "required": [
+ "name"
+ ],
"properties": {
"archived": {
"type": "boolean"
@@ -2348,7 +2351,8 @@
"type": "string"
},
"description": {
- "type": "string"
+ "type": "string",
+ "maxLength": 1000
},
"fields": {
"type": "array",
@@ -2383,7 +2387,9 @@
"type": "string"
},
"name": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
},
"notes": {
"description": "Extras",
@@ -2395,11 +2401,11 @@
"x-omitempty": true
},
"purchaseFrom": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255
},
"purchasePrice": {
- "type": "string",
- "example": "0"
+ "type": "number"
},
"purchaseTime": {
"description": "Purchase",
@@ -2416,15 +2422,15 @@
"type": "string"
},
"soldPrice": {
- "type": "string",
- "example": "0"
+ "type": "number"
},
"soldTime": {
"description": "Sold",
"type": "string"
},
"soldTo": {
- "type": "string"
+ "type": "string",
+ "maxLength": 255
},
"warrantyDetails": {
"type": "string"
@@ -2756,7 +2762,6 @@
"type": "string"
},
"url": {
- "description": "URL field is not exposed to the client",
"type": "string"
},
"userId": {
diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml
index e663b6a6..a7211acb 100644
--- a/backend/app/api/static/docs/swagger.yaml
+++ b/backend/app/api/static/docs/swagger.yaml
@@ -264,6 +264,7 @@ definitions:
assetId:
type: string
description:
+ maxLength: 1000
type: string
fields:
items:
@@ -288,6 +289,8 @@ definitions:
modelNumber:
type: string
name:
+ maxLength: 255
+ minLength: 1
type: string
notes:
description: Extras
@@ -297,10 +300,10 @@ definitions:
x-nullable: true
x-omitempty: true
purchaseFrom:
+ maxLength: 255
type: string
purchasePrice:
- example: "0"
- type: string
+ type: number
purchaseTime:
description: Purchase
type: string
@@ -312,17 +315,19 @@ definitions:
soldNotes:
type: string
soldPrice:
- example: "0"
- type: string
+ type: number
soldTime:
description: Sold
type: string
soldTo:
+ maxLength: 255
type: string
warrantyDetails:
type: string
warrantyExpires:
type: string
+ required:
+ - name
type: object
repo.LabelCreate:
properties:
@@ -540,7 +545,6 @@ definitions:
updatedAt:
type: string
url:
- description: URL field is not exposed to the client
type: string
userId:
type: string
diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go
index 73d72a89..d67a60a3 100644
--- a/backend/internal/data/repo/repo_items.go
+++ b/backend/internal/data/repo/repo_items.go
@@ -93,12 +93,12 @@ type (
// Purchase
PurchaseTime types.Date `json:"purchaseTime"`
PurchaseFrom string `json:"purchaseFrom" validate:"max=255"`
- PurchasePrice float64 `json:"purchasePrice,string"`
+ PurchasePrice float64 `json:"purchasePrice"`
// Sold
SoldTime types.Date `json:"soldTime"`
SoldTo string `json:"soldTo" validate:"max=255"`
- SoldPrice float64 `json:"soldPrice,string"`
+ SoldPrice float64 `json:"soldPrice"`
SoldNotes string `json:"soldNotes"`
// Extras
diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts
index f56ffae1..952e4f1e 100644
--- a/frontend/lib/api/types/data-contracts.ts
+++ b/frontend/lib/api/types/data-contracts.ts
@@ -159,6 +159,7 @@ export enum ItemType {
export interface ItemUpdate {
archived: boolean;
assetId: string;
+ /** @maxLength 1000 */
description: string;
fields: ItemField[];
id: string;
@@ -170,23 +171,27 @@ export interface ItemUpdate {
locationId: string;
manufacturer: string;
modelNumber: string;
+ /**
+ * @minLength 1
+ * @maxLength 255
+ */
name: string;
/** Extras */
notes: string;
parentId?: string | null;
+ /** @maxLength 255 */
purchaseFrom: string;
- /** @example "0" */
- purchasePrice: string;
+ purchasePrice: number;
/** Purchase */
purchaseTime: Date | string;
quantity: number;
/** Identifications */
serialNumber: string;
soldNotes: string;
- /** @example "0" */
- soldPrice: string;
+ soldPrice: number;
/** Sold */
soldTime: Date | string;
+ /** @maxLength 255 */
soldTo: string;
warrantyDetails: string;
warrantyExpires: Date | string;
@@ -323,7 +328,6 @@ export interface NotifierOut {
isActive: boolean;
name: string;
updatedAt: Date | string;
- /** URL field is not exposed to the client */
url: string;
userId: string;
}