Skip to content

Commit ca674a8

Browse files
committed
docs(api): publish MyFestival OpenAPI spec via Redoc at /api-docs/
Adds a Redoc-rendered API docs page at /api-docs/ in the Cloudflare Pages deployment. The OpenAPI spec is generated from proto at build time (not committed), consistent with the proto-in-CI pattern from #426. - web/api-docs/index.html: Redoc page loading openapi.yaml from jsDelivr CDN - web/api-docs/.gitignore: openapi.yaml is generated, not committed - web/_headers: /api-docs/* CSP override allowing cdn.jsdelivr.net for Redoc - ci.yml build-web: buf generate + copy openapi.yaml before flutter build - mise.dev.toml proto:generate: also copies to web/api-docs/ for local dev https://claude.ai/code/session_015uTnGiC56cEELZMH2cQQU4
1 parent 9dfc334 commit ca674a8

5 files changed

Lines changed: 46 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ jobs:
194194
with:
195195
google-services-json: ${{ secrets.GOOGLE_SERVICES_JSON }}
196196

197+
- name: Generate OpenAPI spec from proto
198+
uses: bufbuild/buf-action@v1
199+
with:
200+
setup_only: true
201+
- run: cd proto && buf generate
202+
- run: cp docs/code/api/openapi/openapi.yaml web/api-docs/openapi.yaml
203+
197204
- name: Get git version info
198205
id: git_version
199206
run: scripts/get_version_info.sh github >> $GITHUB_OUTPUT

mise.dev.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ dir = "proto"
4141
run = "buf dep update"
4242

4343
[tasks."proto:generate"]
44-
description = "Generate OpenAPI from the proto contract (BSR remote plugin)"
44+
description = "Generate OpenAPI from the proto contract (BSR remote plugin), then sync to web/api-docs/"
4545
dir = "proto"
46-
run = "buf generate"
46+
run = """
47+
buf generate
48+
cp ../docs/code/api/openapi/openapi.yaml ../web/api-docs/openapi.yaml
49+
"""
4750

4851
[tasks."proto:clients"]
4952
description = "Generate Worker TS types and Flutter Dart client from OpenAPI spec"

web/_headers

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
Referrer-Policy: strict-origin-when-cross-origin
1717
Strict-Transport-Security: max-age=31536000; includeSubDomains
1818

19+
# API docs — relaxed CSP to allow Redoc from jsDelivr CDN.
20+
# This path serves developer documentation, not the Flutter app.
21+
/api-docs/*
22+
Content-Security-Policy: default-src 'self'; base-uri 'self'; frame-ancestors 'none'; object-src 'none'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data: https:; connect-src 'self'; worker-src 'self' blob:;
23+
X-Content-Type-Options: nosniff
24+
X-Frame-Options: DENY
25+
Referrer-Policy: strict-origin-when-cross-origin
26+
Strict-Transport-Security: max-age=31536000; includeSubDomains
27+
1928
# Production Environment - Explicit domain rule for clarity
2029
# Custom domain: cambeerfestival.app
2130
# Path-based rules below apply to this domain for performance optimization

web/api-docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated in CI (build-web job) and locally via: MISE_ENV=dev ./bin/mise run proto:generate
2+
openapi.yaml

web/api-docs/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Cambridge Beer Festival — MyFestival API</title>
7+
<link rel="icon" type="image/png" href="../favicon.png" />
8+
<style>
9+
body {
10+
margin: 0;
11+
padding: 0;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<redoc
17+
spec-url="openapi.yaml"
18+
expand-responses="200"
19+
required-props-first="true"
20+
></redoc>
21+
<script src="https://cdn.jsdelivr.net/npm/redoc@2.4.0/bundles/redoc.standalone.js"></script>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)