Skip to content

Commit 6ce455d

Browse files
dmealingclaude
andcommitted
Add JSON schema for types configuration equivalent to types-config.xsd
- Create comprehensive types-config.schema.json with all type definitions, validation patterns, and structure from XSD - Add $schema property support in schema definition to allow self-referencing - Update simple.types.json to reference the new schema for validation - Schema placed in types folder for reuse across multiple JSON type definition files - All existing functionality verified working with schema validation enabled 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6ec2c22 commit 6ce455d

2 files changed

Lines changed: 148 additions & 1 deletion

File tree

metadata/src/main/resources/com/draagon/meta/loader/simple/simple.types.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"types":[
1+
{"$schema": "../types/types-config.schema.json","types":[
22
{"name":"metadata","class":"com.draagon.meta.MetaData","children":[
33
{"type":"object","subType":"*","name":"*"},
44
{"type":"field","subType":"*","name":"*"},
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://www.draagon.com/types/v2/types-config.schema.json",
4+
"title": "MetaObjects Types Configuration",
5+
"description": "JSON Schema for MetaObjects types configuration, equivalent to types-config.xsd",
6+
"type": "object",
7+
"properties": {
8+
"$schema": {
9+
"type": "string",
10+
"description": "The JSON Schema reference"
11+
},
12+
"types": {
13+
"type": "array",
14+
"items": {
15+
"$ref": "#/definitions/typeDef"
16+
}
17+
},
18+
"rules": {
19+
"$ref": "#/definitions/rulesDef"
20+
}
21+
},
22+
"required": ["types"],
23+
"additionalProperties": false,
24+
"definitions": {
25+
"typeDef": {
26+
"type": "object",
27+
"properties": {
28+
"name": {
29+
"$ref": "#/definitions/typeNameDef"
30+
},
31+
"class": {
32+
"$ref": "#/definitions/classDef"
33+
},
34+
"defaultSubType": {
35+
"$ref": "#/definitions/defSubTypeNameDef"
36+
},
37+
"defaultName": {
38+
"$ref": "#/definitions/typeNameDef"
39+
},
40+
"defaultNamePrefix": {
41+
"$ref": "#/definitions/typeNameDef"
42+
},
43+
"children": {
44+
"type": "array",
45+
"items": {
46+
"$ref": "#/definitions/childDef"
47+
}
48+
},
49+
"subTypes": {
50+
"type": "array",
51+
"items": {
52+
"$ref": "#/definitions/subTypeDef"
53+
}
54+
}
55+
},
56+
"required": ["name", "class"],
57+
"additionalProperties": false
58+
},
59+
"subTypeDef": {
60+
"type": "object",
61+
"properties": {
62+
"name": {
63+
"$ref": "#/definitions/metaDataNameDef"
64+
},
65+
"class": {
66+
"$ref": "#/definitions/classDef"
67+
},
68+
"children": {
69+
"type": "array",
70+
"items": {
71+
"$ref": "#/definitions/childDef"
72+
}
73+
}
74+
},
75+
"required": ["name", "class"],
76+
"additionalProperties": false
77+
},
78+
"childDef": {
79+
"type": "object",
80+
"properties": {
81+
"type": {
82+
"$ref": "#/definitions/typeNameDef"
83+
},
84+
"subType": {
85+
"$ref": "#/definitions/subTypeNameDef"
86+
},
87+
"name": {
88+
"$ref": "#/definitions/metaDataNameDef"
89+
},
90+
"nameAliases": {
91+
"$ref": "#/definitions/typeNameArrayDef"
92+
}
93+
},
94+
"required": ["type", "subType", "name"],
95+
"additionalProperties": false
96+
},
97+
"rulesDef": {
98+
"type": "object",
99+
"properties": {
100+
"rules": {
101+
"type": "array",
102+
"items": {
103+
"$ref": "#/definitions/ruleDef"
104+
}
105+
}
106+
},
107+
"additionalProperties": false
108+
},
109+
"ruleDef": {
110+
"type": "object",
111+
"properties": {
112+
"name": {
113+
"$ref": "#/definitions/typeNameDef"
114+
}
115+
},
116+
"required": ["name"],
117+
"additionalProperties": false
118+
},
119+
"baseNameDef": {
120+
"type": "string",
121+
"pattern": "^[_a-zA-Z/*]([a-zA-Z0-9_/-])*$"
122+
},
123+
"typeNameDef": {
124+
"type": "string",
125+
"pattern": "^[a-zA-Z]([a-zA-Z0-9_/-])*$"
126+
},
127+
"defSubTypeNameDef": {
128+
"type": "string",
129+
"pattern": "^[a-zA-Z]([a-zA-Z0-9_/-])*$"
130+
},
131+
"subTypeNameDef": {
132+
"type": "string",
133+
"pattern": "^[a-zA-Z/*]([a-zA-Z0-9_/-])*$"
134+
},
135+
"metaDataNameDef": {
136+
"$ref": "#/definitions/baseNameDef"
137+
},
138+
"typeNameArrayDef": {
139+
"type": "string",
140+
"pattern": "^([_a-zA-Z/*]([a-zA-Z0-9/-])*)([,_a-zA-Z/*]([a-zA-Z0-9/-])*)$"
141+
},
142+
"classDef": {
143+
"type": "string",
144+
"pattern": "^([\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*$"
145+
}
146+
}
147+
}

0 commit comments

Comments
 (0)