@pdtf/schemas 3.0.0-5 → 3.0.0-7
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 +14 -13
- package/package.json +1 -1
- package/src/examples/v3/exampleTransaction.json +1 -0
- package/src/schemas/v2/overlays/baspi.json +510 -2331
- package/src/schemas/v2/overlays/con29DW.json +36 -125
- package/src/schemas/v2/overlays/con29R.json +5 -143
- package/src/schemas/v2/overlays/fme1.json +48 -233
- package/src/schemas/v2/overlays/lpe1.json +75 -367
- package/src/schemas/v2/overlays/nts.json +17 -103
- package/src/schemas/v2/overlays/piq.json +146 -693
- package/src/schemas/v2/overlays/rds.json +50 -316
- package/src/schemas/v2/overlays/ta10.json +540 -1755
- package/src/schemas/v2/overlays/ta6.json +241 -1193
- package/src/schemas/v2/overlays/ta7.json +106 -440
- package/src/schemas/v3/combined.json +80 -64
- package/src/schemas/v3/overlays/baspi.json +508 -2289
- package/src/schemas/v3/overlays/con29DW.json +36 -125
- package/src/schemas/v3/overlays/con29R.json +5 -143
- package/src/schemas/v3/overlays/fme1.json +53 -233
- package/src/schemas/v3/overlays/lpe1.json +85 -367
- package/src/schemas/v3/overlays/nts.json +131 -367
- package/src/schemas/v3/overlays/piq.json +146 -686
- package/src/schemas/v3/overlays/rds.json +49 -317
- package/src/schemas/v3/overlays/ta10.json +540 -1755
- package/src/schemas/v3/overlays/ta6.json +264 -1146
- package/src/schemas/v3/overlays/ta7.json +220 -462
- package/src/schemas/v3/pdtf-transaction.json +74 -98
- package/src/tests/v3/transactionSchema.test.js +27 -16
- package/src/tests/v3/verifiedClaimsValidator.test.js +2 -2
- package/src/utils/extractOverlay.js +11 -27
- package/src/tests/v2/transactionSchema.test.js +0 -361
- package/src/tests/v2/verifiedClaimsValidator.test.js +0 -128
|
@@ -356,6 +356,7 @@
|
|
|
356
356
|
"type": "object",
|
|
357
357
|
"properties": {
|
|
358
358
|
"propertyType": {
|
|
359
|
+
"title": "Property type",
|
|
359
360
|
"type": "string",
|
|
360
361
|
"enum": [
|
|
361
362
|
"House",
|
|
@@ -1534,13 +1535,11 @@
|
|
|
1534
1535
|
"type": "object",
|
|
1535
1536
|
"properties": {
|
|
1536
1537
|
"isApplicableParty": {
|
|
1537
|
-
"
|
|
1538
|
-
|
|
1539
|
-
"
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
]
|
|
1543
|
-
}
|
|
1538
|
+
"type": "string",
|
|
1539
|
+
"enum": [
|
|
1540
|
+
"true",
|
|
1541
|
+
"false"
|
|
1542
|
+
]
|
|
1544
1543
|
}
|
|
1545
1544
|
},
|
|
1546
1545
|
"oneOf": [
|
|
@@ -1576,13 +1575,11 @@
|
|
|
1576
1575
|
"type": "object",
|
|
1577
1576
|
"properties": {
|
|
1578
1577
|
"isApplicableParty": {
|
|
1579
|
-
"
|
|
1580
|
-
|
|
1581
|
-
"
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
]
|
|
1585
|
-
}
|
|
1578
|
+
"type": "string",
|
|
1579
|
+
"enum": [
|
|
1580
|
+
"true",
|
|
1581
|
+
"false"
|
|
1582
|
+
]
|
|
1586
1583
|
}
|
|
1587
1584
|
},
|
|
1588
1585
|
"oneOf": [
|
|
@@ -1618,13 +1615,11 @@
|
|
|
1618
1615
|
"type": "object",
|
|
1619
1616
|
"properties": {
|
|
1620
1617
|
"isApplicableParty": {
|
|
1621
|
-
"
|
|
1622
|
-
|
|
1623
|
-
"
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
]
|
|
1627
|
-
}
|
|
1618
|
+
"type": "string",
|
|
1619
|
+
"enum": [
|
|
1620
|
+
"true",
|
|
1621
|
+
"false"
|
|
1622
|
+
]
|
|
1628
1623
|
}
|
|
1629
1624
|
},
|
|
1630
1625
|
"oneOf": [
|
|
@@ -1660,13 +1655,11 @@
|
|
|
1660
1655
|
"type": "object",
|
|
1661
1656
|
"properties": {
|
|
1662
1657
|
"isApplicableParty": {
|
|
1663
|
-
"
|
|
1664
|
-
|
|
1665
|
-
"
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
]
|
|
1669
|
-
}
|
|
1658
|
+
"type": "string",
|
|
1659
|
+
"enum": [
|
|
1660
|
+
"true",
|
|
1661
|
+
"false"
|
|
1662
|
+
]
|
|
1670
1663
|
}
|
|
1671
1664
|
},
|
|
1672
1665
|
"oneOf": [
|
|
@@ -1701,13 +1694,11 @@
|
|
|
1701
1694
|
"type": "object",
|
|
1702
1695
|
"properties": {
|
|
1703
1696
|
"isApplicableParty": {
|
|
1704
|
-
"
|
|
1705
|
-
|
|
1706
|
-
"
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
]
|
|
1710
|
-
}
|
|
1697
|
+
"type": "string",
|
|
1698
|
+
"enum": [
|
|
1699
|
+
"true",
|
|
1700
|
+
"false"
|
|
1701
|
+
]
|
|
1711
1702
|
}
|
|
1712
1703
|
},
|
|
1713
1704
|
"oneOf": [
|
|
@@ -3766,13 +3757,11 @@
|
|
|
3766
3757
|
"type": "object",
|
|
3767
3758
|
"properties": {
|
|
3768
3759
|
"isApplicableParty": {
|
|
3769
|
-
"
|
|
3770
|
-
|
|
3771
|
-
"
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
]
|
|
3775
|
-
}
|
|
3760
|
+
"type": "string",
|
|
3761
|
+
"enum": [
|
|
3762
|
+
"true",
|
|
3763
|
+
"false"
|
|
3764
|
+
]
|
|
3776
3765
|
}
|
|
3777
3766
|
},
|
|
3778
3767
|
"oneOf": [
|
|
@@ -3808,13 +3797,11 @@
|
|
|
3808
3797
|
"type": "object",
|
|
3809
3798
|
"properties": {
|
|
3810
3799
|
"isApplicableParty": {
|
|
3811
|
-
"
|
|
3812
|
-
|
|
3813
|
-
"
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
]
|
|
3817
|
-
}
|
|
3800
|
+
"type": "string",
|
|
3801
|
+
"enum": [
|
|
3802
|
+
"true",
|
|
3803
|
+
"false"
|
|
3804
|
+
]
|
|
3818
3805
|
}
|
|
3819
3806
|
},
|
|
3820
3807
|
"oneOf": [
|
|
@@ -3849,13 +3836,11 @@
|
|
|
3849
3836
|
"type": "object",
|
|
3850
3837
|
"properties": {
|
|
3851
3838
|
"isApplicableParty": {
|
|
3852
|
-
"
|
|
3853
|
-
|
|
3854
|
-
"
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
]
|
|
3858
|
-
}
|
|
3839
|
+
"type": "string",
|
|
3840
|
+
"enum": [
|
|
3841
|
+
"true",
|
|
3842
|
+
"false"
|
|
3843
|
+
]
|
|
3859
3844
|
}
|
|
3860
3845
|
},
|
|
3861
3846
|
"oneOf": [
|
|
@@ -3951,13 +3936,11 @@
|
|
|
3951
3936
|
"type": "object",
|
|
3952
3937
|
"properties": {
|
|
3953
3938
|
"isApplicableParty": {
|
|
3954
|
-
"
|
|
3955
|
-
|
|
3956
|
-
"
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
]
|
|
3960
|
-
}
|
|
3939
|
+
"type": "string",
|
|
3940
|
+
"enum": [
|
|
3941
|
+
"true",
|
|
3942
|
+
"false"
|
|
3943
|
+
]
|
|
3961
3944
|
}
|
|
3962
3945
|
},
|
|
3963
3946
|
"oneOf": [
|
|
@@ -3993,13 +3976,11 @@
|
|
|
3993
3976
|
"type": "object",
|
|
3994
3977
|
"properties": {
|
|
3995
3978
|
"isApplicableParty": {
|
|
3996
|
-
"
|
|
3997
|
-
|
|
3998
|
-
"
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
]
|
|
4002
|
-
}
|
|
3979
|
+
"type": "string",
|
|
3980
|
+
"enum": [
|
|
3981
|
+
"true",
|
|
3982
|
+
"false"
|
|
3983
|
+
]
|
|
4003
3984
|
}
|
|
4004
3985
|
},
|
|
4005
3986
|
"oneOf": [
|
|
@@ -4035,13 +4016,11 @@
|
|
|
4035
4016
|
"type": "object",
|
|
4036
4017
|
"properties": {
|
|
4037
4018
|
"isApplicableParty": {
|
|
4038
|
-
"
|
|
4039
|
-
|
|
4040
|
-
"
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
]
|
|
4044
|
-
}
|
|
4019
|
+
"type": "string",
|
|
4020
|
+
"enum": [
|
|
4021
|
+
"true",
|
|
4022
|
+
"false"
|
|
4023
|
+
]
|
|
4045
4024
|
}
|
|
4046
4025
|
},
|
|
4047
4026
|
"oneOf": [
|
|
@@ -4077,13 +4056,11 @@
|
|
|
4077
4056
|
"type": "object",
|
|
4078
4057
|
"properties": {
|
|
4079
4058
|
"isApplicableParty": {
|
|
4080
|
-
"
|
|
4081
|
-
|
|
4082
|
-
"
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
]
|
|
4086
|
-
}
|
|
4059
|
+
"type": "string",
|
|
4060
|
+
"enum": [
|
|
4061
|
+
"true",
|
|
4062
|
+
"false"
|
|
4063
|
+
]
|
|
4087
4064
|
}
|
|
4088
4065
|
},
|
|
4089
4066
|
"oneOf": [
|
|
@@ -4118,13 +4095,11 @@
|
|
|
4118
4095
|
"type": "object",
|
|
4119
4096
|
"properties": {
|
|
4120
4097
|
"isApplicableParty": {
|
|
4121
|
-
"
|
|
4122
|
-
|
|
4123
|
-
"
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
]
|
|
4127
|
-
}
|
|
4098
|
+
"type": "string",
|
|
4099
|
+
"enum": [
|
|
4100
|
+
"true",
|
|
4101
|
+
"false"
|
|
4102
|
+
]
|
|
4128
4103
|
}
|
|
4129
4104
|
},
|
|
4130
4105
|
"oneOf": [
|
|
@@ -6997,7 +6972,7 @@
|
|
|
6997
6972
|
]
|
|
6998
6973
|
},
|
|
6999
6974
|
"details": {
|
|
7000
|
-
"title": "Please provide details of the listing
|
|
6975
|
+
"title": "Please provide details of the listing",
|
|
7001
6976
|
"type": "string",
|
|
7002
6977
|
"minLength": 1
|
|
7003
6978
|
},
|
|
@@ -7046,7 +7021,7 @@
|
|
|
7046
7021
|
]
|
|
7047
7022
|
},
|
|
7048
7023
|
"details": {
|
|
7049
|
-
"title": "Please provide details of the listing
|
|
7024
|
+
"title": "Please provide details of the listing",
|
|
7050
7025
|
"type": "string",
|
|
7051
7026
|
"minLength": 1
|
|
7052
7027
|
},
|
|
@@ -16260,7 +16235,7 @@
|
|
|
16260
16235
|
]
|
|
16261
16236
|
},
|
|
16262
16237
|
"details": {
|
|
16263
|
-
"title": "
|
|
16238
|
+
"title": "Details",
|
|
16264
16239
|
"type": "string"
|
|
16265
16240
|
},
|
|
16266
16241
|
"supplier": {
|
|
@@ -16634,7 +16609,7 @@
|
|
|
16634
16609
|
]
|
|
16635
16610
|
},
|
|
16636
16611
|
"mainsFoulDrainage": {
|
|
16637
|
-
"title": "Mains foul drainage /
|
|
16612
|
+
"title": "Mains foul drainage / sewerage",
|
|
16638
16613
|
"type": "object",
|
|
16639
16614
|
"properties": {
|
|
16640
16615
|
"yesNo": {
|
|
@@ -17529,6 +17504,7 @@
|
|
|
17529
17504
|
"Electricity",
|
|
17530
17505
|
"Oil",
|
|
17531
17506
|
"LPG",
|
|
17507
|
+
"Biomass",
|
|
17532
17508
|
"Other"
|
|
17533
17509
|
]
|
|
17534
17510
|
}
|
|
@@ -17542,7 +17518,7 @@
|
|
|
17542
17518
|
"Electricity",
|
|
17543
17519
|
"Oil",
|
|
17544
17520
|
"LPG",
|
|
17545
|
-
"Biomass
|
|
17521
|
+
"Biomass"
|
|
17546
17522
|
]
|
|
17547
17523
|
}
|
|
17548
17524
|
}
|
|
@@ -18268,12 +18244,12 @@
|
|
|
18268
18244
|
]
|
|
18269
18245
|
},
|
|
18270
18246
|
"details": {
|
|
18271
|
-
"title": "Please provide details
|
|
18247
|
+
"title": "Please provide details",
|
|
18272
18248
|
"type": "string",
|
|
18273
18249
|
"minLength": 1
|
|
18274
18250
|
},
|
|
18275
18251
|
"attachments": {
|
|
18276
|
-
"title": "
|
|
18252
|
+
"title": "Please mark the route on a plan of the property",
|
|
18277
18253
|
"type": "string",
|
|
18278
18254
|
"enum": [
|
|
18279
18255
|
"Attached",
|
|
@@ -11,23 +11,24 @@ const {
|
|
|
11
11
|
} = require("../../../index.js");
|
|
12
12
|
|
|
13
13
|
const exampleTransaction = require("../../examples/v3/exampleTransaction.json");
|
|
14
|
+
|
|
14
15
|
const schemaId =
|
|
15
16
|
"https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json";
|
|
16
17
|
// const validator = getValidator(schemaId);
|
|
17
18
|
const v3TransactionSchema = getTransactionSchema(schemaId);
|
|
18
19
|
|
|
19
|
-
test("exports a property pack schema, v3 with
|
|
20
|
-
const testSchema = getTransactionSchema();
|
|
21
|
-
expect(testSchema.$id).toEqual(
|
|
22
|
-
|
|
23
|
-
);
|
|
20
|
+
test("exports a property pack schema, v3 with no overlay by default", () => {
|
|
21
|
+
const testSchema = getTransactionSchema(schemaId);
|
|
22
|
+
// expect(testSchema.$id).toEqual(
|
|
23
|
+
// "https://trust.propdata.org.uk/schemas/v3/pdtf-transaction.json"
|
|
24
|
+
// );
|
|
24
25
|
expect(
|
|
25
26
|
testSchema.properties.propertyPack.properties.materialFacts.baspiRef
|
|
26
|
-
).toEqual(
|
|
27
|
+
).toEqual(undefined);
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test("sample is valid BASPI", () => {
|
|
30
|
-
const testSchema = getTransactionSchema();
|
|
31
|
+
const testSchema = getTransactionSchema(schemaId, ["baspiV4"]);
|
|
31
32
|
expect(
|
|
32
33
|
testSchema.properties.propertyPack.properties.materialFacts.baspiRef
|
|
33
34
|
).toEqual("A");
|
|
@@ -49,7 +50,7 @@ test("invalid sample is invalid", () => {
|
|
|
49
50
|
JSON.stringify(exampleTransaction)
|
|
50
51
|
);
|
|
51
52
|
delete clonedExampleTransaction.propertyPack.materialFacts.notices;
|
|
52
|
-
const validator = getValidator(schemaId);
|
|
53
|
+
const validator = getValidator(schemaId, ["baspiV4"]);
|
|
53
54
|
const isValid = validator(clonedExampleTransaction);
|
|
54
55
|
expect(isValid).toBe(false);
|
|
55
56
|
});
|
|
@@ -166,6 +167,15 @@ test("correctly gets yes another subschema but through a non-baspi oneOf structu
|
|
|
166
167
|
expect(subschema).toEqual({ type: "string" });
|
|
167
168
|
});
|
|
168
169
|
|
|
170
|
+
test("correctly gets an overlaid enum in a subschema", () => {
|
|
171
|
+
const subschema = getSubschema(
|
|
172
|
+
"/propertyPack/materialFacts/connectedUtilities/mainsElectricity/yesNo",
|
|
173
|
+
schemaId,
|
|
174
|
+
["nts2023"]
|
|
175
|
+
);
|
|
176
|
+
expect(subschema.enum).toEqual(["Yes", "No"]);
|
|
177
|
+
});
|
|
178
|
+
|
|
169
179
|
test("correctly gets a subschema with multiple overlays", () => {
|
|
170
180
|
const subschema = getSubschema(
|
|
171
181
|
"/propertyPack/materialFacts/parking/parkingArrangements",
|
|
@@ -267,14 +277,14 @@ test("correctly gets a subschema validator for an NTS overlay", () => {
|
|
|
267
277
|
expect(isValid).toBe(true);
|
|
268
278
|
});
|
|
269
279
|
|
|
270
|
-
test("correctly gets a subschema validator for an
|
|
280
|
+
test("correctly gets a subschema validator for an TA7 overlay", () => {
|
|
271
281
|
const path = "/propertyPack";
|
|
272
282
|
const clonedExampleTransaction = JSON.parse(
|
|
273
283
|
JSON.stringify(exampleTransaction)
|
|
274
284
|
);
|
|
275
285
|
const data = jp.get(clonedExampleTransaction, path);
|
|
276
286
|
const validator = getSubschemaValidator(path, exampleTransaction.$schema, [
|
|
277
|
-
"
|
|
287
|
+
"ta7ed3",
|
|
278
288
|
]);
|
|
279
289
|
let isValid = validator(data);
|
|
280
290
|
expect(isValid).toBe(false);
|
|
@@ -299,48 +309,49 @@ test("correctly gets titles across schemas, arrays and non-existient title prope
|
|
|
299
309
|
"/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/ownershipType"
|
|
300
310
|
)
|
|
301
311
|
).toBe("What type of ownership is the property?");
|
|
312
|
+
|
|
302
313
|
expect(
|
|
303
314
|
getTitleAtPath(
|
|
304
315
|
v3TransactionSchema,
|
|
305
316
|
"/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/leaseTerm/lengthOfLeaseInYears"
|
|
306
317
|
)
|
|
307
318
|
).toBe("Length of lease (years)");
|
|
308
|
-
|
|
309
|
-
getTitleAtPath(
|
|
310
|
-
v3TransactionSchema,
|
|
311
|
-
"/propertyPack/materialFacts/ownership/ownershipsToBeTransferred/0/leaseholdInformation/serviceCharge/annualServiceCharge"
|
|
312
|
-
)
|
|
313
|
-
).toBe("Amount of current annual service charge (£)");
|
|
319
|
+
|
|
314
320
|
expect(
|
|
315
321
|
getTitleAtPath(
|
|
316
322
|
v3TransactionSchema,
|
|
317
323
|
"/propertyPack/materialFacts/invalidPath"
|
|
318
324
|
)
|
|
319
325
|
).toBe(undefined);
|
|
326
|
+
|
|
320
327
|
expect(
|
|
321
328
|
getTitleAtPath(
|
|
322
329
|
v3TransactionSchema,
|
|
323
330
|
"/propertyPack/titlesToBeSold/0/registerExtract"
|
|
324
331
|
)
|
|
325
332
|
).toBe("HMLR Official Copy Register Extract");
|
|
333
|
+
|
|
326
334
|
expect(
|
|
327
335
|
getTitleAtPath(
|
|
328
336
|
v3TransactionSchema,
|
|
329
337
|
"/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/PropertyAddress"
|
|
330
338
|
)
|
|
331
339
|
).toBe("Property address");
|
|
340
|
+
|
|
332
341
|
expect(
|
|
333
342
|
getTitleAtPath(
|
|
334
343
|
v3TransactionSchema,
|
|
335
344
|
"/propertyPack/titlesToBeSold/0/registerExtract/OCSummaryData/InvalidProp"
|
|
336
345
|
)
|
|
337
346
|
).toBe(undefined);
|
|
347
|
+
|
|
338
348
|
expect(
|
|
339
349
|
getTitleAtPath(
|
|
340
350
|
v3TransactionSchema,
|
|
341
351
|
"/propertyPack/materialFacts/energyEfficiency/certificate/currentEnergyRating"
|
|
342
352
|
)
|
|
343
353
|
).toBe("Current energy efficiency rating");
|
|
354
|
+
|
|
344
355
|
expect(
|
|
345
356
|
getTitleAtPath(
|
|
346
357
|
v3TransactionSchema,
|
|
@@ -27,14 +27,14 @@ test("returns an array with an error stating if path is incorrect", () => {
|
|
|
27
27
|
]);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test("returns errors if BASPI requirements are not met and BASPI overlay is specified
|
|
30
|
+
test("returns errors if BASPI requirements are not met and BASPI overlay is specified", () => {
|
|
31
31
|
const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
|
|
32
32
|
clonedVouch.claims = {
|
|
33
33
|
"/propertyPack/materialFacts/delayFactors": {
|
|
34
34
|
hasDelayFactors: { yesNo: "Yes" },
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
const errors = validateVerifiedClaims([clonedVouch], v3SchemaId);
|
|
37
|
+
const errors = validateVerifiedClaims([clonedVouch], v3SchemaId, ["baspiV4"]);
|
|
38
38
|
expect(errors).toEqual([
|
|
39
39
|
{
|
|
40
40
|
instancePath: "/hasDelayFactors",
|
|
@@ -23,30 +23,15 @@ const extractFields = [
|
|
|
23
23
|
];
|
|
24
24
|
|
|
25
25
|
const overlayIncludeProperties = [
|
|
26
|
-
"title",
|
|
27
|
-
"description",
|
|
28
|
-
"enum",
|
|
26
|
+
// "title",
|
|
27
|
+
// "description",
|
|
28
|
+
// "enum",
|
|
29
29
|
"discriminator",
|
|
30
|
-
"minItems",
|
|
30
|
+
// "minItems",
|
|
31
31
|
];
|
|
32
32
|
|
|
33
|
-
const combineMerge = (target, source, options) => {
|
|
34
|
-
const destination = target.slice();
|
|
35
|
-
source.forEach((item, index) => {
|
|
36
|
-
if (typeof destination[index] === "undefined") {
|
|
37
|
-
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
|
38
|
-
} else if (options.isMergeableObject(item)) {
|
|
39
|
-
destination[index] = merge(target[index], item, options);
|
|
40
|
-
} else if (target.indexOf(item) === -1) {
|
|
41
|
-
destination.push(item);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return destination;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
33
|
const flattenSkeleton = (schema) => {
|
|
48
34
|
if (!schema) return undefined;
|
|
49
|
-
// console.log(schema.properties);
|
|
50
35
|
let returnStructure = {};
|
|
51
36
|
if (schema.properties) {
|
|
52
37
|
Object.keys(schema.properties).forEach((key) => {
|
|
@@ -55,10 +40,8 @@ const flattenSkeleton = (schema) => {
|
|
|
55
40
|
}
|
|
56
41
|
if (schema.oneOf) {
|
|
57
42
|
schema.oneOf.forEach((aOneOf) => {
|
|
58
|
-
// console.log(aOneOf);
|
|
59
43
|
if (aOneOf.properties) {
|
|
60
44
|
Object.entries(aOneOf.properties).forEach(([key, value]) => {
|
|
61
|
-
// console.log(aProperty);
|
|
62
45
|
returnStructure[key] = flattenSkeleton(value);
|
|
63
46
|
});
|
|
64
47
|
}
|
|
@@ -105,6 +88,11 @@ const extractOverlay = (sourceSchema, ref) => {
|
|
|
105
88
|
// if a refEnum use that
|
|
106
89
|
const refEnum = `${ref}Enum`;
|
|
107
90
|
if (discriminatorProperty[refEnum]) {
|
|
91
|
+
// console.log(
|
|
92
|
+
// "Found refEnum",
|
|
93
|
+
// discriminatorProperty[refEnum],
|
|
94
|
+
// path
|
|
95
|
+
// );
|
|
108
96
|
jp.set(
|
|
109
97
|
returnSchema,
|
|
110
98
|
discriminatorEnumPath,
|
|
@@ -112,6 +100,7 @@ const extractOverlay = (sourceSchema, ref) => {
|
|
|
112
100
|
);
|
|
113
101
|
} else {
|
|
114
102
|
// use the base enum
|
|
103
|
+
// console.log("Found base enum", discriminatorProperty.enum, path);
|
|
115
104
|
jp.set(
|
|
116
105
|
returnSchema,
|
|
117
106
|
discriminatorEnumPath,
|
|
@@ -153,12 +142,7 @@ const deleteProperties = (sourceSchema, propertyNames) => {
|
|
|
153
142
|
const overlays = {};
|
|
154
143
|
|
|
155
144
|
extractFields.forEach((key) => {
|
|
156
|
-
let overlay = extractOverlay(combinedSchema, key
|
|
157
|
-
"title",
|
|
158
|
-
"description",
|
|
159
|
-
"enum",
|
|
160
|
-
"discriminator",
|
|
161
|
-
]);
|
|
145
|
+
let overlay = extractOverlay(combinedSchema, key);
|
|
162
146
|
overlays[key] = overlay;
|
|
163
147
|
const fileName = `../schemas/v3/overlays/${key}.json`;
|
|
164
148
|
fs.writeFileSync(fileName, JSON.stringify(overlay, null, 2));
|