Skip to content

Commit ffc4b34

Browse files
committed
[TASK] Add Schema for overrideType
1 parent 276e441 commit ffc4b34

File tree

9 files changed

+286
-0
lines changed

9 files changed

+286
-0
lines changed

Build/JsonSchema/SchemaSources/FieldTypes/collection.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,27 @@
327327
"items": {
328328
"$ref": "../field-type.json"
329329
}
330+
},
331+
"overrideType": {
332+
"oneOf": [
333+
{
334+
"type": "object",
335+
"patternProperties": {
336+
".*": {
337+
"type": "array",
338+
"items": {
339+
"$ref": "../field-type.json"
340+
}
341+
}
342+
}
343+
},
344+
{
345+
"type": "array",
346+
"items": {
347+
"$ref": "../field-type.json"
348+
}
349+
}
350+
]
330351
}
331352
}
332353
}

Build/JsonSchema/SchemaSources/FieldTypes/file.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@
294294
"relationship": {
295295
"type": "string",
296296
"enum": ["oneToOne", "oneToMany"]
297+
},
298+
"overrideType": {
299+
"type": "object",
300+
"additionalProperties": false,
301+
"patternProperties": {
302+
"image|text|video|audio|application": {
303+
"type": "array",
304+
"items": {
305+
"$ref": "../field-type.json"
306+
}
307+
}
308+
}
297309
}
298310
}
299311
}

JsonSchema/basic.schema.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,18 @@
26572657
"oneToOne",
26582658
"oneToMany"
26592659
]
2660+
},
2661+
"overrideType": {
2662+
"type": "object",
2663+
"additionalProperties": false,
2664+
"patternProperties": {
2665+
"image|text|video|audio|application": {
2666+
"type": "array",
2667+
"items": {
2668+
"$ref": "#/properties/fields/items"
2669+
}
2670+
}
2671+
}
26602672
}
26612673
}
26622674
}
@@ -4442,6 +4454,27 @@
44424454
"items": {
44434455
"$ref": "#/properties/fields/items"
44444456
}
4457+
},
4458+
"overrideType": {
4459+
"oneOf": [
4460+
{
4461+
"type": "object",
4462+
"patternProperties": {
4463+
".*": {
4464+
"type": "array",
4465+
"items": {
4466+
"$ref": "#/properties/fields/items"
4467+
}
4468+
}
4469+
}
4470+
},
4471+
{
4472+
"type": "array",
4473+
"items": {
4474+
"$ref": "#/properties/fields/items"
4475+
}
4476+
}
4477+
]
44454478
}
44464479
}
44474480
}

JsonSchema/content-element.schema.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,18 @@
27592759
"oneToOne",
27602760
"oneToMany"
27612761
]
2762+
},
2763+
"overrideType": {
2764+
"type": "object",
2765+
"additionalProperties": false,
2766+
"patternProperties": {
2767+
"image|text|video|audio|application": {
2768+
"type": "array",
2769+
"items": {
2770+
"$ref": "#/allOf/1/properties/fields/items"
2771+
}
2772+
}
2773+
}
27622774
}
27632775
}
27642776
}
@@ -4544,6 +4556,27 @@
45444556
"items": {
45454557
"$ref": "#/allOf/1/properties/fields/items"
45464558
}
4559+
},
4560+
"overrideType": {
4561+
"oneOf": [
4562+
{
4563+
"type": "object",
4564+
"patternProperties": {
4565+
".*": {
4566+
"type": "array",
4567+
"items": {
4568+
"$ref": "#/allOf/1/properties/fields/items"
4569+
}
4570+
}
4571+
}
4572+
},
4573+
{
4574+
"type": "array",
4575+
"items": {
4576+
"$ref": "#/allOf/1/properties/fields/items"
4577+
}
4578+
}
4579+
]
45474580
}
45484581
}
45494582
}

JsonSchema/file-type.schema.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,18 @@
26992699
"oneToOne",
27002700
"oneToMany"
27012701
]
2702+
},
2703+
"overrideType": {
2704+
"type": "object",
2705+
"additionalProperties": false,
2706+
"patternProperties": {
2707+
"image|text|video|audio|application": {
2708+
"type": "array",
2709+
"items": {
2710+
"$ref": "#/properties/fields/items"
2711+
}
2712+
}
2713+
}
27022714
}
27032715
}
27042716
}
@@ -4484,6 +4496,27 @@
44844496
"items": {
44854497
"$ref": "#/properties/fields/items"
44864498
}
4499+
},
4500+
"overrideType": {
4501+
"oneOf": [
4502+
{
4503+
"type": "object",
4504+
"patternProperties": {
4505+
".*": {
4506+
"type": "array",
4507+
"items": {
4508+
"$ref": "#/properties/fields/items"
4509+
}
4510+
}
4511+
}
4512+
},
4513+
{
4514+
"type": "array",
4515+
"items": {
4516+
"$ref": "#/properties/fields/items"
4517+
}
4518+
}
4519+
]
44874520
}
44884521
}
44894522
}

JsonSchema/page-type.schema.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,18 @@
27422742
"oneToOne",
27432743
"oneToMany"
27442744
]
2745+
},
2746+
"overrideType": {
2747+
"type": "object",
2748+
"additionalProperties": false,
2749+
"patternProperties": {
2750+
"image|text|video|audio|application": {
2751+
"type": "array",
2752+
"items": {
2753+
"$ref": "#/allOf/1/properties/fields/items"
2754+
}
2755+
}
2756+
}
27452757
}
27462758
}
27472759
}
@@ -4527,6 +4539,27 @@
45274539
"items": {
45284540
"$ref": "#/allOf/1/properties/fields/items"
45294541
}
4542+
},
4543+
"overrideType": {
4544+
"oneOf": [
4545+
{
4546+
"type": "object",
4547+
"patternProperties": {
4548+
".*": {
4549+
"type": "array",
4550+
"items": {
4551+
"$ref": "#/allOf/1/properties/fields/items"
4552+
}
4553+
}
4554+
}
4555+
},
4556+
{
4557+
"type": "array",
4558+
"items": {
4559+
"$ref": "#/allOf/1/properties/fields/items"
4560+
}
4561+
}
4562+
]
45304563
}
45314564
}
45324565
}

JsonSchema/record-type.schema.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,6 +2912,18 @@
29122912
"oneToOne",
29132913
"oneToMany"
29142914
]
2915+
},
2916+
"overrideType": {
2917+
"type": "object",
2918+
"additionalProperties": false,
2919+
"patternProperties": {
2920+
"image|text|video|audio|application": {
2921+
"type": "array",
2922+
"items": {
2923+
"$ref": "#/allOf/1/properties/fields/items"
2924+
}
2925+
}
2926+
}
29152927
}
29162928
}
29172929
}
@@ -4697,6 +4709,27 @@
46974709
"items": {
46984710
"$ref": "#/allOf/1/properties/fields/items"
46994711
}
4712+
},
4713+
"overrideType": {
4714+
"oneOf": [
4715+
{
4716+
"type": "object",
4717+
"patternProperties": {
4718+
".*": {
4719+
"type": "array",
4720+
"items": {
4721+
"$ref": "#/allOf/1/properties/fields/items"
4722+
}
4723+
}
4724+
}
4725+
},
4726+
{
4727+
"type": "array",
4728+
"items": {
4729+
"$ref": "#/allOf/1/properties/fields/items"
4730+
}
4731+
}
4732+
]
47004733
}
47014734
}
47024735
}

Tests/Unit/JsonSchemaValidation/CollectionFieldSchemaTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,46 @@ public static function collectionFieldSchemaValidationWorksAsExpectedDataProvide
235235
],
236236
'valid' => false,
237237
];
238+
239+
yield 'overrideType as object' => [
240+
'data' => (object)[
241+
'name' => 'json/schema-test',
242+
'fields' => [
243+
(object)[
244+
'identifier' => 'collection',
245+
'type' => 'Collection',
246+
'overrideType' => (object)[
247+
'type1' => [
248+
(object)[
249+
'identifier' => 'text',
250+
'type' => 'Text',
251+
],
252+
],
253+
],
254+
],
255+
],
256+
],
257+
'valid' => true,
258+
];
259+
260+
yield 'overrideType as array' => [
261+
'data' => (object)[
262+
'name' => 'json/schema-test',
263+
'fields' => [
264+
(object)[
265+
'identifier' => 'collection',
266+
'type' => 'Collection',
267+
'overrideType' => [
268+
(object)[
269+
'identifier' => 'text',
270+
'type' => 'Text',
271+
],
272+
],
273+
],
274+
],
275+
],
276+
'valid' => true,
277+
];
238278
}
239279

240280
#[Test]

Tests/Unit/JsonSchemaValidation/FileFieldSchemaTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,54 @@ public static function fileFieldSchemaValidationWorksAsExpectedDataProvider(): i
307307
],
308308
'valid' => false,
309309
];
310+
311+
yield 'overrideType valid' => [
312+
'data' => (object)[
313+
'name' => 'json/schema-test',
314+
'fields' => [
315+
(object)[
316+
'identifier' => 'file',
317+
'type' => 'File',
318+
'overrideType' => (object)[
319+
'image' => [
320+
(object)[
321+
'identifier' => 'text',
322+
'type' => 'Text',
323+
],
324+
],
325+
'video' => [
326+
(object)[
327+
'identifier' => 'text',
328+
'type' => 'Text',
329+
],
330+
],
331+
],
332+
],
333+
],
334+
],
335+
'valid' => true,
336+
];
337+
338+
yield 'overrideType invalid key' => [
339+
'data' => (object)[
340+
'name' => 'json/schema-test',
341+
'fields' => [
342+
(object)[
343+
'identifier' => 'file',
344+
'type' => 'File',
345+
'overrideType' => (object)[
346+
'invalid' => [
347+
(object)[
348+
'identifier' => 'text',
349+
'type' => 'Text',
350+
],
351+
],
352+
],
353+
],
354+
],
355+
],
356+
'valid' => false,
357+
];
310358
}
311359

312360
#[Test]

0 commit comments

Comments
 (0)