Skip to content

feat: publish JSON schemas at https://raidcli.dev/schema/v1/ (closes #48)#78

Merged
8bitAlex merged 3 commits into
mainfrom
feat/issue-48-publish-schemas
May 11, 2026
Merged

feat: publish JSON schemas at https://raidcli.dev/schema/v1/ (closes #48)#78
8bitAlex merged 3 commits into
mainfrom
feat/issue-48-publish-schemas

Conversation

@8bitAlex
Copy link
Copy Markdown
Owner

Summary

  • Publish the three JSON schemas under a stable, versioned URL: 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/).
  • New Docusaurus plugin site/plugins/copy-schemas.ts copies schemas/*.schema.json into site/static/schema/v1/ at docsite build start — single source of truth stays in schemas/, no committed duplicates.
  • Rewrite $id and cross-$ref values in the three schemas to absolute URLs. Internal Go validation (validateWithEmbeddedSchema) now registers each embedded schema under its $id and compiles by URL.
  • Update generated profile / repo templates, README, llms.txt, schema reference doc, and example YAMLs to point at the new URLs.
  • New Go tests in src/internal/lib/schemas_published_test.go:
    • every embedded schema's $id matches the v1 URL,
    • site/static/schema/v1/ (when built) byte-equals embedded source,
    • profile / repo templates pass schema validation in their rendered form,
    • every docs/examples/*.{yaml,json} validates against the appropriate schema.
  • Document the versioning rule in schemas/README.md; add a "Published JSON Schemas" section to site/docs/references/schema.mdx.
  • Patch bump: 0.11.0-beta0.11.1-beta; entry under 0.11.1 in site/docs/whats-new.mdx.

Closes #48.

Follow-up (external, separate PR): update the SchemaStore catalog entries for *.raid.yaml / raid.yaml to point at the new https://raidcli.dev/schema/v1/... URLs.

Test plan

  • go test ./... — all packages green, including the four new tests
  • npm run build in site/ — clean, schemas land at site/build/schema/v1/<name>.schema.json with absolute \$id
  • Built binary smoke test: valid profile accepted; unknown field rejected with the new URL surfaced in the validation error ('https://raidcli.dev/schema/v1/raid-profile.schema.json#')
  • After merge + docs deploy: verify the three schemas are reachable at their canonical URLs and resolve cross-refs in an external validator (e.g. json-schema.app)

Copilot AI review requested due to automatic review settings May 11, 2026 19:37
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.11%. Comparing base (755f29b) to head (eadbf35).

Files with missing lines Patch % Lines
src/internal/lib/lib.go 42.85% 5 Missing and 3 partials ⚠️
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.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json into site/static/schema/v1/ during Docusaurus build.
  • Rewrite schema $id and cross-schema $ref values to absolute https://raidcli.dev/schema/v1/... URLs; update Go embedded-schema validation to register/compile by $id URL.
  • 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.

Comment thread src/internal/lib/lib.go
Comment on lines 565 to +580
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)
Comment thread src/internal/lib/repo.go Outdated
)

const repoSchemaPath = "raid-repo.schema.json"
const repoSchemaPath = "https://raidcli.dev/schema/v1/raid-repo.schema.json"
Comment on lines 17 to 21
const (
activeProfileKey = "profile"
allProfilesKey = "profiles"
profileSchemaPath = "raid-profile.schema.json"
profileSchemaPath = "https://raidcli.dev/schema/v1/raid-profile.schema.json"
)
Comment on lines +98 to +102
name string
template string
fill string
schemaID string
wantInvalid bool
8bitAlex and others added 2 commits May 11, 2026 12:44
- 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).
@8bitAlex
Copy link
Copy Markdown
Owner Author

Auto-review by meeseeks

Updates pushed: 2 commits

  • c2d6ca9 fix: address Copilot review (suffix narrowing + repoSchemaID/profileSchemaID rename + drop unused wantInvalid field)
  • eadbf35 test: cover unknown-schemaID and repo-schema branches in validateWithEmbeddedSchema

Copilot comments addressed: 4 of 4

  • lib.go:580 — narrowed embedded schema registration to *.schema.json (drops the dependency on every embedded *.json having $id)
  • repo.go:14repoSchemaPathrepoSchemaID (it's a canonical $id URL, not a path)
  • profile.go:21profileSchemaPathprofileSchemaID (same)
  • schemas_published_test.go:102 — removed unused wantInvalid field from the template-validation table

Skipped: 0

Codecov patch: 50.00% (project 91.11%, was 91.23%) — needs human
Other CI: green (build/macOS/Windows/Ubuntu/CodeQL/docs/version-check all pass)

Needs human: Patch coverage stays at 50% even after the test additions — the remaining 8 uncovered lines are all defensive error paths inside validateWithEmbeddedSchema (ReadDir / ReadFile / Unmarshal / missing-$id / AddResource failures). Triggering them requires refactoring the function to inject the embedded fs.FS so a test can supply a corrupted filesystem. That's an architectural change beyond the scope of "one honest test attempt," and the project delta is only -0.12% which is well within acceptable drift, so flagging for your call rather than refactoring autonomously.

@8bitAlex 8bitAlex merged commit 7edd367 into main May 11, 2026
11 of 13 checks passed
@8bitAlex 8bitAlex deleted the feat/issue-48-publish-schemas branch May 11, 2026 20:38
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.

Publish JSON Schema for raid.yaml

2 participants