Reference docs, generated from your code.
Gravity reads your OpenAPI file and your code, writes the reference, and ties every fact to the code it came from. When the code changes, the docs change with it.
src/keys.go
12// Keys13const graceWindow = 24 * time.Hour1415r.POST("/v1/keys/rotate", rotateKey)1617func rotateKey(w, r) {18 id := body.String("keyId")19 idem := r.Header.Get("X-Idempotency-Key")20 …21}2223type RotateResponse struct {24 Key string25 ExpiresAt time.Time26}
API reference Keys
Parameters
Response
Writing from src/keys.go…
Generated doesn’t mean unreviewed
Every generated update arrives as a change request in the same review queue as hand-written edits. Nothing reaches your readers until someone on your team approves it.
Your pipeline tells you the docs are wrong, before your customers do.
When a code change outpaces the reference, Gravity doesn’t wait for someone to notice. It proposes the matching update, as a change you can read in seconds.
- One step in the pipeline you already haveThe check runs on every pull request. No annotations or sidecar files to maintain.
- New, changed and removed endpointsIt notices what moved in the code and which pages describe it.
- The exact edit, ready to reviewThe update arrives as a change request, so the reference is corrected before it ships.
Try a pull request that
Make key rotation safe to retry
#1287src/gateway.go
−r.POST("/v1/keys/rotate", rotateKey)
+r.POST("/v1/keys/rotate", idempotent(rotateKey))
Docs drift check
running- Comparing the gateway with the published reference
A reference your team trusts on sight.
Every endpoint, parameter and type, organised by service and ready to publish on your own domain.
- A map of your whole codebaseServices, packages and module boundaries are laid out for you, so a new engineer can find their way on day one.
- Typed, end to endEndpoints, methods, parameters and types come from your OpenAPI or Swagger file, and change when it does.
Pick an endpoint, and open a type to see its fields.
Keys
Rotate an API key
Issues a new key. The previous key stays valid for 24 hours.
POSThttps://api.acme.com/v1/keys/rotate
- keystring
The new API key. Shown once.
- expiresAttimestamp
When the previous key stops working.
The key being replaced.
Generated from src/gateway.go, line 41In step with main · updated by change request #418
You own the words. Gravity keeps the facts.
Generated blocks stay tied to the code they describe, and everything around them is yours to write. Editing a generated block opens a suggestion for the code’s owner; it never overwrites anything silently.
Rotating an API key
Keep your integrations secure by rotating keys on a schedule.
Call the rotate endpoint to issue a new key. The old key stays valid for so you can roll it out without downtime.
POST /v1/keys/rotate → { key: string, expiresAt: timestamp }
In production, keep the returned key in your secret manager, not in source control.
Source code · owned by @keys-team
src/keys.go
18const graceWindow = 24 * time.Hour19func rotateKey(w, r) {20 …
Edited a generated block?
Your edit becomes a suggestion for the code’s owner, so the docs and the code never disagree.
The difference your readers feel.
The same endpoint, kept two ways. One drifts as soon as an engineer ships a change; the other moves with the code.
Jan · Page written
Kept by hand
Edited todayPOST /v1/keys/rotate
- Body: keyId (string)
- The old key stays valid for 1 hour
- Retrying a request issues another new key
- Returns key (string)
Correct, for now.
Kept by Gravity
In step with mainPOST /v1/keys/rotate
- Body: keyId (string)
- The old key stays valid for 1 hour
- Retrying a request issues another new key
- Returns key (string)
Generated from the code, and tied to it.
Explore the rest of Gravity
Each part works on its own, and better next to the others: one path from a code change to a reader’s answer.
See it on your own code.
Connect a repository and see your reference generated, then kept in step with every change.