Skip to content

Commit 3885f36

Browse files
authored
Allow arrays as custom properties (#328)
* Allow arrays as custom properties * Remove unnecessary sentence * Add custom field example to topic get request * Use object instead of string for enum values definition
1 parent 5659983 commit 3885f36

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,25 @@ Project extensions are used to define possible values that can be used in topics
392392
"name": "price_in_dollar",
393393
"type": "decimal",
394394
"readonly": false,
395-
"required": true
395+
"minArraySize": 1,
396+
"maxArraySize": 1
396397
}
397398
]
398399
}
399400

400401
> **About custom fields:** Projects may be configured to allow `custom_fields` in a topic. This is a way of enabling clients and servers to embed custom data in a topic. Those custom fields can be sent when creating or updating a topic, and they will be returned by the server when retrieving topics.
401402
402-
Custom field values are always represented as strings. The type of the custom field indicates how it should be parsed. The value null indicates that it is absent.
403+
Custom field values are always represented as arrays of strings. The type of the custom field indicates how its values should be parsed. Since all custom fields are expressed as arrays, the `minArraySize` and `maxArraySize` properties are used to describe the required cardinality of the field. For example:
404+
405+
|`minArraySize`| `maxArraySize` | Description | Example |
406+
|-|-|-|-|
407+
| `1` | `1` | Single required item | `["My Custom Value"]` |
408+
| `0` | `1` | Single optional item | `[]` or `["My Custom Value"]` |
409+
| `1` | `null` | Multiple required items | `["My Custom Value"]` or `["My Custom Value", "My Other Value"]` |
410+
| `0` | `null` | Multiple optional items | `[]` or `["My Custom Value"]` or `["My Custom Value", "My Other Value"]` |
411+
| `2` | `2` | Two required items | `["My Custom Value", "My Other Value"]` |
412+
413+
The following types are supported:
403414
- integer: A number that does not contain decimals
404415
- decimal: A number than can contain decimals
405416
- string: Any string
@@ -568,7 +579,11 @@ JSON encoded body using the "application/json" content type.
568579
"Architecture",
569580
"Heating"
570581
],
571-
"assigned_to": "[email protected]"
582+
"assigned_to": "[email protected]",
583+
"custom_fields":[{
584+
"id": "6e6bddaa-4c53-4fb8-b884-500e0d2dba6a",
585+
"value": ["19.99"]
586+
}]
572587
}
573588

574589
**Example Response**

Schemas/Collaboration/Topic/custom_field.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"required": false,
88
"type": "string"
99
},
10-
"value": {
10+
"values": {
1111
"required": false,
12-
"type": "string"
12+
"type": "array",
13+
"items": {
14+
"type": "string"
15+
}
1316
}
1417
}
1518
}

Schemas/Project/custom_field.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,30 @@
1818
"required": true,
1919
"type": "boolean"
2020
},
21-
"required": {
21+
"minArraySize": {
2222
"required": true,
23-
"type": "boolean"
23+
"type": "integer"
24+
},
25+
"maxArraySize": {
26+
"required": false,
27+
"type": "integer"
2428
},
2529
"defaultValue": {
26-
"type": "string"
30+
"type": "array",
31+
"items": {
32+
"type": "string"
33+
}
2734
},
2835
"enumValues": {
2936
"type": "array",
3037
"items": {
31-
"type": "string"
38+
"type": "object",
39+
"properties": {
40+
"value": {
41+
"required": true,
42+
"type": "string"
43+
}
44+
}
3245
}
3346
}
3447
}

0 commit comments

Comments
 (0)