You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,71 +14,73 @@ The BHoM JSON schemas make use of [references ($ref)](https://json-schema.org/un
14
14
A major benfit of using this type of structure is that in reduces the size and complexity of the schemas, especially for cases when a property is targeting an [interface](#interfaces).
15
15
16
16
#### Properties
17
-
For properties that target another IObject, the property is linked across via $ref. As an example, the [Line](https://bhom.xyz/api/oM/Dimensional/Geometry/Curve/Line/) class has two properties, start and end, that are of type [Point](https://bhom.xyz/api/oM/Dimensional/Geometry/Vector/Point/). These properties are referenced in via the ref keyword:
17
+
For properties that target another IObject, the property is linked across via $ref. This allows for greater flexibility as well as simpler composition, especially for more complex schemas. As an example, the [Line](https://bhom.xyz/api/oM/Dimensional/Geometry/Curve/Line/) class has two properties, start and end, that are of type [Point](https://bhom.xyz/api/oM/Dimensional/Geometry/Vector/Point/). These properties are referenced in via the ref keyword:
"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.",
"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.",
"description" : "Point: Defines a dimensionless location in three-dimensional space.",
58
+
"properties" : {
59
+
"X" : {
60
+
"type" : "number",
61
+
"description" : "Position along global X coordinate axis."
62
+
},
63
+
"Y" : {
64
+
"type" : "number",
65
+
"description" : "Position along global Y coordinate axis."
66
+
},
67
+
"Z" : {
68
+
"type" : "number",
69
+
"description" : "Position along global Z coordinate axis."
70
+
},
71
+
"_t" : {
72
+
"type" : ["string", "null"],
73
+
"description" : "Optional type disciminator.",
74
+
"const" : "BH.oM.Geometry.Point"
75
+
},
76
+
"_bhomVersion" : {
77
+
"type" : ["string", "null"],
78
+
"description" : "Optional version of BHoM used as part of automatic versioning and schema upgrades."
79
+
}
73
80
},
74
-
"_bhomVersion" : {
75
-
"type" : ["string", "null"],
76
-
"description" : "Optional version of BHoM used as part of automatic versioning and schema upgrades."
81
+
"required" : ["X", "Y", "Z"]
77
82
}
78
-
},
79
-
"required" : ["X", "Y", "Z"]
80
-
}
81
-
```
83
+
```
82
84
83
85
In the example above, you can see that the Point class is referenced across using the $ref keyword, and that the $id of the point is exactly matching the ref used.
84
86
@@ -90,7 +92,7 @@ For a json object to validate against a interface schema it requires the type di
90
92
!!! note
91
93
The type discriminator "_t" is not generally set as required across the BHoM JSON schemas for validation against a known class schema. When validating against a interface schema, at base level or as a property, however it is required to determine the schema to validate against.
92
94
93
-
!!! note
95
+
!!! warning
94
96
To successfully evaluate a type that is implementing an interface agaist the schema of that interface, the subtype needs to known at the point of creation of the interface schema. This means a class in a repo not set to be part of the [generation](#generation) wont be able to be validated against its base interface, even if it is implementing that inferface in C#.
95
97
96
98
It then uses the [if then + all of](https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse) pattern to validate the object against the appropriate type.
@@ -107,44 +109,46 @@ Then the all-of + if-the pattern follows, which can be read as: If the value `"_
107
109
108
110
The initial part of requiring `"_t"` to exist and match one of the types guarantiues that only valid types are validated as correct. The allOf if, then ensures that this subtime is valid against the matching schema.
0 commit comments