BHoM / BHoM/JSONSchema_Toolkit

Should we remove the requirement on properties with default values ?

Offen
#3 0 Kommentare 0 Reaktionen 2 zugewiesene Personen Beansprucht von @IsakNaslundBh Auf GitHub ansehen
type:question
Vorherrschende Sprache
C#
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In the BHoM_UI, users are only required to provide properties that don't have a default value. Considering that the JSON schemas are meant to be used with external partners that don't necessarily have the exact same set of properties as the BHoM, it would be great to do something similar. That way, they can provide only the properties that are relevant within their own environment without having to handle the potential extra richness/complexity that the BHoM might offer.

Here's an example of what I mean. Here's our current schema for a Line:

```json
{
"$id" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Line.json",
"title" : "Line",
"type" : ["object", "null"],
"description" : "Line: A straight segment in space defining the shortest distance between two points in three-dimensional Euclidean geometry.\nThe Vector from Start to End defines the Line direction, which can be important for some applications.",
"properties" : {
"Start" : {
"$ref" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Point.json"
},
"End" : {
"$ref" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Point.json"
},
"Infinite" : {
"type" : "boolean",
"description" : "Defines the Line as a ray of infinite extents in both directions"
},
"_t" : {
"type" : ["string", "null"],
"description" : "Optional type disciminator.",
"const" : "BH.oM.Geometry.Line"
},
"_bhomVersion" : {
"type" : ["string", "null"],
"description" : "Optional version of BHoM used as part of automatic versioning and schema upgrades."
}
},
"required" : ["Start", "End", "Infinite"]
}
```

This means that this would fail the validation as it doesn't contain the `Infinite` property:

```json
{
"_t": "BH.oM.Geometry.Line",
"Start": {
"_t": "BH.oM.Geometry.Point",
"X": 1,
"Y": 2,
"Z": 3
},
"End": {
"_t": "BH.oM.Geometry.Point",
"X": 1,
"Y": 2,
"Z": 3
},
"_bhomVersion": "8.1"
}
```

My issue here is that the BHoM Line would actually be created successfully from the above. So we are enforcing additional constrains that are not a reflection of that would actually work in practice.

I understand that we want to protect the user from incorrectly naming properties. But would it be possible to have warnings instead of errors on properties from the json that are not found on the BHoM object itself? This is what we do in the BHoM_UI and it works quite well that way, providing the best of both worlds.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.