feat: publish JSON schemas at https://raidcli.dev/schema/v1/ (closes #48)#78
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
- Coverage 91.23% 91.11% -0.12%
==========================================
Files 33 33
Lines 2909 2915 +6
==========================================
+ Hits 2654 2656 +2
- Misses 167 169 +2
- Partials 88 90 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR formalizes a stable, versioned publication path for Raid’s JSON Schemas (https://raidcli.dev/schema/v1/...) and updates both the Go-side schema validation and all user-facing references (templates/docs/examples) to use canonical absolute $id/$ref URLs.
Changes:
- Publish schemas via the docs site by copying
schemas/*.schema.jsonintosite/static/schema/v1/during Docusaurus build. - Rewrite schema
$idand cross-schema$refvalues to absolutehttps://raidcli.dev/schema/v1/...URLs; update Go embedded-schema validation to register/compile by$idURL. - Update templates, docs, examples, and bump version to
0.11.1-beta; add tests to enforce canonical schema IDs and validate templates/examples.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/resources/repo-template | Update YAML LSP $schema modeline to the canonical v1 URL. |
| src/resources/profile-template | Update YAML LSP $schema modeline to the canonical v1 URL. |
| src/resources/app.properties | Patch bump to 0.11.1-beta. |
| src/internal/lib/schemas_published_test.go | Add tests for canonical $ids, templates/examples validation, and (optionally) published-copy equality. |
| src/internal/lib/repo.go | Switch repo schema identifier constant to the published v1 URL. |
| src/internal/lib/profile.go | Switch profile schema identifier constant to the published v1 URL. |
| src/internal/lib/lib.go | Update embedded-schema validation to register schemas by $id and compile by canonical URL. |
| src/internal/lib/lib_test.go | Update tests to pass canonical schema URLs to embedded validation. |
| site/plugins/copy-schemas.ts | New Docusaurus plugin to copy schemas into static/schema/v1/ pre-build. |
| site/docusaurus.config.ts | Register the new copy-schemas plugin. |
| site/docs/whats-new.mdx | Add a 0.11.1 entry documenting the published schema URLs and contract. |
| site/docs/references/schema.mdx | Document the published schema URLs and versioning promise. |
| site/docs/examples/new-developer.mdx | Update example modelines to point at the canonical v1 schema URLs. |
| site/.gitignore | Ignore generated site/static/schema/ output. |
| schemas/README.md | Document single-source-of-truth + v1/v2 versioning rules and publishing behavior. |
| schemas/raid-repo.schema.json | Set $id and $refs to canonical v1 absolute URLs. |
| schemas/raid-profile.schema.json | Set $id and $refs to canonical v1 absolute URLs; minor formatting cleanup. |
| schemas/raid-defs.schema.json | Set $id to canonical v1 absolute URL. |
| README.md | Update modelines/links to canonical v1 schema URLs. |
| llms.txt | Update schema links to canonical v1 URLs. |
| docs/examples/raid.yaml | Update YAML LSP $schema modeline to canonical v1 URL. |
| docs/examples/example.raid.yaml | Update YAML LSP $schema modeline to canonical v1 URL. |
| docs/examples/demo.raid.yaml | Update YAML LSP $schema modeline to canonical v1 URL. |
| for _, entry := range entries { | ||
| data, err := schemas.FS.ReadFile(entry.Name()) | ||
| name := entry.Name() | ||
| if !strings.HasSuffix(name, ".json") { | ||
| continue | ||
| } | ||
| data, err := schemas.FS.ReadFile(name) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to read embedded schema %s: %w", entry.Name(), err) | ||
| return fmt.Errorf("failed to read embedded schema %s: %w", name, err) | ||
| } | ||
| var doc any | ||
| var doc map[string]any | ||
| if err := json.Unmarshal(data, &doc); err != nil { | ||
| return fmt.Errorf("failed to parse embedded schema %s: %w", entry.Name(), err) | ||
| return fmt.Errorf("failed to parse embedded schema %s: %w", name, err) | ||
| } | ||
| id, _ := doc["$id"].(string) | ||
| if id == "" { | ||
| return fmt.Errorf("embedded schema %s is missing $id", name) |
| ) | ||
|
|
||
| const repoSchemaPath = "raid-repo.schema.json" | ||
| const repoSchemaPath = "https://raidcli.dev/schema/v1/raid-repo.schema.json" |
| const ( | ||
| activeProfileKey = "profile" | ||
| allProfilesKey = "profiles" | ||
| profileSchemaPath = "raid-profile.schema.json" | ||
| profileSchemaPath = "https://raidcli.dev/schema/v1/raid-profile.schema.json" | ||
| ) |
| name string | ||
| template string | ||
| fill string | ||
| schemaID string | ||
| wantInvalid bool |
- Narrow embedded schema registration to *.schema.json so non-schema JSON files in schemas/ can't break validation at runtime. - Rename repoSchemaPath/profileSchemaPath to repoSchemaID/profileSchemaID to reflect that they hold canonical schema $id URLs, not filesystem paths. - Remove unused wantInvalid field from the template validation test table. Co-Authored-By: Copilot <copilot@github.com>
…EmbeddedSchema Adds two tests to lift patch coverage closer to project baseline: - unknownSchemaID exercises the Compile error path. - repoSchema exercises the loop iteration that registers raid-repo alongside raid-profile (parallel to the existing profile test).
|
Auto-review by meeseeks Updates pushed: 2 commits
Copilot comments addressed: 4 of 4
Skipped: 0 Codecov patch: 50.00% (project 91.11%, was 91.23%) — needs human Needs human: Patch coverage stays at 50% even after the test additions — the remaining 8 uncovered lines are all defensive error paths inside |
Summary
https://raidcli.dev/schema/v1/raid-profile.schema.json,raid-repo.schema.json,raid-defs.schema.json. The/v1/segment is a public stability contract (additive-only; breaking changes go to/v2/).site/plugins/copy-schemas.tscopiesschemas/*.schema.jsonintosite/static/schema/v1/at docsite build start — single source of truth stays inschemas/, no committed duplicates.$idand cross-$refvalues in the three schemas to absolute URLs. Internal Go validation (validateWithEmbeddedSchema) now registers each embedded schema under its$idand compiles by URL.src/internal/lib/schemas_published_test.go:$idmatches the v1 URL,site/static/schema/v1/(when built) byte-equals embedded source,docs/examples/*.{yaml,json}validates against the appropriate schema.schemas/README.md; add a "Published JSON Schemas" section tosite/docs/references/schema.mdx.0.11.0-beta→0.11.1-beta; entry under 0.11.1 insite/docs/whats-new.mdx.Closes #48.
Follow-up (external, separate PR): update the SchemaStore catalog entries for
*.raid.yaml/raid.yamlto point at the newhttps://raidcli.dev/schema/v1/...URLs.Test plan
go test ./...— all packages green, including the four new testsnpm run buildinsite/— clean, schemas land atsite/build/schema/v1/<name>.schema.jsonwith absolute\$id'https://raidcli.dev/schema/v1/raid-profile.schema.json#')