Skip to content

feat: generate cdk.json JSON Schema from cli-config source of truth#1573

Draft
9pace wants to merge 2 commits into
mainfrom
9pace/cdk-json-schema-gen
Draft

feat: generate cdk.json JSON Schema from cli-config source of truth#1573
9pace wants to merge 2 commits into
mainfrom
9pace/cdk-json-schema-gen

Conversation

@9pace
Copy link
Copy Markdown
Contributor

@9pace 9pace commented May 29, 2026

Adds a generated JSON Schema for `cdk.json` as a 4th output target in `user-input-gen`, alongside the existing yargs, types, and config conversion outputs. Because it's generated from `cli-config.ts`, it can never drift from actual supported options.

What's included:

  • Schema generator covering all global options + per-command config blocks
  • Warn-only validation on config load (recurses into command namespaces, never blocks)
  • `$schema` pointer injected by `cdk init` for IDE autocomplete
  • Schema included in npm package

Design decisions:

  • Generated, not hand-written (PR feat: manually generated json-schema with validation #919 covered ~25 of 150+ properties manually)
  • `additionalProperties: true` at root (custom keys allowed), `false` on command blocks (typo detection)
  • No external validator dependency (lightweight recursive type checking)

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team May 29, 2026 19:46
@9pace 9pace temporarily deployed to no-approval May 29, 2026 19:46 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 29, 2026

Codecov Report

❌ Patch coverage is 48.64865% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.76%. Comparing base (2c4acf7) to head (8bb64a5).

Files with missing lines Patch % Lines
packages/aws-cdk/lib/cli/validate-config.ts 35.95% 57 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1573      +/-   ##
==========================================
- Coverage   88.16%   87.76%   -0.41%     
==========================================
  Files          76       77       +1     
  Lines       10841    10952     +111     
  Branches     1494     1510      +16     
==========================================
+ Hits         9558     9612      +54     
- Misses       1255     1312      +57     
  Partials       28       28              
Flag Coverage Δ
suite.unit 87.76% <48.64%> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@9pace 9pace force-pushed the 9pace/cdk-json-schema-gen branch from 75841d9 to 7b9a321 Compare May 29, 2026 20:11
@9pace 9pace temporarily deployed to no-approval May 29, 2026 20:11 — with GitHub Actions Inactive
Adds a 4th generation target to user-input-gen that produces a
JSON Schema (draft-07) for cdk.json from the same CliConfig source
of truth used for yargs, types, and config conversion.

- Schema generator covering all global + per-command options
- Warn-only validation on config load (never blocks)
- $schema pointer in cdk init templates for IDE autocomplete
- Schema included in npm package

Fixes #743
@9pace 9pace closed this May 29, 2026
@9pace 9pace reopened this May 29, 2026
@9pace 9pace temporarily deployed to no-approval May 29, 2026 20:13 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

Total lines changed 1605 is greater than 1000. Please consider breaking this PR down.

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants