- Shell 78.4%
- Makefile 21.6%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| patches | ||
| scripts | ||
| .gitattributes | ||
| .gitignore | ||
| CODEOWNERS | ||
| Makefile | ||
| openapi.v1.yaml | ||
| openapi.yaml | ||
| OPERATIONS.md | ||
| policy.yaml | ||
| README.md | ||
| swagger.v1.json | ||
forgejo-api-contract
The shared API contract for Forgejo clients built at Raster & State. One pinned spec, one operational policy, consumed by both Fjord (Swift / iOS) and fj (Rust CLI).
This repo is the single source of truth for:
- which Forgejo API version the clients target,
- the OpenAPI 3.0 document they generate code from,
- the operational policy (retry budget, body cap, redaction list, version floor) the clients are expected to honor in lockstep.
It contains no compiled code. Each consumer vendors this repo as a git submodule and runs its own language-specific code generation.
What's here
| Path | Role |
|---|---|
swagger.v1.json |
Upstream Forgejo spec, vendored at a pinned version (Forgejo 15.0.2, Gitea 1.22-compatible). |
openapi.v1.yaml |
Raw OpenAPI 3.0 conversion of the swagger via swagger2openapi. Committed so consumers don't need Node to build. |
openapi.yaml |
The patched spec: openapi.v1.yaml plus policy.yaml's requiredOverrides: applied. This is the document consumers generate from. |
policy.yaml |
Operational policy shared by every consumer: version floor, retry table, body cap, redaction allowlist, optionality overrides, required-field overrides. |
patches/ |
Reserved for future Redocly-style overlays. Empty today; the simple required: rewrites are driven from policy.yaml. |
scripts/apply-required-overrides.sh |
Reads policy.yaml's requiredOverrides:, applies them to openapi.v1.yaml, writes openapi.yaml. Validates each schema and field exists before writing. |
scripts/generate-policy-swift.sh |
Consumer-side convenience: renders policy.yaml into a Swift constants file. Invoked by Fjord with its own output path. A generate-policy-rs.sh will join it when fj adopts the contract. |
Makefile |
Contract-level targets: fetch, convert, patch, check. |
OPERATIONS.md |
Re-vendor cadence, patch hygiene, ownership, breaking-change protocol. |
Contract-level commands
make help # list targets
make fetch # re-download swagger.v1.json from rasterhub.com
make convert # rerun swagger2openapi (writes openapi.v1.yaml)
make patch # apply policy.yaml requiredOverrides (writes openapi.yaml)
make regenerate # convert + patch
make check # fail if either committed spec drifts (CI gate)
make check is this repo's CI gate. Language-specific code generation
(Swift types, Rust constants) is each consumer's responsibility and runs
in the consumer's own CI.
How consumers use this
Each consumer adds this repo as a git submodule, points its code generator
at openapi.yaml, and runs its own policy.yaml-to-constants step:
- Fjord vendors the submodule at
Fjord/Tools/forgejo-contract/, runsswift-openapi-generatoragainstopenapi.yaml, and runsscripts/generate-policy-swift.shto produceForgejoPolicyconstants. - fj (planned) will vendor the submodule, generate Rust models, and run
a
generate-policy-rs.shfor the matchingpolicy.rsconstants.
Prerequisites
node24.x (forswagger2openapi, invoked vianpx --yes).yq, Mike Farah's Go implementation (not the Pythonyqwrapper). The patching script refuses to run on the wrong flavor.make,bash,curl.
Re-vendoring
See OPERATIONS.md for the cadence, the patch-hygiene rules, and the
major-version bump protocol.
versionFloor vs spec version
policy.yaml's versionFloor.semver is the minimum Forgejo major version
clients agree to talk to (7.0.0, set by fj's pre-existing version-warning
baseline). It is independent of the spec version vendored in
swagger.v1.json (Forgejo 15.0.2 today); the spec floats forward, the floor
changes only when both clients agree to drop compatibility with older
servers.