Skip to content

Commit 923c61e

Browse files
committed
[TASK] Add Schema for Page Types
1 parent b09bd6d commit 923c61e

File tree

5 files changed

+5552
-7
lines changed

5 files changed

+5552
-7
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "http://typo3.org/page-type.json",
4+
"title": "Page Type",
5+
"description": "TYPO3 CMS Content Blocks Page Type",
6+
"additionalProperties": false,
7+
"properties": {
8+
"group": {},
9+
"typeName": {},
10+
"name": {},
11+
"title": {},
12+
"prefixFields": {},
13+
"prefixType": {},
14+
"vendorPrefix": {},
15+
"priority": {},
16+
"basics": {},
17+
"fields": {}
18+
},
19+
"allOf": [
20+
{
21+
"type": "object",
22+
"properties": {
23+
"group": {
24+
"description": "Group name the Content Block should be displayed in",
25+
"anyOf": [
26+
{
27+
"type": "string"
28+
},
29+
{
30+
"type": "string",
31+
"enum": ["default", "links", "special"]
32+
}
33+
],
34+
"default": "default"
35+
},
36+
"typeName": {
37+
"description": "Unqique type identifier for this Content Block",
38+
"type": "integer"
39+
}
40+
}
41+
},
42+
{
43+
"$ref": "content-type.json"
44+
}
45+
]
46+
}

Build/JsonSchema/json-schema-bundler.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ import { fileURLToPath } from "node:url";
55

66
const __dirname = dirname(fileURLToPath(import.meta.url));
77

8-
let schema = await $RefParser.bundle(join(__dirname, 'SchemaSources/content-element.json'));
9-
let jsonString = JSON.stringify(schema, null, 2);
8+
let contentElementSchema = await $RefParser.bundle(join(__dirname, 'SchemaSources/content-element.json'));
9+
let contentElementSchemaJson = JSON.stringify(contentElementSchema, null, 2);
1010

11-
const outputPath = join(__dirname, '../../JsonSchema/content-element.schema.json');
12-
await mkdir(dirname(outputPath), { recursive: true });
13-
await writeFile(outputPath, jsonString);
11+
let pageTypeSchema = await $RefParser.bundle(join(__dirname, 'SchemaSources/page-type.json'));
12+
let pageTypeSchemaJson = JSON.stringify(pageTypeSchema, null, 2);
13+
14+
const contentElementOutputPath = join(__dirname, '../../JsonSchema/content-element.schema.json');
15+
await mkdir(dirname(contentElementOutputPath), { recursive: true });
16+
await writeFile(contentElementOutputPath, contentElementSchemaJson);
17+
18+
const pageTypeOutputPath = join(__dirname, '../../JsonSchema/page-type.schema.json');
19+
await mkdir(dirname(pageTypeOutputPath), { recursive: true });
20+
await writeFile(pageTypeOutputPath, pageTypeSchemaJson);

Classes/JsonSchemaValidation/JsonSchemaValidator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
public function validateContentElement(object $data, string $schemaIdentifier): bool
2828
{
2929
$validator = new Validator();
30-
$pathToSchemaFile = __DIR__ . '/../../JsonSchema/content-element.schema.json';
3130
$validator->resolver()->registerFile(
3231
'http://typo3.org/content-element.json',
33-
$pathToSchemaFile
32+
__DIR__ . '/../../JsonSchema/content-element.schema.json'
33+
);
34+
$validator->resolver()->registerFile(
35+
'http://typo3.org/page-type.json',
36+
__DIR__ . '/../../JsonSchema/page-type.schema.json'
3437
);
3538
$result = $validator->validate($data, $schemaIdentifier);
3639
return !$result->hasError();

0 commit comments

Comments
 (0)