mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Generate json schema for node def (#2862)
This commit is contained in:
@@ -2,7 +2,12 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema'
|
||||
|
||||
import { zComfyWorkflow, zComfyWorkflow1 } from '../src/types/comfyWorkflow'
|
||||
import {
|
||||
zComfyWorkflow,
|
||||
zComfyWorkflow1
|
||||
} from '../src/schemas/comfyWorkflowSchema'
|
||||
import { zComfyNodeDef as zComfyNodeDefV2 } from '../src/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import { zComfyNodeDef as zComfyNodeDefV1 } from '../src/schemas/nodeDefSchema'
|
||||
|
||||
// Convert both workflow schemas to JSON Schema
|
||||
const workflow04Schema = zodToJsonSchema(zComfyWorkflow, {
|
||||
@@ -15,6 +20,16 @@ const workflow1Schema = zodToJsonSchema(zComfyWorkflow1, {
|
||||
$refStrategy: 'none'
|
||||
})
|
||||
|
||||
const nodeDefV1Schema = zodToJsonSchema(zComfyNodeDefV1, {
|
||||
name: 'ComfyNodeDefV1',
|
||||
$refStrategy: 'none'
|
||||
})
|
||||
|
||||
const nodeDefV2Schema = zodToJsonSchema(zComfyNodeDefV2, {
|
||||
name: 'ComfyNodeDefV2',
|
||||
$refStrategy: 'none'
|
||||
})
|
||||
|
||||
// Create output directory if it doesn't exist
|
||||
const outputDir = './schemas'
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
@@ -32,4 +47,14 @@ fs.writeFileSync(
|
||||
JSON.stringify(workflow1Schema, null, 2)
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(outputDir, 'node-def-v1.json'),
|
||||
JSON.stringify(nodeDefV1Schema, null, 2)
|
||||
)
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(outputDir, 'node-def-v2.json'),
|
||||
JSON.stringify(nodeDefV2Schema, null, 2)
|
||||
)
|
||||
|
||||
console.log('JSON Schemas generated successfully!')
|
||||
|
||||
Reference in New Issue
Block a user