Before you write a single path, decide who will build the spec and what you want out of it. There are two broad approaches, and they produce very different results downstream.
Design-first means you write the OpenAPI description before you write the implementation. The OpenAPI Initiative is blunt about its preference here: OpenAPI is not capable of describing every possible HTTP API, so if you code first and describe later, you eventually hit a construct you cannot express. You then either rewrite the code or twist the description until it "more or less" matches, which produces unintuitive and incomplete docs the OpenAPI best practices page.
Code-first means the implementation comes first and the description is derived from annotations, framework metadata or traffic sniffing. It has real appeal because developers do not need to learn another syntax, but the annotation tooling has historically lagged behind the current specification versions, and annotations drift from the code they sit next to Bump.sh on code-first workflows.
A decision rule that holds up in practice:
| Situation | Start with | Why |
|---|---|---|
| New public API, external consumers | Design-first | The spec is the contract; SDKs and docs generate from it before code exists |
| Internal service, single team, rapid churn | Code-first with a generated spec | Faster iteration, but you must validate the output in CI |
| Spec already exists but generates poor clients | Fix the spec, keep design-first | Inline schemas and missing operationIds cause most bad output |
| Multiple languages consuming the API | Design-first | One spec, many client stubs, one place to change |
Whatever you choose, there is one rule that overrides the rest: keep a single source of truth. If annotations generate the spec and you also commit the spec, newcomers will not know which one is live, so either pick one or add a CI check that fails when the two diverge the OpenAPI best practices page. Treat the description as a first-class source file, commit it early and let it drive testing and documentation generation.



