The generator moves into the Go toolchain per repo preference: internal/docs/bruno_gen.go emits the OpenCollection mirrors (same output contract — gate-verified example-request bodies, env-var params, device-token headers, login/register/refresh token-capture scripts) and TestBrunoMirrorsDocs grows a -update flag: verification by default, regeneration on demand: go test ./internal/docs -run TestBrunoMirrorsDocs -update Generator and checker are now the same code — they cannot drift apart. scripts/gen_bruno_from_docs.py deleted; opencollection.yml README points at the go-test command. Also fixed vs the Python pass: mirror placement follows the docs tree folder (RelPath), not the area frontmatter (several docs — highlights, notes, ratings, users, progress — carry a different area); docs blocks emit the collection's mapping form (content + type), not a bare scalar; JSON body sanity is checked at generation time. Idempotent: back-to-back -update runs are byte-identical. make test green (9 pkgs).
53 lines
1.3 KiB
YAML
53 lines
1.3 KiB
YAML
info:
|
|
name: Refresh Token
|
|
type: http
|
|
seq: 4
|
|
|
|
http:
|
|
method: POST
|
|
url: '{{base_url}}/api/auth/refresh'
|
|
auth: inherit
|
|
body:
|
|
type: json
|
|
data: |-
|
|
{
|
|
"refresh_token": "d4f5g6h7..."
|
|
}
|
|
settings:
|
|
encodeUrl: true
|
|
timeout: 0
|
|
followRedirects: true
|
|
maxRedirects: 5
|
|
|
|
runtime:
|
|
scripts:
|
|
- type: after-response
|
|
code: |-
|
|
function onResponse(res) {
|
|
try {
|
|
const responseBody = res.getBody();
|
|
const token = responseBody.access_token;
|
|
const refreshToken = responseBody.refresh_token;
|
|
if (token) {
|
|
bru.setEnvVar("token", token, { persist: true });
|
|
console.log("Access token saved");
|
|
}
|
|
if (refreshToken) {
|
|
bru.setEnvVar("refresh_token", refreshToken, { persist: true });
|
|
console.log("Refresh token saved");
|
|
}
|
|
} catch (error) {
|
|
console.error("Token capture failed:", error.message);
|
|
}
|
|
}
|
|
onResponse();
|
|
|
|
docs:
|
|
content: |-
|
|
# Refresh Token
|
|
|
|
`POST /api/auth/refresh` — auth: none.
|
|
|
|
Canonical reference: docs/developer/api/authentication/refresh_token.md (docs site → Developer → API). This request is GENERATED from that doc; edit the doc, then run the drift test with -update.
|
|
type: text/markdown
|