Skip to content

REST & OpenAPI design

Designing HTTP APIs that consumers understand and that survive change.

Build APIs
9 posts1 h 10 min reading time
Start with part 1 →
  1. Soft delete in REST APIs — it's still a DELETE"We only set a flag, so it's not really a delete, so it should be a POST." A common line of reasoning that leaks a storage detail into the public contract. Why soft delete belongs behind DELETE, how to model hard delete and restore, and how to implement it cleanly with EF Core.8 min read
  2. PATCH the status or POST an action? Property updates vs. action endpoints"`PATCH /orders/42 { status: Shipped }` is RESTful, so it must be right." Until shipping has to reserve a carrier, send an e-mail and is only allowed for paid orders. A simple rule for when a state change is a property update and when it's a business operation that deserves its own endpoint.8 min read
  3. PATCH done right — JSON Merge Patch (RFC 7386) in ASP.NET CoreA C# DTO can't tell you whether the client sent a description set to null or didn't send the description at all. That's the whole difficulty of PATCH. How JSON Merge Patch defines the semantics, how to detect property presence in minimal APIs, and how to get a usable OpenAPI schema out of it.9 min read
  4. Reading the request body twice in minimal APIsYou bound the body to a typed DTO and now you need the raw JSON too, for merge patch presence checks, signature validation or auditing. But the stream is already consumed. How request buffering works, how to switch it on only where needed, and why an endpoint filter is too late.7 min read
  5. .NET 9 and OpenAPI — what broke, and how to fix itSwashbuckle gone from the templates, "Unable to render this definition", "No operations defined in spec" and transformers that stop compiling after the next upgrade. A practical guide to the built-in OpenAPI support since .NET 9, the usual errors and their real causes.7 min read
  6. JSON polymorphism in ASP.NET Core — discriminators, OpenAPI and types you don't know yetOne endpoint, many request shapes. `[JsonPolymorphic]` handles three payment methods nicely and turns into a merge-conflict magnet at thirty. Static attributes, runtime contract customization and schema transformers compared, with the pitfalls of each.8 min read
  7. Enums in APIs — adding a value shouldn't break your clientsYou add `Refunded` to an order status enum, and a consumer's deserializer crashes on the first refunded order. Why closed enums are a hidden breaking-change trap, how `x-extensible-enum` documents open-ended value lists, and how to generate it and consume it safely in .NET.7 min read
  8. Catching breaking API changes before your consumers do — OpenAPI diffs in CIA renamed property, a parameter that became required, an enum value too many. None of them fail a unit test, all of them break a client. How to turn your OpenAPI document into a contract test, from a simple snapshot to a semantic breaking-change check in the pipeline.8 min read
  9. Generate the OpenAPI document your API guidelines want — from code, not by handYour organization's API guidelines want an API ID in the info block, camelCase operation IDs, OAuth2 scopes per operation, extensible enums and proper date formats. Editing the generated JSON by hand doesn't scale. How to make ASP.NET Core produce a compliant document, with one attribute that both enforces a scope and documents it.8 min read