Generate SPLAT JSON Schema from the Go types#24
Closed
stackedsax wants to merge 1 commit into
Closed
Conversation
Add internal/splat/schema, which reflects splat.Job into a JSON Schema (draft 2020-12) with the opaque scalar wrappers (Quantity, Duration) mapped to strings. The committed schema/splat.schema.json is regenerated with `make schema` (go test ./internal/splat/schema -update); a drift test runs under `go test ./...` so the schema can never silently fall out of sync with the types. Depends on github.com/invopop/jsonschema (kept out of the core splat package via the reflector's type Mapper). Note: validating the current examples/ against this schema fails because they use snake_case field names while the types/schema use camelCase — a pre-existing docs/impl mismatch tracked separately; the schema here reflects what the tool actually accepts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PnTz6Zxqa4jHocK8kCbyx
Contributor
Author
|
Superseded by the combined schema + camelCase + CI-validation PR (the schema commit is included there, and the examples now validate against it). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Generate a JSON Schema for the SPLAT job spec directly from the Go types, so it
can't drift from the implementation.
internal/splat/schemareflectssplat.Jobinto a JSON Schema (draft2020-12). The opaque scalar wrappers (
Quantity,Duration) are mapped tostringvia the reflector's type mapper, keeping the dependency out of thecore
splatpackage.schema/splat.schema.jsonis the committed artifact. Regenerate withmake schema(go test ./internal/splat/schema -update).go test ./...(already in CI's test job), failing ifthe committed schema is stale — no new CI wiring needed.
github.com/invopop/jsonschema.Validating the current
examples/*.yamlagainst the generated schema fails:they use snake_case field names (
cpus_per_task,client_id, …) while theGo types — and everything the tool actually parses — use camelCase
(
cpusPerTask,clientId). Confirmed at runtime: a snake_case SPLAT file hasits fields silently dropped on convert; the camelCase equivalent works. So
the examples and
SPEC.md's field reference are wrong, not the schema. Fixingthat (docs → camelCase, or add snake_case support in the parser) is a separate
decision, so this PR does not gate CI on example validation yet.
Testing
go test ./internal/splat/schema— drift check + a shape sanity check.🤖 Generated with Claude Code