OpenAPI Best Practices: Design, Validation and Versioning
OpenAPI best practices for design, validation, versioning and backward compatibility, with Australian government guidance and a checklist you can apply this week.

The best OpenAPI practice is to treat the definition as the contract for your API: one version-controlled file, validated automatically on every change, with a versioning rule that only breaks consumers on a deliberate major release. Get those three things right and documentation, SDKs, mock servers and tests follow from the same source. At LogicBranch we build custom software and AI systems, and the teams that struggle with integrations are rarely short of endpoints. They are short of a contract everyone trusts.
This guide is for the people who commission and own APIs: IT leaders, startup founders, agency principals and operations managers who need to judge whether their API work is sound, even if they do not write the YAML themselves.
TL;DR
- Keep one OpenAPI file as the single source of truth, stored in source control, and reuse shared pieces with
$refinstead of copying them. - Validate the file against the specification and a style ruleset on every pull request, and check in CI that the running API still matches it.
- Use semantic versioning (MAJOR.MINOR.PATCH) and put only the major version in the URL, for example
/v1/. - Adding optional things is safe. Removing fields, changing types or removing endpoints is a breaking change and needs a new major version.
- Use one consistent error format, realistic examples and a described security scheme, so developers can integrate without a call to your team.
Table of Contents
- What OpenAPI is, and where it fits
- Design the definition as a contract
- Structure and maintain the file as the API grows
- OpenAPI validation: what to check and when
- API versioning best practices
- A practical order of work
- Our perspective
- Getting this built properly
- FAQ
- Sources
What OpenAPI is, and where it fits
OpenAPI is a machine-readable format for describing RESTful HTTP APIs. Postman's overview describes it as a way to establish an API contract that can generate documentation, mock servers, client SDKs and tests. That is the practical payoff: one file, many outputs.
It also has limits worth knowing before you commit. The UK government's guidance on describing RESTful APIs notes that OpenAPI cannot describe SOAP, gRPC or GraphQL APIs, and that generated reference documentation often needs to be supplemented with quick starts, API-key instructions, sample applications and rate limit information. So if your integration is REST over HTTP, OpenAPI is the right description format. If part of your system uses another style, plan a separate way to document that part.

Design the definition as a contract
Treat the file as a product, not an export. The official OpenAPI best practices start with a single source of truth: one description that humans and tools both rely on, rather than a hand-written wiki page that drifts away from the code.
There are two ways teams usually get this wrong. They generate the file from code after the fact and never review it, or they write it once at kickoff and never update it. The first produces a file nobody reads. The second produces a file nobody trusts. A contract-first approach, where the definition is agreed before the build and reviewed like any other deliverable, avoids both, because the consumer team can react to the design while it is still cheap to change.

Reuse with components and $ref
The same customer object, pagination parameter or error response will appear dozens of times in a real API. The official guidance is to move repeated descriptions into the components section and point to them with $ref. Change the shared definition once and every operation that references it changes with it.
A small example of the pattern:
parameters:
- $ref: '#/components/parameters/PageSize'
responses:
'404':
$ref: '#/components/responses/NotFound'
Good habits for keeping specs tidy include naming schemas by the business concept (Invoice, not Response12), keeping one definition per concept, and reviewing how to organize API specifications so duplicated schemas and descriptions never creep in as the file grows.
Write examples developers will actually copy
Developers tend to copy an example before they read the schema. Scalar's documentation guidance recommends realistic values, such as properly formatted IDs and real-looking dates, in place of string and 0. An example that shows an ISO 8601 date and a real ID format prevents a whole category of integration bugs before they reach support.
Use one error format
Inconsistent errors are one of the most common complaints from integrating teams. One endpoint returns a plain message, another returns a code and a nested object. The same Scalar guidance points to RFC 9457, Problem Details for HTTP APIs, as a good standard for a consistent error shape across an API. Define it once in components and reference it from every operation.
Describe security in the contract
The OpenAPI documentation on describing API security lists the supported security types: API keys, HTTP authentication, mutual TLS, OAuth 2.0 and OpenID Connect. Declare the scheme in the definition and apply it to the operations that need it. That way, generated documentation and client SDKs know how to authenticate, and a reviewer can see at a glance which endpoints are open.
The contract is also the right place to be explicit about limits. If your API throttles clients, say so in the documentation and design the client behavior deliberately. Our guide to API rate limiting design covers the algorithms and what clients should do when they hit a limit. If your API sends webhooks, our notes on webhook security best practices cover both receivers and senders.
Structure and maintain the file as the API grows
A 200-line file is easy to manage. A 12,000-line file with five contributing teams is not. Plan for growth early.
- Keep it in source control. The official guidance is to store OpenAPI descriptions in source control, so every change has an author, a diff and a review.
- Split large descriptions into files. The same guidance suggests splitting along the URL hierarchy, so the
/customerspaths live together and the/invoicespaths live together. - Consider a dedicated repository. For larger organizations with several teams contributing, Stainless notes that an independent repository for the specifications is common.
- Know which version is which. The
info.versionfield describes your API specification. According to the Zalando API guidelines, it is distinct from the OpenAPI Specification version and from the version of the API implementation. Mixing these up is a common source of confusing release notes.
What Australian government guidance asks for
If you sell to or work with government, the direction is clear. The Western Australian Government's architecture decision record on HTTP API contracts says that for new or materially changed agency-controlled HTTP APIs, teams should maintain a version-controlled, machine-readable contract, preferably OpenAPI, and automate contract conformance, behavior and risk-based security testing. Even if you are not a government agency, that is a sensible bar for any enterprise API.
OpenAPI validation: what to check and when
Validation answers two different questions, and a healthy pipeline asks both.
Is the file itself valid? Check the document against the OpenAPI Specification on every pull request, and lint it against your style rules. Scalar recommends exactly this pairing: schema validation catches broken structure, and linting catches things like missing descriptions, inconsistent naming or absent examples.
Does the running API match the file? A perfectly valid file can still lie. The official best practices suggest using CI validation to check that the implementation conforms to the description. This is where contract testing earns its keep: a response that has quietly gained a required field, or lost one, fails the build instead of failing a customer.
A workable pull request checklist:
| Check | What it catches | Run it |
|---|---|---|
| Specification validation | Broken structure, bad $ref paths | Every pull request |
| Style linting | Missing descriptions, naming drift, no examples | Every pull request |
| Contract conformance tests | Implementation that differs from the file | Every build |
| Breaking-change comparison against the last release | Removed fields, changed types | Before each release |
| Security testing based on risk | Unprotected or weakly protected operations | Per release, weighted by risk |
The last two rows are where most teams have a gap, and they matter most for versioning, which is next.
API versioning best practices
Versioning is a promise about change. The best strategy is the one your consumers can predict.
Use semantic versioning, expose only the major version
The Australian government's API versioning guidance on api.gov.au is direct: use semantic versioning in the form MAJOR.MINOR.PATCH, start at MAJOR 1, and include only the MAJOR version in the URI, as v{MAJOR}. In practice:
/v1/customersstays stable for as long as v1 lives.- Minor versions (new optional features) and patch versions (bug fixes) are tracked in
info.versionand your release notes, not in the URL. - A new major version,
/v2/customers, appears only when a breaking change is unavoidable.
This keeps URLs stable and stops consumers from rewriting integrations every time you ship a small improvement.
Decide what counts as breaking
The same api.gov.au guidance draws the line clearly:
| Change | Backward compatible? |
|---|---|
| Add an optional field | Yes |
| Add a link, endpoint or media type | Yes |
| Remove a field | No, needs a new major version |
| Change a data type | No, needs a new major version |
| Remove an endpoint, function or media-type support | No, needs a new major version |
Two habits make this table useful. First, make additions optional by default, because a new required request field breaks every existing caller. Second, compare each release candidate against the previous published definition automatically, so a removed field is caught in review, not by an angry customer.
Running two major versions
When a v2 is genuinely needed, run v1 and v2 side by side for a published period, tell consumers early and give them a migration path. Because both versions have their own OpenAPI file, each stays testable and documented on its own. If you manage many APIs across several teams, versioning rules belong in a shared governance model: our piece on enterprise API management looks at federated governance, and our Kong vs Apigee migration checklist is useful if you are moving between gateway platforms.
A practical order of work
If you have an API today and a messy or missing definition, this is the order that delivers value fastest.
- Get the file into source control and make one person accountable for it.
- Add validation and linting to pull requests. Start with a small ruleset and tighten it over time.
- Move repeated schemas into components and use
$reffor every shared object, parameter and response. - Standardize errors on one format and reference it everywhere.
- Write realistic examples for your ten most-used operations.
- Declare your security scheme and apply it to every protected operation.
- Adopt the versioning rule (semantic versioning, major version in the URL) and write down what counts as breaking.
- Add a conformance check in CI so the file and the running API cannot drift.
None of this needs a big program. For most teams it is a few weeks of focused work, and it removes the most expensive integration problems.
Our perspective
We build custom software, and the pattern is consistent: the integrations that last are the ones with a contract that was designed, reviewed and tested, not the ones with the most endpoints.
Our engineering approach favors strict software engineering standards, modular domain-driven architecture, zero-trust security and transparent communication. An OpenAPI definition is where those principles become visible to the people who consume your API. Domain-driven design shows up as schemas named after real business concepts. Zero-trust shows up as security schemes declared on every protected operation. Transparent communication shows up as a changelog and a versioning rule a customer can read.
We also see APIs as the foundation for AI. Agentic tools and automation can only act reliably on a system whose interfaces are described precisely. A clean contract is what lets an AI agent, or a partner's developer, use your system without guessing. That is why we treat the definition as a deliverable of every project, not an afterthought, and why the goal is always technology that creates genuine value without complexity for its own sake.
Josh
Getting this built properly
If your API needs a contract-first redesign, a new platform, or AI agents that sit on top of your existing systems, this is work we do. LogicBranch delivers custom software development, AI software development, agentic AI and system integration for enterprises, Australian SMBs, startups, agencies and professional services firms. The services page lists everything we offer, and our home page introduces our products, including LogicEngine Core and ZeroTrust Vault.

Bring your current definition, or just the problem you are trying to solve, and we will tell you what a sound API foundation looks like for your business.
FAQ
Is OpenAPI only for public APIs?
No. It is just as useful for internal and partner APIs, where it removes the need to ask the owning team how an endpoint behaves. It can generate documentation, mock servers, client SDKs and tests from the same file, so internal teams benefit the same way external developers do.
How should I version an API?
Use semantic versioning (MAJOR.MINOR.PATCH), start at 1, and put only the major version in the URL, such as /v1/. This is the approach set out in the Australian government's API versioning guidance. Track minor and patch changes in your definition and release notes.
What is a breaking change?
Removing a field, changing a data type, or removing an endpoint or media-type support all break existing consumers and need a new major version. Adding optional fields, links, endpoints or media types does not. Compare each release against the previous definition automatically so nothing slips through.
How do I validate an OpenAPI file?
Run specification validation and style linting on every pull request, then use CI checks to confirm the running API conforms to the file. The first catches a broken or inconsistent description. The second catches an implementation that has drifted away from it.
Does OpenAPI work for GraphQL or gRPC?
No. According to UK government guidance, OpenAPI describes RESTful APIs and cannot describe SOAP, gRPC or GraphQL APIs. Use it for the REST parts of your system.
Sources
- Best Practices, OpenAPI Initiative
- Describing RESTful APIs with OpenAPI 3, GOV.UK
- What is OpenAPI?, Postman
- API documentation best practices, Scalar
- ADR 003: HTTP API Contracts, Government of Western Australia
- Meta information, Zalando RESTful API guidelines
- How to write a great OpenAPI spec, Stainless
- API versioning, api.gov.au
Recommended

API-First Design: What It Is and How to Apply It
API-first design means agreeing the API contract before building anything. See how it works, when it beats code-first, and how Australian businesses can use it.

Tokenization vs Encryption: How to Choose for Your Data
Tokenization and encryption protect data in different ways. Learn how each works, how they compare with masking and hashing, and which fits your Australian business.