feat: 리소스 스키마 및 검증 스크립트 추가, 기존 스키마 파일 삭제

This commit is contained in:
2026-01-18 08:49:19 +00:00
parent 2f05e5a1e1
commit cbe960364d
7 changed files with 30 additions and 10 deletions
+20
View File
@@ -0,0 +1,20 @@
{
"json.schemas": [
{
"fileMatch": ["resources/map/*.json"],
"url": "./resources/schema/map.json"
},
{
"fileMatch": ["resources/scenario/*.json"],
"url": "./resources/schema/scenario.json"
},
{
"fileMatch": ["resources/unitset/*.json"],
"url": "./resources/schema/unitset.json"
},
{
"fileMatch": ["resources/turn-commands/*.json"],
"url": "./resources/schema/turn-commands.json"
}
]
}
@@ -18,16 +18,16 @@ const RESOURCE_ROOT = path.join(REPO_ROOT, 'resources');
const writeSchema = async (relativePath: string, schema: ZodTypeAny): Promise<void> => { const writeSchema = async (relativePath: string, schema: ZodTypeAny): Promise<void> => {
const outputPath = path.join(RESOURCE_ROOT, relativePath); const outputPath = path.join(RESOURCE_ROOT, relativePath);
const jsonSchema = z.toJSONSchema(schema, { target: 'draft-07' }); const jsonSchema = z.toJSONSchema(schema);
const serialized = `${JSON.stringify(jsonSchema, null, 4)}\n`; const serialized = `${JSON.stringify(jsonSchema, null, 4)}\n`;
await fs.writeFile(outputPath, serialized, 'utf8'); await fs.writeFile(outputPath, serialized, 'utf8');
}; };
const main = async (): Promise<void> => { const main = async (): Promise<void> => {
await writeSchema(path.join('map', 'schema.json'), MapResourceSchema); await writeSchema(path.join('schema', 'map.json'), MapResourceSchema);
await writeSchema(path.join('scenario', 'schema.json'), ScenarioResourceSchema); await writeSchema(path.join('schema', 'scenario.json'), ScenarioResourceSchema);
await writeSchema(path.join('unitset', 'schema.json'), UnitSetDefinitionInputSchema); await writeSchema(path.join('schema', 'unitset.json'), UnitSetDefinitionInputSchema);
await writeSchema(path.join('turn-commands', 'schema.json'), TurnCommandProfileInputSchema); await writeSchema(path.join('schema', 'turn-commands.json'), TurnCommandProfileInputSchema);
}; };
main().catch((error) => { main().catch((error) => {
@@ -24,7 +24,7 @@ const RESOURCE_SCHEMAS: Record<string, (value: unknown) => void> = {
const listJsonFiles = async (dirPath: string): Promise<string[]> => { const listJsonFiles = async (dirPath: string): Promise<string[]> => {
const entries = await fs.readdir(dirPath, { withFileTypes: true }); const entries = await fs.readdir(dirPath, { withFileTypes: true });
return entries return entries
.filter((entry) => entry.isFile() && entry.name.endsWith('.json') && entry.name !== 'schema.json') .filter((entry) => entry.isFile() && entry.name.endsWith('.json'))
.map((entry) => entry.name) .map((entry) => entry.name)
.sort((a, b) => a.localeCompare(b)); .sort((a, b) => a.localeCompare(b));
}; };
@@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"type": "object", "type": "object",
@@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [ "anyOf": [
{ {
"type": "object", "type": "object",
@@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {
"general": { "general": {
@@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {