Phase 10: Fix API documentation routing and add schema download link

- Fix /docs/api route to go directly to API docs page instead of redirecting
- Fix docs.ts link to point to /compete/docs/api instead of itself
- Add download button for replay-schema-v1.json in API docs
- Reorder router routes to ensure /docs/api is matched before /docs

The API documentation at /docs/api now correctly shows the OpenAPI-style
endpoint documentation for all static JSON file paths on Pages, R2, and B2,
including the versioned replay format specification.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-05-08 15:02:07 -04:00
parent c5557016cd
commit bc857d10bc
4 changed files with 5 additions and 3 deletions

View file

@ -1 +1 @@
02338375440c4ead8fd7156f034ee29a334daef3
5024353c1e10455091d07cadbec2fd5be4c69ba4

View file

@ -272,8 +272,8 @@ router
.on('/sandbox', redirect('/compete/sandbox'))
.on('/register', redirect('/compete/register'))
.on('/bots', redirect('/leaderboard'))
.on('/docs/api', lazyRoute(loadDocsApiPage))
.on('/docs', redirect('/compete/docs'))
.on('/docs/api', redirect('/compete/docs'))
.on('/clip-maker', redirect('/watch/replays'))
.on('/rivalries', lazyRoute(loadRivalriesPage))
.on('/feedback', lazyRoute(loadFeedbackPage))

View file

@ -489,6 +489,8 @@ export function renderDocsApiPage(): void {
<section id="replay-schema" class="schema-section">
<h2>Replay JSON Schema</h2>
<p>The replay format is versioned. The current version is <code>v1</code>.</p>
<p><a href="/replay-schema-v1.json" target="_blank" class="btn secondary">Download replay-schema-v1.json</a></p>
<p>The schema can be used with JSON Schema validators to ensure replay files conform to the expected format.</p>
<pre><code>${escapeHtml(replaySchema)}</code></pre>
</section>

View file

@ -100,7 +100,7 @@ export function renderDocsPage(): void {
<section>
<h2>Data &amp; API</h2>
<p>All match data (leaderboards, replays, bot profiles) is exposed as static JSON files served from CDN.</p>
<p><a href="#/compete/docs" class="btn secondary">View API Reference</a></p>
<p><a href="#/compete/docs/api" class="btn secondary">View API Reference</a></p>
</section>
</div>
</div>