Skip to content

Commit

Permalink
Add properties to schema (#222)
Browse files Browse the repository at this point in the history
* Add properties to schema

* Add `id` to property, and make property value of type string for easier model binding

* Add bool to configure if additional (not specified) properties are allowed

* Add properties to property (😀) as discussed in todays call

* Add properties to topic PUT and POST models

* Add required attributes

* Rename property to custom_field

* Add info about custom fields to README

* Do not allow additional properties flag in extensions

* Add id to field definition in extensions

* Remove name property of custom field instance in topic

* Add description to custom field object

* Update README.md

* Update README.md

---------

Co-authored-by: Georg Dangl <[email protected]>
  • Loading branch information
jasollien and GeorgDangl authored May 22, 2023
1 parent 74abd55 commit 84af26d
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,29 @@ Project extensions are used to define possible values that can be used in topics
],
"comment_actions": [
"update"
],
"custom_fields": [
{
"id": "6e6bddaa-4c53-4fb8-b884-500e0d2dba6a",
"name": "price_in_dollar",
"type": "decimal",
"readonly": false,
"required": true
}
]
}

> **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.
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.
- integer: A number that does not contain decimals
- decimal: A number than can contain decimals
- string: Any string
- boolean: The values 'true' or 'false'
- enum: A value from the predefined enumValues array
- date-time: ISO 8601 compliant date: https://github.com/buildingSMART/foundation-API#17-datetime-format


### 3.1.5 Expressing User Authorization Through Project Extensions

Global default authorizations for the requesting user can be expressed in the project schema. The actions authorized
Expand Down Expand Up @@ -529,6 +549,10 @@ JSON encoded body using the "application/json" content type.
|bim_snippet.reference|string|Reference of a BIM-Snippet of a topic|false|
|bim_snippet.reference_schema|string|Schema of a BIM-Snippet of a topic|false|
|due_date|string|Until when the topics issue needs to be resolved|false|
| custom_fields| array (object) | Custom fields of a topic | false |

> `custom_fields` are an optional array property that can be used by clients to attach custom data to a topic. The server should return the same array in the response. The array may be empty. It should contain the custom fields as defined in the project extensions.
> The `id` property of each custom field object is used to identify a field within a project. When creating or updating a topic, the `id` property from the extensions must be provided.
_Note: If "bim_snippet" is present, then all four properties (`snippet_type`, `is_external`, `reference` and `reference_schema`) are mandatory._

Expand Down
15 changes: 15 additions & 0 deletions Schemas_draft-03/Collaboration/Topic/custom_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"title": "custom_field",
"type": ["object"],
"properties": {
"id": {
"description": "Refers to the id of the custom field in the project extensions.",
"required": false,
"type": "string"
},
"value": {
"required": false,
"type": "string"
}
}
}
7 changes: 7 additions & 0 deletions Schemas_draft-03/Collaboration/Topic/custom_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "custom_fields",
"type": ["array"],
"items": {
"$ref": "custom_field.json"
}
}
3 changes: 3 additions & 0 deletions Schemas_draft-03/Collaboration/Topic/topic_GET.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
"type": ["string",
"null"]
},
"custom_fields": {
"$ref": "custom_fields.json"
},
"authorization": {
"type": "object",
"required": false,
Expand Down
3 changes: 3 additions & 0 deletions Schemas_draft-03/Collaboration/Topic/topic_POST.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
"due_date": {
"type": ["string",
"null"]
},
"custom_fields": {
"$ref": "custom_fields.json"
}
}
}
3 changes: 3 additions & 0 deletions Schemas_draft-03/Collaboration/Topic/topic_PUT.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"due_date": {
"type": ["string",
"null"]
},
"custom_fields": {
"$ref": "custom_fields.json"
}
}
}
35 changes: 35 additions & 0 deletions Schemas_draft-03/Project/custom_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"title": "custom_field",
"type": "object",
"properties": {
"id": {
"required": true,
"type": "string"
},
"name": {
"required": true,
"type": "string"
},
"type": {
"required": true,
"enum": ["integer", "decimal", "string", "boolean", "enum", "date", "date-time"]
},
"readonly": {
"required": true,
"type": "boolean"
},
"required": {
"required": true,
"type": "boolean"
},
"defaultValue": {
"type": "string"
},
"enumValues": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
6 changes: 6 additions & 0 deletions Schemas_draft-03/Project/extensions_GET.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
},
"comment_actions": {
"$ref": "../Collaboration/Action/comment_actions.json"
},
"custom_fields": {
"type": ["array"],
"items": {
"$ref": "custom_field.json"
}
}
}
}

0 comments on commit 84af26d

Please sign in to comment.