Emit canonical openrpc.json at workspace root (#73) #81

Merged
timur merged 1 commit from issue-73-openrpc-location into development 2026-05-20 06:52:30 +00:00
Owner

Closes #73. Location locked at docs/openrpc.json per the decision comment. OschemaBuildConfig/OschemaBuilder gain workspace_dir (auto-detects via walking up to [workspace] Cargo.toml; explicit override available). Generator now writes a single canonical <workspace>/docs/openrpc.json instead of per-domain copies under src/{domain}/. rust_server computes the include_str! relative path dynamically — works for nested, separate-server-crate, and flat layouts. Scaffolded _admin template embeds the spec and serves /openrpc.json. example/recipe_server regenerated to the new layout. Both workspaces build clean; all tests pass.

Out-of-scope follow-ups: hero_skills hero_service_scaffold.md skill update + hero_service template repo regen (separate PRs).

Closes #73. Location locked at `docs/openrpc.json` per the decision comment. OschemaBuildConfig/OschemaBuilder gain `workspace_dir` (auto-detects via walking up to [workspace] Cargo.toml; explicit override available). Generator now writes a single canonical `<workspace>/docs/openrpc.json` instead of per-domain copies under `src/{domain}/`. `rust_server` computes the include_str! relative path dynamically — works for nested, separate-server-crate, and flat layouts. Scaffolded `_admin` template embeds the spec and serves `/openrpc.json`. `example/recipe_server` regenerated to the new layout. Both workspaces build clean; all tests pass. Out-of-scope follow-ups: hero_skills `hero_service_scaffold.md` skill update + `hero_service` template repo regen (separate PRs).
feat(generator): emit canonical openrpc.json at workspace docs/ (#73)
Some checks failed
Test / test (push) Failing after 2m44s
Test / test (pull_request) Failing after 2m10s
24d8b25b28
Per #73 and the locked decision in comment 34451, the OpenRPC spec is the
API contract every SDK target + the <hero-api-docs> admin widget consumes,
so it belongs in a discoverable top-level location rather than buried
under each crate's src/.

Changes:
- OschemaBuildConfig gains a workspace_dir setting; the builder
  auto-detects the workspace root by walking up from CARGO_MANIFEST_DIR
  for a Cargo.toml containing a [workspace] table (falls back to manifest
  dir for non-workspace consumers and unit tests).
- Generator gains a matching workspace_dir field. write_openrpc_json
  now writes a single docs/openrpc.json at the workspace root instead
  of per-domain copies under src/{domain}/.
- rust_types stops emitting an in-tree openrpc.json next to the core
  types; rust_server is the single emission point.
- rust_server computes the include_str! path from the server file's dir
  to <workspace>/docs/openrpc.json so the hardcoded
  include_str!("openrpc.json") / include_str!("../core/openrpc.json")
  layout fix-ups go away — works for nested layout, server_crate_dir,
  and flat in-tree alike.
- Scaffolded _admin main.rs template now embeds the canonical spec at
  build time and serves it on /openrpc.json so <hero-api-docs
  spec-url="/openrpc.json"> resolves without an extra wiring step.

example/recipe_server is regenerated to the new layout:
- src/recipes/openrpc.json removed from both hero_recipes and
  hero_recipes_server.
- docs/openrpc.json is the single canonical file.
- hero_recipes_admin/src/main.rs updates its include_str! to
  ../../../docs/openrpc.json.

Acceptance:
- Fresh scaffold emits docs/openrpc.json (not src/.../openrpc.json).
- recipe_server workspace + top-level workspace both build cleanly.
- All 125 generator tests + downstream tests still pass.

Note (multi-domain): the generator runs per-domain and currently
overwrites the same docs/openrpc.json each call (last domain wins).
Single-domain consumers (recipe_server, hero_service template) are
unaffected; merging multi-domain specs is a follow-up.

Out of scope: hero_skills hero_service_scaffold.md update +
hero_service template regeneration are separate PRs in their own repos.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
timur merged commit 5bab38dda6 into development 2026-05-20 06:52:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_rpc!81
No description provided.