N07
Warning
Requests
N07 — A service's files are behind its spec
wf api sync writes a service's generated/ folder from its OpenAPI spec, and wf api check fails when the two disagree. When the spec has changed since the files were written, the program is checked against a contract the server no longer keeps: run wf api sync.
The fix
run wf api sync, read the diff, and fix what the change broke.
wf api sync writes a service's contract from its spec: its groups, its
types and its error enums. The program is checked against those files, not
the spec, so when the spec moves on — a field renamed, an endpoint added, a
status that can now come back — the build still checks the program against
the old contract, and the page finds out at run time. wf check reads the
spec, writes the files in memory, and warns when they differ from the ones
on disk; wf api check does the same and exits 1, for a CI step.
A file in generated/ that does not open with the // Code generated by …
comment wf api sync writes, or one sync would not write, is not
the reason for this warning: sync refuses to touch it, and says so. Move
what it says to service.wf or a file of your own.
Why this rule exists
Warning. A service wf api keeps in apis whose generated/ folder is not
what its spec says now: ` Backend's files are behind openapi.json:
wf api sync Backend would change src/api/backend/generated/types.wf `.
lints may lower it:
"lints": { "N07": "off" }
// wf-allow(N07)