@pdtf/schemas 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -2
- package/package.json +1 -1
- package/src/tests/transactionSchema.test.js +8 -0
package/index.js
CHANGED
|
@@ -40,6 +40,8 @@ const getSubschema = (path) => {
|
|
|
40
40
|
return transactionSchema;
|
|
41
41
|
}
|
|
42
42
|
return pathArray.reduce((schema, pathElement) => {
|
|
43
|
+
if (schema.type === "array") return schema.items;
|
|
44
|
+
if (schema.properties[pathElement]) return schema.properties[pathElement];
|
|
43
45
|
const dependencies = schema.dependencies;
|
|
44
46
|
if (dependencies) {
|
|
45
47
|
// only single dependency discriminator, oneOf keyword is supported
|
|
@@ -50,8 +52,7 @@ const getSubschema = (path) => {
|
|
|
50
52
|
);
|
|
51
53
|
if (matchingOneOf) return matchingOneOf["properties"][pathElement];
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
return schema.properties[pathElement];
|
|
55
|
+
return undefined;
|
|
55
56
|
}, transactionSchema);
|
|
56
57
|
};
|
|
57
58
|
|
package/package.json
CHANGED
|
@@ -102,6 +102,14 @@ test("correctly gets yet another subschema through a dependency", () => {
|
|
|
102
102
|
expect(subschema.title).toBe("Details");
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
test("correctly gets yet, yet another subschema through a dependency", () => {
|
|
106
|
+
const subschema = getSubschema(
|
|
107
|
+
"/propertyPack/materialFacts/listingAndConservation/isConservationArea/yesNo"
|
|
108
|
+
);
|
|
109
|
+
expect(subschema.type).toBe("string");
|
|
110
|
+
expect(subschema.enum).toStrictEqual(["Yes", "No"]);
|
|
111
|
+
});
|
|
112
|
+
|
|
105
113
|
test("correctly gets a subschema validator which is already cached", () => {
|
|
106
114
|
const validator = getSubschemaValidator(
|
|
107
115
|
"/propertyPack/energyPerformanceCertificate"
|