Skip to main content

Overview

The kdx validate command checks a resource YAML file against the platform’s OpenAPI schema without sending anything to the server. It helps catch errors before you deploy, surfacing typos, missing required fields, and type mismatches.

What It Checks

Missing Required Keys

Fields the API schema marks as required but are missing from your YAML:

Type Mismatches

Values whose types don’t match what the schema expects:

Unknown Keys

Keys in your YAML that don’t appear in the API schema. These are reported as warnings since the API may accept and ignore them, but they likely indicate a typo or a field that has no effect:
Unknown key warnings are only reported when the schema defines properties to compare against. If a schema has additionalProperties: false, unknown keys are reported as errors instead.

Envelope Key Validation

When using the spec wrapper format, top-level keys are checked against the recognized envelope fields (type, slug, orgSlug, name, metadata, storeType, spec):

Usage

Basic Validation

Example Output

Clean validation:
Validation with issues:
The command exits with a non-zero exit code when there are errors, making it suitable for CI pipelines. Warnings alone do not cause a non-zero exit.

How It Works

  1. Parses the YAML file and extracts the type field
  2. Resolves the resource type using the platform’s OpenAPI discovery (same as kdx apply)
  3. Extracts the JSON schema from the OpenAPI spec for that resource’s create operation
  4. Recursively walks all keys in the YAML and compares them against the schema properties
  5. Reports missing required fields, type mismatches, and unknown keys
The OpenAPI spec is cached locally (same cache as kdx api-resources). If the cache is stale, refresh it:

Supported YAML Formats

The validate command supports both resource file formats used by the CLI:

Flat Format

All fields at the top level (used by kdx apply):

Spec Wrapper Format

Fields nested under a spec key (used by kdx sync):

CI/CD Integration

Use kdx validate in your CI pipeline to catch issues before deployment:
Since the command exits with a non-zero code on errors, your pipeline will fail if any resource file has validation issues.

Limitations

  • Validation depends on the OpenAPI schema published by your platform. If the schema doesn’t define properties for a resource type, key-level validation is limited to required field checks.
  • Some resource types use permissive schemas where any additional fields are accepted. In these cases, unknown keys are reported as warnings rather than errors.
  • The command requires API connectivity for the initial OpenAPI spec fetch (subsequent runs use the cache).

Next Steps

Resource Operations

Create, update, and delete resources with kdx apply

Metadata Sync

Set up GitOps workflows for infrastructure as code