Skip to content

[4/4] docs: generate API reference samples that run, in current idioms - #149

Merged
dazzatronus merged 1 commit into
mainfrom
derk/reference-code-samples
Sep 30, 2026
Merged

dazzatronus merged 1 commit into
mainfrom
derk/reference-code-samples

Conversation

@dazzatronus

@dazzatronus dazzatronus commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Run against a local server, no POST sample in the reference worked in any language. Most sent no body, Ruby, Java and HTTP never sent the API key, Go didn't compile, and NodeJS needed node-fetch, which no longer supports require.

This replaces widdershins's sample templates with templates/code-samples. Each template reads like the sample it produces; the shared logic (header selection and rendering JSON as each language's literals) lives in sample.def. Every sample reads the key from SHOTSTACK_API_KEY (HTTP shows YOUR_API_KEY) and uses the language's current client: built-in fetch, requests, Guzzle 7, Ruby's Net::HTTP, java.net.http and Go's net/http. Optional headers are left out, so the Generate samples no longer all send one fixed Idempotency-Key.

tests/reference-code-samples.cjs runs all 176 samples, plus each language against a body built to break string quoting, and checks the method, path, key and body that arrive. CI installs the eight runtimes.

Also fixes the Direct Upload samples, which called the Edit API: the build-docs.sh rewrite missed /upload.

463 lines: the templates and the check that proves them land together, because the check fails on the old templates.

Verify: CI step "Check reference code samples" → 184 of 184 ran correctly.

Stack (merge in order)

PR Adds Why it is separate
1/4 #147 (merged) Keeps <?php in rendered PHP samples A Shins fix, independent of what the samples contain
2/4 #151 (merged, released as 1.20.2) Current, valid examples in the spec Changes the published spec, so it releases a patch
3/4 #148 (merged) Shows each request body's example in the reference Docs build only
4/4 ← this PR #149 Current-idiom sample templates and a check that runs them Depends on the examples; the check and templates land together

@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from 6050494 to c35ac8c Compare September 29, 2026 13:08
@dazzatronus
dazzatronus added this pull request to stack #150 September 29, 2026 13:18
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from c35ac8c to 525ba45 Compare September 29, 2026 13:18
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from 525ba45 to ddede70 Compare September 29, 2026 23:05
@dazzatronus
dazzatronus marked this pull request as draft September 30, 2026 00:01
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from ddede70 to e6ee699 Compare September 30, 2026 00:06
@dazzatronus dazzatronus changed the title [3/3] docs: generate API reference samples that run, in current idioms [4/4] docs: generate API reference samples that run, in current idioms Sep 30, 2026
@dazzatronus
dazzatronus marked this pull request as ready for review September 30, 2026 00:07
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from e6ee699 to 8d551ba Compare September 30, 2026 00:19
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from 8d551ba to a32ab00 Compare September 30, 2026 00:29
Base automatically changed from derk/reference-request-examples to main September 30, 2026 00:33
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from a32ab00 to c906de0 Compare September 30, 2026 00:33
@dazzatronus
dazzatronus force-pushed the derk/reference-code-samples branch from c906de0 to 0e55c94 Compare September 30, 2026 00:43
@dazzatronus
dazzatronus merged commit fecfaa0 into main Sep 30, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.20.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant