Overview
Thekdx 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 thespec 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:How It Works
- Parses the YAML file and extracts the
typefield - Resolves the resource type using the platform’s OpenAPI discovery (same as
kdx apply) - Extracts the JSON schema from the OpenAPI spec for that resource’s create operation
- Recursively walks all keys in the YAML and compares them against the schema properties
- Reports missing required fields, type mismatches, and unknown keys
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 bykdx apply):
Spec Wrapper Format
Fields nested under aspec key (used by kdx sync):
CI/CD Integration
Usekdx validate in your CI pipeline to catch issues before deployment:
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).
