Skip to content

validate

Validate a typegen.jsonc configuration file for syntax and semantic errors.

Usage

sh
sparktype validate [options]

Options

OptionAliasDescription
--config <path>-cPath to configuration file

Purpose

The validate command checks your configuration file for:

  • Syntax errors: Invalid JSON/JSONC syntax
  • Schema errors: Missing required fields, invalid values
  • Semantic errors: References to undefined specs, invalid patterns

It does not load or parse OpenAPI specs—only the config file itself is validated.

Examples

Valid Configuration

sh
sparktype validate

Output:

Configuration is valid: typegen.jsonc

Invalid Configuration

sh
sparktype validate

Output:

configuration validation failed: output[0]: unknown format "ts" (valid: typescript, zod, python, go)

Custom Config Path

sh
sparktype validate --config ./config/typegen.jsonc

Exit Codes

CodeMeaning
0Configuration is valid
1Configuration has errors

When to Use

During Development

Run validate after editing your config to catch errors before running generate:

sh
sparktype validate && sparktype generate

In CI/CD

Add validation as a separate step:

yaml
- name: Validate config
  run: npx sparktype validate

- name: Check types
  run: npx sparktype check

Validation vs Generation

Checkvalidategenerate
Config syntaxYesYes
Config schemaYesYes
Spec file existsNoYes
Spec is valid OpenAPINoYes
Schema patterns matchNoYes

Use validate for quick config checks. Use generate or check for full validation including spec files.

Common Errors

"unexpected end of JSON input"

Your config file has a syntax error. Common causes:

  • Missing closing brace or bracket
  • Trailing comma in arrays/objects
  • Unclosed string

"missing required field"

Add the required field to your config. Required fields are:

  • specs (object)
  • outputs (array)
  • For each output: path, format, contents

"unknown format"

Use one of: typescript, zod, python, go

"spec must have exactly one source"

Each spec needs exactly one of:

  • path (local file)
  • url (remote URL)
  • schemas (inline definitions)

See Also

Released under the MIT License.