Skip to content

Commit 33dfc1d

Browse files
committed
add captured examples to git for CI/CD docgen. TODO: add better sanitizing in case this runs on production server eventually
1 parent 666b7d8 commit 33dfc1d

34 files changed

Lines changed: 65649 additions & 3 deletions

.github/workflows/fly-deploy.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,20 @@ jobs:
7171
sed -i "s/const apiVersion = .*/const apiVersion = \"$VERSION\"/" go-relay/cmd/docgen/main.go
7272
7373
# Regenerate OpenAPI / AsyncAPI / api-docs JSON with the new version
74+
# This also regenerates docs/md/api/*.md from scratch (no examples yet)
7475
cd go-relay && go run ./cmd/docgen/ && cd ..
7576
77+
# Re-inject captured code examples into the freshly-regenerated markdown.
78+
# docs/examples/*.json are committed to the repo so they're available here.
79+
corepack enable && pnpm install --ignore-workspace --ignore-scripts
80+
pnpm run docs:examples
81+
7682
# Configure git
7783
git config --global user.name 'github-actions[bot]'
7884
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
7985
8086
# Commit and push changes only if something actually changed
81-
git add package.json frontend/package.json go-relay/cmd/server/main.go go-relay/cmd/docgen/main.go public/openapi.json public/asyncapi.json public/api-docs.json
87+
git add package.json frontend/package.json go-relay/cmd/server/main.go go-relay/cmd/docgen/main.go public/openapi.json public/asyncapi.json public/api-docs.json docs/md/api/
8288
if git diff --cached --quiet; then
8389
echo "Version already up to date, skipping commit"
8490
else

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ lerna-debug.log*
3333
test-results/
3434
tests/.global-vars.json
3535

36-
# generated test examples (regenerated by running tests)
37-
docs/examples/
3836

3937
.VSCodeCounter/
4038
*.notes
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[
2+
{
3+
"endpoint": "/auth/register",
4+
"method": "POST",
5+
"description": "/auth/register - with email verification",
6+
"request": {
7+
"url": "http://localhost:3010/auth/register",
8+
"method": "POST",
9+
"headers": {},
10+
"body": {
11+
"email": "verify-test-1778884125157@example.com",
12+
"password": "TestPassword123!"
13+
}
14+
},
15+
"response": {
16+
"status": 201,
17+
"data": {
18+
"createdAt": "2026-05-15T22:28:45Z",
19+
"email": "verify-test-1778884125157@example.com",
20+
"emailVerified": true,
21+
"id": 793,
22+
"sessionExpiresAt": "2026-06-14T22:28:45Z",
23+
"sessionToken": "6024a179774777642460a5c82f00cb28e429912b1ff3bf108c7dce16afa9514f",
24+
"subscriptionStatus": "free"
25+
}
26+
},
27+
"codeExamples": {
28+
"javascript": "const baseUrl = 'http://localhost:3010';\nconst path = '/auth/register';\nconst url = `${baseUrl}${path}`;\n\nconst response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n \"email\": \"verify-test-1778884125157@example.com\",\n \"password\": \"TestPassword123!\"\n })\n});\nconst data = await response.json();\nconsole.log(data);",
29+
"curl": "curl -X POST 'http://localhost:3010/auth/register' \\\n -H \"Content-Type: application/json\" \\\n -d '{\"email\":\"verify-test-1778884125157@example.com\",\"password\":\"TestPassword123!\"}'",
30+
"python": "import requests\n\nbase_url = 'http://localhost:3010'\npath = '/auth/register'\nurl = f'{base_url}{path}'\n\nresponse = requests.post(\n url,\n json={\n \"email\": \"verify-test-1778884125157@example.com\",\n \"password\": \"TestPassword123!\"\n }\n)\ndata = response.json()\nprint(data)",
31+
"typescript": "import axios from 'axios';\n\n(async () => {\n const baseUrl = 'http://localhost:3010';\n const path = '/auth/register';\n const url = `${baseUrl}${path}`;\n\n const response = await axios({\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n url,\n data: {\n \"email\": \"verify-test-1778884125157@example.com\",\n \"password\": \"TestPassword123!\"\n }\n });\n const data = response.data;\n console.log(data);\n})();",
32+
"emojicode": "📦 sockets 🏠\n\n💭 Emojicode HTTP Client\n💭 Compile: emojicodec example.🍇 -o example\n💭 Run: ./example\n\n🏁 🍇\n 💭 Connection settings\n 🔤localhost🔤 ➡️ host\n 3010 ➡️ port\n 🔤/auth/register🔤 ➡️ path\n\n 💭 Request body\n 🔤{\"email\":\"verify-test-1778884125157@example.com\",\"password\":\"TestPassword123!\"}🔤 ➡️ body\n\n 💭 Build HTTP request\n 🔤POST /auth/register HTTP/1.1❌r❌nHost: localhost:3010❌r❌nContent-Type: application/json❌r❌nContent-Length: 79❌r❌n❌r❌n{\"email\":\"verify-test-1778884125157@example.com\",\"password\":\"TestPassword123!\"}🔤 ➡️ request\n\n 💭 Connect and send\n 🍺 🆕📞 host port❗ ➡️ socket\n 🍺 💬 socket 📇 request❗❗\n \n 💭 Read and print response\n 🍺 👂 socket 4096❗ ➡️ data\n 😀 🍺 🔡 data❗❗\n \n 💭 Close socket\n 🚪 socket❗\n🍉"
33+
}
34+
}
35+
]

docs/examples/auth-examples.json

Lines changed: 577 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)