feat(api): TRA-743 — single-source OpenAPI spec (remove contact.url, add Cache-Control)#357
Merged
Merged
Conversation
…add Cache-Control) Platform side of TRA-743's "eliminate docs-side mirror, single source on platform" pivot. The TRA-742 PR (#356) traded the drifted contact.url for the docs.trakrf.id homepage; this PR removes the field entirely so docs.trakrf.id can redirect spec asset requests to the platform origin without re-introducing the same drift class. Changes: - Drop the info.contact.url assignment from apispec/postprocess.go's public spec branch. info.contact.{name,email} remain authoritative for support routing; the bare-hostname servers[] block continues to differentiate preview vs prod. - Disable the inherited Zalando must-have-info-contact-url Spectral rule with rationale referencing this ticket. info.contact.name + info.contact.email continue to satisfy the broader "MUST have contact info" intent (rule 218). - Add `Cache-Control: public, max-age=60, stale-while-revalidate=300` to all four spec handlers (internal + public, json + yaml). Caps origin load during codegen/probe storms; stale-while-revalidate lets CF serve briefly stale bytes while it refreshes in the background. - Backfill missing serve-handler tests for internal-spec endpoints so the Cache-Control sweep is covered uniformly across all four endpoints, not just the previously-tested public ones. Audit-sweep finding: only the public spec ever set info.contact.url (postprocessInternal doesn't touch contact at all), so the field- removal scope is single-entity. No platform-side env-aware swap machinery remains — PR #356 already removed swaggerspec.resolvePublicSpec. CORS: deferred per ticket. The 302 redirect path from docs.trakrf.id works for browser navigation, curl, and programmatic fetch without needing Access-Control-Allow-Origin on the spec endpoint. Revisit if docs.trakrf.id adds browser-side spec rendering against the platform origin. Out of scope (separate trakrf-docs PR): _redirects file, deleting mirror scripts (refresh-openapi.sh, swap-openapi-env.mjs, generate-postman.mjs, platform-meta.json, check-spec-sync.sh), static spec asset removal, Postman page rewrite to URL-import guidance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🚀 Preview Deployment Update ✅ This PR has been successfully merged into the preview branch. The preview environment will update shortly at: https://app.preview.trakrf.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TRA-743 — platform side of the "eliminate docs-side mirror, single source on platform" pivot.
PR #356 (TRA-742) swapped the drifted
info.contact.urlvalue forhttps://docs.trakrf.id/as a stop-gap. This PR removes the field entirely sodocs.trakrf.idcan redirect spec asset requests to the platform origin without re-introducing the same drift class TRA-742 patched.The companion
trakrf-docsPR (separate session, this user'sfeedback_docs_prs_separate_checkoutconvention) will land the Cloudflare_redirectsfile, delete the mirror scripts (refresh-openapi.sh,swap-openapi-env.mjs,generate-postman.mjs,check-spec-sync.sh,platform-meta.json), remove the static spec assets, and rewrite the Postman page to URL-import guidance.Spec changes
info.contact.urlfromapispec/postprocess.go's public-spec branch.info.contact.{name,email}remain authoritative for support routing; the bare-hostnameservers[]block continues to differentiate preview vs prod.must-have-info-contact-urlin.spectral.yamlwith rationale linking back to this ticket.info.contact.nameandinfo.contact.emailcontinue to satisfy the broader rule 218 "MUST have API meta information" intent.Cache-Control
Cache-Control: public, max-age=60, stale-while-revalidate=300added to all four spec handlers (internal + public × json + yaml). Caps origin load during codegen / BB probe storms; the stale-while-revalidate window lets the CF edge serve briefly stale bytes while it refreshes in the background. The spec only changes on deploy, so the staleness window is bounded by deploy cadence.Audit sweep
info.contact.url—postprocessInternaldoesn't touchcontactat all. Field-removal scope is correctly limited to the public path.swaggerspec.resolvePublicSpecand its associated tests.TestServeJSON/TestServeYAMLfor the internal pair so the header assertion runs uniformly).CORS — deferred
Per ticket, the 302 redirect path from
docs.trakrf.id→app.{env}.trakrf.id/api/v1/openapi.{yaml,json}works for browser navigation, curl, and programmatic fetch without needingAccess-Control-Allow-Originon the spec endpoint. Revisit if the docs site adds browser-side spec rendering (Stoplight Elements, etc.) that would fetch the spec via XHR/fetch against a different origin.Test plan
just backend api-specregenerates clean; only diff indocs/api/openapi.public.{yaml,json}is the removedcontact.urllinejust backend lint(fmt + vet) cleango test ./...— all 33 backend packages passjust backend api-lint(Redocly) clean (2 pre-existing warnings unrelated to this change)pnpm exec spectral lint docs/api/openapi.public.yaml --ruleset .spectral.yaml— 0 issuescurl -I https://app.preview.trakrf.id/api/v1/openapi.yamlshowsCache-Control: public, max-age=60, stale-while-revalidate=300curl -s https://app.preview.trakrf.id/api/v1/openapi.yaml | grep -A3 'contact:'confirmsurlabsentcurl -L https://docs.preview.trakrf.id/api/openapi.yamlreturns the preview platform spec (verified at ticket close, not in this PR)Out of scope
_redirectsfile, mirror-script deletions, Postman page rewrite — separatetrakrf-docsPR per the ticket's two-PR sequencing.trakrf/docsintotrakrf/platform) — explicitly deferred in the ticket as a post-launch reconsideration.🤖 Generated with Claude Code