Skip to content

docs(schema): publish JSON Schema for goten.config.yaml - #30

Merged
dnahilman merged 1 commit into
mainfrom
docs/config-json-schema
May 26, 2026
Merged

docs(schema): publish JSON Schema for goten.config.yaml#30
dnahilman merged 1 commit into
mainfrom
docs/config-json-schema

Conversation

@dnahilman

Copy link
Copy Markdown
Owner

Closes #26.

Summary

Publishes goten.config.schema.json so editors with YAML LSP support give autocomplete, hover docs, and inline validation when editing goten.config.yaml.

Activate with a magic comment at the top of your config:

# yaml-language-server: $schema=https://raw.githubusercontent.com/dnahilman/goten/main/goten.config.schema.json
env_file: .env
database:
  url: ${DATABASE_URL}

Works in VS Code (Red Hat YAML extension), JetBrains GoLand/IntelliJ, Neovim with yaml-language-server, etc.

Why

Until now editing goten.config.yaml was raw text. With the schema in place:

  • Field-name typos get flagged (databse: → red squiggle).
  • Hover any field for inline docs.
  • driver: postgers → "must be one of postgres".
  • Autocomplete suggests valid field names.

Steps (matching #26)

  • 2.1 Write goten.config.schema.json at repo root — covers env_file, database (url required, driver enum), migrations (core_dir, plugins, table), generate_dir. $id is the raw GitHub URL.
  • 2.2 Add magic comment header to examples/basic/goten.config.yaml. Kept full paths in this file because it shares migrations with the repo root via ../../; the shorthand demo lives in the upcoming Quick Start rewrite (docs(wiki): rewrite Quick Start for new projects #27).
  • 2.3 README — short pointer near the CLI section.
  • 2.4 CHANGELOG [Unreleased] entry.

Design notes

  • Schema is editor-only, no CLI-side validator. The Go struct unmarshal already type-checks structural input; JSON Schema adds field-name and enum validation at the editor level. Level 2 (CLI validator) and Level 3 (SchemaStore submission) are explicit non-goals for this PR.
  • additionalProperties: false so unknown fields are flagged. This matches the strict Go struct definitions.
  • plugins items: schema describes both shorthand (username) and full path (./plugins/username/migrations) as valid — auto-detected by the CLI at runtime (Issue feat(cli): top-level goten init + plugin registry #25's resolvePluginEntry).

Test plan

  • make build — all six modules compile (schema does not affect compilation).
  • go test ./cmd/goten/... — all green; schema is not consumed by any test.
  • Reviewer: open examples/basic/goten.config.yaml in VS Code with Red Hat YAML extension. Confirm:
    • Hover on database: shows description.
    • Type dat → autocomplete suggests database.
    • Change driver: postgres to driver: postgers → red squiggle.

Unblocks

#27 — Quick Start rewrite can now reference the schema URL in its sample config.

🤖 Generated with Claude Code

Closes #26.

Publishes goten.config.schema.json at the repo root so editors with YAML
LSP support (VS Code + Red Hat YAML extension, JetBrains, Neovim, etc.)
can provide autocomplete, hover docs, and inline validation when editing
goten.config.yaml.

Activation is a single-line magic comment at the top of the user's
config file (yaml-language-server convention). Schema is pure editor
metadata — runtime behavior unchanged.

The shorthand plugin form (`- username`) is part of the schema's
allowed values but examples/basic keeps full paths because it shares
migrations with the repo root via `../../`. The shorthand demo lives
in the upcoming Quick Start rewrite (#27).

Steps:
- 2.1 Write goten.config.schema.json covering env_file, database
  (url + driver enum), migrations (core_dir, plugins, table), and
  generate_dir.
- 2.2 Add magic comment header to examples/basic/goten.config.yaml.
- 2.3 README pointer in the CLI section.
- 2.4 CHANGELOG entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dnahilman
dnahilman merged commit 097d0fc into main May 26, 2026
2 checks passed
@dnahilman
dnahilman deleted the docs/config-json-schema branch May 26, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(schema): publish JSON Schema for goten.config.yaml

1 participant