Skip to content

generateSchema

Generated reference page for the generateSchema function export.

Signatures

ts
function generateSchema(schema: CLISchema, options?: JsonSchemaOptions): Record<string, unknown>;
ParameterTypeDescription
schemaCLISchemaThe CLI schema from CLIBuilder.schema.
optionsJsonSchemaOptions | undefinedGeneration options.

Members

Members

generateSchema

Generate a definition metadata document describing the CLI's structure.

Walks the full command tree and produces a plain JSON-serializable object representing all commands, subcommands, flags, args, and metadata. Non-serializable runtime values (parse functions, middleware handlers, interactive resolvers) are omitted.

ts
(schema: CLISchema, options?: JsonSchemaOptions): Record<string, unknown>;

Examples

ts
const app = cli('myapp').version('1.0.0').command(deploy);
const definition = generateSchema(app.schema);
writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2));

See Also

Released under the MIT License.