ADR-0026: JSON Canonical Route Authoring Format
Date: 2026-06-26 Status: Accepted Issues: rc-iq7
Context
rust-camel supports two route authoring formats: YAML and JSON. Both deserialize
into the same AST and compile into DeclarativeRoute via the shared
route_dsl_to_declarative_route function
(crates/camel-dsl/src/yaml.rs, crates/camel-dsl/src/json.rs). The shared AST
types are RouteDslRoutes/RouteDslRoute/RouteDslStep
(crates/camel-dsl/src/route_ast.rs); both formats consume them directly (no
format-specific aliases).
Discovery supports both formats by extension
(crates/camel-dsl/src/discovery.rs); the CLI defaults to routes/*.yaml
(crates/camel-cli/src/commands/run.rs) and JSON requires explicit .json
glob — a deliberate ergonomic default, not an assertion of YAML primacy.
The existing canonical runtime contract (CanonicalRouteSpec) is minimal by design
and NOT a full authoring DSL (crates/camel-api/src/runtime.rs, ADR-0011/0016).
SDKs, programmatic route generators, IDE tooling, and machine-driven workflows all speak JSON natively. YAML is the better human authoring format but a worse machine contract (implicit-type quirks like the Norway problem, no native schema validation in popular tooling, ambiguous block scalars).
Decision
JSON is the canonical full route authoring format for SDKs, generators, schema validation, IDE completion, and machine workflows. YAML remains a supported human convenience derived from the same AST.
Concretely:
- Shared code names use
RouteDsl*(notYaml*). Both formats lower through the sameroute_dsl_to_declarative_routefunction. - The project publishes a generated full-DSL JSON Schema at
schemas/dsl/route-schema.jsonplus TypeScript types underschemas/ts/. Both are regenerated viacargo xtask schema; drift is detected bycargo xtask schema --check(CI gate, non-mutating). - New verbs MUST land with JSON schema + tests + examples first. YAML parity must follow before release.
- Discovery supports both formats when configured; default CLI glob remains
routes/*.yaml; JSON requires explicit.jsonglob. No API or doc implies YAML is the "primary" format beyond human-ergonomics defaults. - Error messages carry input format context via
InputFormatboundary annotation (crates/camel-dsl/src/input_format.rs): messages are prefixed with"YAML DSL error: "or"JSON DSL error: "so users know which parser failed.
Consequences
- ADR-0017 (snake_case naming) applies to DSL keys in both JSON and YAML.
- ADR-0011/0016 remain about the minimal runtime canonical contract, not authoring
format.
CanonicalRouteSpecand the full-DSL JSON Schema are distinct artifacts. - Maintainers must enforce JSON-first verb landing in code review until tooling automates the check.
- YAML users are not demoted: feature parity is release-blocking, but no longer implicit-primacy.
- Future: hosted stable schema URL (post-1.0); SDKs in target languages derive from the schema.
References
- Spec:
docs/superpowers/specs/2026-06-24-json-canonical-route-format.md(oracle-blessed loop 3, e_gpt; preserved on main worktree, gitignored — if absent, see bd rc-iq7 epic notes for summary). - bd epic: rc-iq7 (tracks all sub-tasks and merged commits).
- Implementation commits: d652b4e2 (A1 rename), 9dc7b494 (B1 parity), 65d0d5d4 (B2+B3), 29cab318 (C1-C3 schema+TS), 301b0cfb (D1 format-aware errors).
- Supersedes: rc-l6e (closed 2026-06-24; 4 gaps absorbed into B1/B2/B3/A1).