feat: 리소스 스키마 및 검증 스크립트 추가, 기존 스키마 파일 삭제
This commit is contained in:
Vendored
+20
@@ -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": {
|
||||||
Reference in New Issue
Block a user