Skip to content

Commit

Permalink
Added component definitions to add weight as a valid definition (netb…
Browse files Browse the repository at this point in the history
…ox-community#1061)

Added the required validation information
Updated the readme
  • Loading branch information
danner26 authored and mjpereira602 committed Feb 22, 2023
1 parent 8df83b0 commit 57387a0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions schema/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

}
Expand Down
7 changes: 7 additions & 0 deletions schema/devicetype.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
"passive"
]
},
"weight": {
"type": "array",
"items": {
"$ref": "components.json#/definitions/weight"
},
"maxItems": 1
},
"subdevice_role": {
"type": "string",
"enum": [
Expand Down
7 changes: 7 additions & 0 deletions schema/moduletype.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
},
"comments": {
"type": "string"
},
"weight": {
"type": "array",
"items": {
"$ref": "components.json#/definitions/weight"
},
"maxItems": 1
}
},
"required": ["manufacturer", "model"],
Expand Down

0 comments on commit 57387a0

Please sign in to comment.