Classifies API changes as breaking or safe (including enums, validation, defaults and semantics), the tolerant reader pattern and System.Text.Json settings that support it, and consumer-driven contract testing with Pact.
A breaking change is anything that makes a correct existing client fail or behave wrongly. Obvious ones are removing or renaming fields and changing types. Less obvious ones: a new required request field, stricter validation, a changed default or sort order, a different status code, and a new enum value that a client's exhaustive switch doesn't handle.
Adding optional fields and endpoints is safe only if clients are tolerant readers: they ignore unknown members and unknown enum values. System.Text.Json ignores unknown members by default, but opting into strict settings, such as UnmappedMemberHandling.Disallow or a plain JsonStringEnumConverter, makes a client throw JsonException on the next additive server change.
I protect compatibility with OpenAPI diffs for structure and consumer-driven contract tests (Pact) for the behaviour each consumer actually relies on, and I document what isn't promised. The trade-off: every observable behaviour becomes a contract, so you decide deliberately what you promise.
"My working definition is: a change is breaking if a client that was correct yesterday fails or does the wrong thing today without changing its code. Removing a field or changing a number to a string is obvious. The ones that catch teams are subtler. Making a request field required, or tightening validation from 100 characters to 50, breaks clients that were sending valid requests. Changing a default page size, the default sort order or the meaning of a status field breaks clients that relied on it, even if the schema is identical. Returning 422 where you used to return 400 breaks error handling. And adding an enum value, say a new order status
OnHold, breaks any client with an exhaustive switch or a strict enum deserialiser.For example, at [company] we [added a
PartiallyRefundedpayment status]. The schema diff said it was additive, but [a partner's Java client failed deserialising the unknown value] and [their reconciliation job stopped for a morning]. After that we documented every enum in the API as extensible, told clients to map unknown values to a fallback, and treated new enum values as a change requiring notice. That's the tolerant reader pattern: on both sides, read only what you need, ignore unknown members, and don't fail on values you don't recognise. On .NET, System.Text.Json ignores unknown JSON members by default, which is tolerant; butUnmappedMemberHandling.Disallow, required constructor parameters and integer-only enum converters make your own clients brittle.Structural tools like oasdiff catch removed fields and type changes in CI. They can't see behaviour, so for important consumers I use consumer-driven contract tests with Pact: each consumer publishes the interactions it relies on, and the provider's pipeline verifies them before deploy. The senior point is Hyrum's law: with enough consumers, every observable behaviour is depended on by somebody, so you decide what you promise and test that."
| Change | Breaking? | Why |
|---|---|---|
| Add optional response field | No (tolerant readers) | Unknown members ignored |
| Add optional request field with a default that preserves behaviour | No | Old clients get old behaviour |
| Add endpoint or operation | No | Nobody calls it yet |
| Remove or rename a field | Yes | Clients read or send it |
Change type or format (int to string, date format) |
Yes | Deserialisation fails |
| Make a request field required | Yes | Old requests now fail validation |
| Stricter validation (shorter max length, narrower range) | Yes | Previously valid input rejected |
| Looser validation | Usually no | But can break clients that relied on the server rejecting input |
| New enum value in a response | Yes for strict clients | Exhaustive switches and strict deserialisers fail |
| Change default (page size, sort, currency) | Yes | Behaviour changes silently |
| Change status code or error code | Yes | Error handling branches differ |
| Change auth scopes required | Yes | Calls start returning 403 |
| Performance change (much slower, lower rate limit) | Effectively yes | Timeouts, 429s |
| Side | Rule |
|---|---|
| Client | Ignore unknown members; map unknown enum values to Unknown; don't depend on member order; only read fields you use |
| Server | Accept and ignore unknown request members (unless over-posting matters); keep defaults stable; add, don't change |
After adopting Pact for our [four] internal consumers and oasdiff in CI, the provider pipeline blocked [eleven] breaking changes in a year. Eight were structural (caught by oasdiff), three were behavioural (a changed default sort and two stricter validations) that only the contract tests caught.
Checks a senior understanding of compatibility beyond the schema: behavioural changes, enums, tolerant readers and automated contract testing.
Green flags
Red flags
With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviours of your system will be depended on by somebody.
The documented contract is a subset of the observable behaviour:
┌────────────────────── observable behaviour ─────────────────────────┐
│ sort order, timing, field order, error wording, default page size │
│ ┌─────────────────── documented contract (OpenAPI) ───────────────┐ │
│ │ paths, schemas, status codes, documented error codes │ │
│ └───────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
Two defences: make the documented contract explicit about what is not promised ("order of results is unspecified unless sort is given"), and make undocumented behaviour stable anyway where it's cheap (always apply a default sort).
Adding a value is additive for the schema but breaking for clients that:
switch exhaustively and throw in default,Mitigations: document enums as extensible (OpenAPI 3.1 has no built-in flag; use a description or an x-extensible-enum extension), send them as strings, and tell clients to map unknown values to a fallback. On the .NET client side, a custom JsonConverter that maps unknown strings to Unknown is a tolerant reader.
| Setting | Default | Effect on tolerance |
|---|---|---|
| Unknown JSON members | Ignored | Tolerant |
UnmappedMemberHandling.Disallow |
Off | Throws on any new field: brittle client |
JsonStringEnumConverter |
Not on by default | Unknown string values throw JsonException |
RespectRequiredConstructorParameters (.NET 9+) |
Off | Missing constructor parameters throw |
RespectNullableAnnotations (.NET 9+) |
Off | Nulls in non-nullable members throw |
required members |
Enforced | Missing member throws |
On the server, strictness on requests (reject unknown members) protects against over-posting and typos, but means a client adding a field for a newer server version fails against an older one. Pick deliberately.
consumer test (PactNet) ──► pact file: "GET /orders/42 returns { id, status }"
│ publish
▼
Pact Broker / PactFlow ──► provider pipeline verifies every consumer's pact
against the real API (with provider states)
▲ │
can-i-deploy? ◄───────── results ──────────────┘
The consumer specifies only what it uses, so the provider is free to change everything else. PactNet (v5) runs in xUnit; can-i-deploy gates releases on both sides. It works best for internal consumers you can talk to; for unknown public consumers, rely on oasdiff, conservative change rules and long deprecation windows.
Expand and contract:
totalMoney) alongside the old (total); write both.The same pattern applies to validation: log what would fail under the stricter rule for a few weeks before enforcing it.
JsonSerializerOptions, then with UnmappedMemberHandling.Disallow, and compare.JsonStringEnumConverter; then write a converter that falls back to Unknown.oasdiff breaking on two versions of a spec where you made a field required.A tolerant .NET client: ignores unknown members and maps unknown enum values instead of throwing.
// Client/TolerantEnumConverter.cs
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Shop.Client;
public enum OrderStatus { Unknown = 0, Open, Paid, Shipped, Cancelled }
// Unknown strings (e.g. a new "OnHold") become Unknown instead of a JsonException.
public sealed class TolerantEnumConverter<TEnum> : JsonConverter<TEnum> where TEnum : struct, Enum
{
public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
reader.TokenType == JsonTokenType.String
&& Enum.TryParse<TEnum>(reader.GetString(), ignoreCase: true, out var value)
? value
: default; // Unknown = 0
public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options) =>
writer.WriteStringValue(value.ToString());
}
public sealed record OrderDto(
int Id,
[property: JsonConverter(typeof(TolerantEnumConverter<OrderStatus>))] OrderStatus Status);
public static class Demo
{
// Defaults are tolerant: unknown members are ignored. Don't add UnmappedMemberHandling.Disallow on a client.
private static readonly JsonSerializerOptions Options = new(JsonSerializerDefaults.Web);
public static OrderDto Parse() =>
JsonSerializer.Deserialize<OrderDto>(
"""{ "id": 42, "status": "OnHold", "newFieldAddedLater": true }""", Options)!;
// => OrderDto { Id = 42, Status = Unknown }
}
A consumer-driven contract test with PactNet: the consumer states only what it relies on.
// Consumer.Tests/OrdersApiPactTests.cs
using PactNet;
using PactNet.Matchers;
using Xunit;
namespace Shop.Client.Tests;
public sealed class OrdersApiPactTests
{
private readonly IPactBuilderV4 _pact = Pact.V4("mobile-app", "orders-api", new PactConfig())
.WithHttpInteractions();
[Fact]
public async Task Get_order_returns_id_and_status()
{
_pact.UponReceiving("a request for order 42")
.Given("order 42 exists")
.WithRequest(HttpMethod.Get, "/v1/orders/42")
.WillRespond()
.WithStatus(System.Net.HttpStatusCode.OK)
.WithJsonBody(new { id = 42, status = Match.Type("Open") }); // only fields we use
await _pact.VerifyAsync(async ctx =>
{
using var http = new HttpClient { BaseAddress = ctx.MockServerUri };
var order = await http.GetFromJsonAsync<OrderDto>("/v1/orders/42");
Assert.Equal(42, order!.Id);
});
}
}
UnmappedMemberHandling.Disallow in client code. Why it is wrong: Every additive server change breaks the client. Instead: Keep the tolerant default on clients; be strict only where it protects the server.Backward compatibility is a cost you pay continuously to avoid paying a much larger one at every release. The cheapest place to buy it is in the initial design: extensible enums, string-encoded money, optional fields with stable defaults, and documentation of what isn't promised. After that, automation (oasdiff, Pact) makes the policy enforceable rather than aspirational.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| oasdiff breaking check in CI | Every API with an OpenAPI document | Near zero | Never skip it |
| Consumer-driven contracts (Pact) | Internal consumers you can coordinate with | Broker, provider states, consumer buy-in | Unknown public consumers |
| Expand and contract | Renames and type changes | Temporary duplication | Truly incompatible models (new major version) |
| Log-then-enforce for validation | Tightening rules on live APIs | Weeks of delay | Security fixes that must ship now |
I measure it by breaking changes caught before production versus reported by clients, and by how many releases needed a new major version.
I make the committed build-time spec the contract and gate pull requests on it:
oasdiff breaking compares the PR's spec with main and the last released spec, and fails on removed paths or properties, new required request fields, narrowed enums or changed types.AddOpenApi("v1"), AddOpenApi("v2")), so breaking changes go into a new version while v1 stays frozen.The trade-off: CI becomes stricter and occasionally needs a deliberate override, but breaking changes become explicit decisions instead of production incidents.
There are four common schemes: URL segment (/v1/orders), query string (?api-version=1.0), a request header (api-version: 1.0) and a media type parameter (Accept: application/json;v=1.0). In ASP.NET Core the Asp.Versioning library (10.x for .NET 10) implements all four through an ApiVersionReader, and can combine them.
The senior part: version only for breaking changes. Additive changes (new optional fields, new endpoints) should ship without a version bump, because every live version is a support cost you carry for years.
Ship the rule in log-only mode first: evaluate it, record a metric and log the client id when a request would fail, but still accept it. After a few weeks you know exactly which clients send non-conforming data. Contact them, give a date, optionally return a warning header, then enforce in the next major version or after the notice period. Security-driven rules are the exception and ship immediately with direct communication.
How to tell it (STAR)
**S:** We added a new payment status and a partner's reconciliation job failed overnight because their generated client threw on the unknown value, even though our diff tool said the change was additive. **T:** I owned the API and needed to restore the partner and stop this class of break. **A:** I added a per-subscription mapping to the old value within [two hours], then marked every enum as extensible in the spec, wrote tolerant-reader guidance with a client example, added a Spectral rule, and made enum additions a notified change. **R:** The partner recovered the same day, and in the following [year] we added [five] enum values with no client incidents.
Last updated 23 Nov 2026.