experimental api docs

This commit is contained in:
Devin Zuczek
2026-07-20 18:41:00 -04:00
parent 30bb6a131c
commit 7429ba4536
6 changed files with 2653 additions and 50 deletions
+19
View File
@@ -46,3 +46,22 @@ it('rejects an unauthenticated coach message', async () => {
expect(res.status).toBe(401)
expect(await res.json()).toEqual({ error: 'not signed in' })
})
it('serves the aggregated docs page with a source per documented service', async () => {
const res = await SELF.fetch('https://example.com/docs')
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('text/html')
const html = await res.text()
// Mounts the self-hosted Scalar bundle (not a CDN) and lists every service's spec.
expect(html).toContain('/docs/scalar.standalone.js')
for (const slug of ['auth', 'accounts', 'match', 'econ']) {
expect(html).toContain(`/docs/openapi/${slug}.json`)
}
})
it('404s a spec proxy for an unknown service (not an open proxy)', async () => {
// An un-allowlisted service is rejected before any upstream fetch, so this can't be
// turned into a proxy to `https://<anything>.<DOMAIN>`.
const res = await SELF.fetch('https://example.com/docs/openapi/evil.json')
expect(res.status).toBe(404)
})