-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] Extract comfy workflow zod schema as json schema (#2206)
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,7 @@ browser_tests/*/*-win32.png | |
|
||
dist.zip | ||
|
||
/temp/ | ||
/temp/ | ||
|
||
# Generated JSON Schemas | ||
/schemas/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { zodToJsonSchema } from 'zod-to-json-schema' | ||
|
||
import { zComfyWorkflow, zComfyWorkflow1 } from '../src/types/comfyWorkflow' | ||
|
||
// Convert both workflow schemas to JSON Schema | ||
const workflow04Schema = zodToJsonSchema(zComfyWorkflow, { | ||
name: 'ComfyWorkflow0_4', | ||
$refStrategy: 'none' | ||
}) | ||
|
||
const workflow1Schema = zodToJsonSchema(zComfyWorkflow1, { | ||
name: 'ComfyWorkflow1_0', | ||
$refStrategy: 'none' | ||
}) | ||
|
||
// Create output directory if it doesn't exist | ||
const outputDir = './schemas' | ||
if (!fs.existsSync(outputDir)) { | ||
fs.mkdirSync(outputDir, { recursive: true }) | ||
} | ||
|
||
// Write schemas to files | ||
fs.writeFileSync( | ||
path.join(outputDir, 'workflow-0_4.json'), | ||
JSON.stringify(workflow04Schema, null, 2) | ||
) | ||
|
||
fs.writeFileSync( | ||
path.join(outputDir, 'workflow-1_0.json'), | ||
JSON.stringify(workflow1Schema, null, 2) | ||
) | ||
|
||
console.log('JSON Schemas generated successfully!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters