From b2eea4389987d3dabc9484fd02412ac63985b6cb Mon Sep 17 00:00:00 2001 From: "Daniel W. Anner" Date: Thu, 19 Jan 2023 11:40:40 -0500 Subject: [PATCH] Added component definitions to add weight as a valid definition (#1061) Added the required validation information Updated the readme --- README.md | 15 +++++++++++++++ schema/components.json | 21 +++++++++++++++++++++ schema/devicetype.json | 7 +++++++ schema/moduletype.json | 7 +++++++ 4 files changed, 50 insertions(+) diff --git a/README.md b/README.md index 97e2c4fcaa..1e448d92ad 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,21 @@ The following fields may **optionally** be declared: - `comments`: A string field which allows for comments to be added to the device. (**Default: None**) - Type: String > :test_tube: **Example**: `comments: This is a comment that will appear on all NetBox devices of this type` +- `weight`: An array with a **single** item that allow for a value and unit of measurement to be defined. (**Default: None**) + - Type: Array + - Value: Number - must be multiple of 0.01 + - Unit: String + - Options: + - kg + - g + - lb + - oz +>:test_tube: **Example**: +>``` +>weight: +> - value: 12.21 +> unit: lb +>``` For further detail on these attributes and those listed below, please reference the [schema definitions](schema/) and the [Component Definitions](#component-definitions) below. diff --git a/schema/components.json b/schema/components.json index 6124ec86b8..7a174372aa 100644 --- a/schema/components.json +++ b/schema/components.json @@ -594,6 +594,27 @@ } }, "required": ["name"] + }, + + "weight": { + "type": "object", + "properties": { + "value": { + "type": "number", + "minimum": 0, + "multipleOf": 0.01 + }, + "unit": { + "type": "string", + "enum": [ + "kg", + "g", + "lb", + "oz" + ] + } + }, + "required": ["value", "unit"] } } diff --git a/schema/devicetype.json b/schema/devicetype.json index 4b8e7412f7..6b97952329 100644 --- a/schema/devicetype.json +++ b/schema/devicetype.json @@ -33,6 +33,13 @@ "passive" ] }, + "weight": { + "type": "array", + "items": { + "$ref": "components.json#/definitions/weight" + }, + "maxItems": 1 + }, "subdevice_role": { "type": "string", "enum": [ diff --git a/schema/moduletype.json b/schema/moduletype.json index 4b56b37b0c..edd4df8874 100644 --- a/schema/moduletype.json +++ b/schema/moduletype.json @@ -54,6 +54,13 @@ }, "comments": { "type": "string" + }, + "weight": { + "type": "array", + "items": { + "$ref": "components.json#/definitions/weight" + }, + "maxItems": 1 } }, "required": ["manufacturer", "model"],