You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.7 KiB
2.7 KiB
| title | status | type | priority | created_at | updated_at |
|---|---|---|---|---|---|
| [TRIAGE] OpenAPI spec serving strategy — embed YAML at compile time vs load at runtime | completed | task | high | 2026-03-10T23:32:06Z | 2026-03-10T23:32:06Z |
The refined implementation uses a build.rs script rather than embedding the raw YAML and
parsing it at runtime. Specifically:
build.rsreadsapi/openapi.yaml, parses it toserde_json::Valuewithserde_yaml, writes compact JSON to$OUT_DIR/openapi.json, and emitscargo:rerun-if-changed=api/openapi.yamlso the conversion re-runs on every spec change.- The
GET /api/handler serves the result as:const OPENAPI_JSON: &str = include_str!(concat!(env!("OUT_DIR"), "/openapi.json")); serde_yamlis a[build-dependencies]entry only — it never enters the Workers binary, keeping binary size minimal.- Zero runtime overhead: no
OnceLock, no lazy parsing, no heap allocation for the spec.
Options 2 (runtime load) and 3 (utoipa) were ruled out:
- Option 2 is impossible on Cloudflare Workers — there is no filesystem at runtime.
- Option 3 (utoipa) would require annotating all 7 handlers with macros and migrating away
from the hand-written
api/openapi.yamlspec, which is already complete and validated. The added complexity is not justified for a project of this size.
Tickets updated:
- 8892d5 (new): implements
build.rsand adds[build-dependencies]toCargo.toml. - 28e7d9: updated with the concrete
include_str!(concat!(env!("OUT_DIR"), "/openapi.json"))handler pattern; now depends on 8892d5 instead of this triage ticket. - 1f5bb5: updated with the
[build-dependencies]constraint. - f3dc74 (API sub-project): 8892d5 added as dependency.