API documentation beyond the generated spec: task-based guides, realistic examples, error and rate-limit documentation, changelogs and deprecation notices, developer portals (APIM), and keeping docs accurate through automation.
The OpenAPI document is reference documentation: it tells you every field, not how to get a job done. Good API docs add:
A developer portal (Azure API Management's, or Scalar/Redocly over the spec) is worth it when external developers need self-service keys and a try-it console. I keep docs accurate with docs as code: in the repo, reviewed in PRs, examples validated against the schema in CI. The trade-off is writing effort against support tickets and slow integrations.
"I think of API docs in three layers. Reference is the OpenAPI document: every path, parameter and schema, and in .NET 10 that's generated by the built-in OpenAPI support and rendered with Scalar or Swagger UI. Guides are task-based: how to authenticate, how to create an order and track it, how to page through results. And operational docs explain the rules of engagement: rate limits, error codes, idempotency keys, versioning and the deprecation policy. Most teams ship only the first layer, which is why developers still email you.
The single most useful metric is time to first successful call. If a new partner can get a sandbox key and make an authenticated call in 15 minutes, everything else goes better. So the getting-started page is short and copy-pasteable: curl, a C# snippet, and what the response looks like. Every operation has realistic examples, including the error cases, stored in the OpenAPI document so the mock server and the docs show the same thing. Errors get their own page listing each code, why it happens, whether it's safe to retry and what to do.
The mistake I see is docs that drift. Someone writes a lovely wiki page, the API changes, and now the docs are wrong, which is worse than none. So documentation lives in the repo next to the code: Markdown guides and the spec, reviewed in the same PR, with CI validating that examples match the schemas and links work. The changelog is partly generated from oasdiff between releases, with a human summary on top. A developer portal like Azure API Management's is worth it for external developers who need self-service sign-up, subscription keys and a try-it console; for internal consumers, a rendered spec plus guides in the repo is enough."
| Layer | Purpose | Source | Example |
|---|---|---|---|
| Reference | Every endpoint, parameter, schema | OpenAPI (generated or designed) | POST /v1/orders request schema |
| Guides | Complete tasks end to end | Markdown in the repo | "Take a payment and handle 3-D Secure" |
| Operational | Rules of engagement | Markdown + spec extensions | Rate limits, error catalogue, versioning policy |
| Item | Detail |
|---|---|
| Environments | Sandbox and production base URLs (e.g. Australia East) |
| Credentials | How to get a key or OAuth client; scopes |
| First call | curl and C# snippet, expected response |
| Next steps | Links to the two or three most common tasks |
| Option | Fits | Notes |
|---|---|---|
| Azure API Management developer portal | External developers, products and subscriptions | Self-service keys, try-it console, customisable; tied to APIM |
| Scalar / Swagger UI in the app | Internal teams | Zero cost; reference only |
| Redocly / static site from the spec | Public docs with guides | Docs as code, versioned with the API |
For a partner API, adding a 15-minute getting-started guide, examples for every error response and a code catalogue cut median time to first successful call from [two days] to [40 minutes] and reduced integration support tickets by [about half] over the next quarter.
Checks that the candidate sees documentation as part of the product and knows how to keep it accurate.
Green flags
Red flags
evaluating ──► "Can this API do what I need?" → overview, capabilities, pricing/limits
integrating ──► "How do I do task X?" → guides, examples, SDKs
debugging ──► "Why did I get this 409?" → error catalogue, trace ids, status page
maintaining ──► "What changed? What's going away?" → changelog, deprecation notices
Reference docs serve only part of the integrating phase. The rest needs written content.
OpenAPI 3.1 supports examples on parameters, request bodies and responses. In .NET 10 you can add them through operation or schema transformers on the built-in generator, or write them in a designed spec. Keeping examples in the spec means the docs, the mock server (Prism, APIM mock-response) and generated SDK samples all agree.
CI can validate examples against their schemas (Spectral's oas3-valid-media-example rule), so an example can't silently go stale.
For each operation, list the status codes and error codes it can return. A central error catalogue page has, per code: meaning, typical cause, retryable or not, and client action. Link each ProblemDetails type URI to its section on that page, so a developer can paste the type into a browser.
| Source | Gives you |
|---|---|
oasdiff changelog old.yaml new.yaml |
Accurate structural changes (added endpoint, new optional field) |
| Human release notes | Behaviour changes, context, migration steps |
| Deprecation page | What's deprecated, the sunset date, the replacement |
The Link header on deprecated responses (rel="deprecation") should point at the deprecation page.
APIM's portal is generated from the APIs imported into APIM (usually from your OpenAPI document). It provides sign-up, products and subscriptions (keys), a try-it console that calls through the gateway, and customisable content pages. It's valuable for external developers; for internal APIs it's often more than you need. Keep the source content in git and publish through the portal's automation or APIOps pipelines so it stays reviewable.
Use obviously fake data in examples (Jane Citizen, 0400 000 000, test card numbers). Real customer data in docs or sandbox fixtures is a Privacy Act and Notifiable Data Breaches risk.
oasdiff changelog.type and point the type URI at it.Adding realistic examples to the built-in OpenAPI document with an operation transformer, so docs and mocks share them.
// Program.cs
using System.Text.Json.Nodes;
using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi(options =>
{
options.AddDocumentTransformer((doc, ctx, ct) =>
{
doc.Info.Title = "Orders API";
// Point readers at the guides and the error catalogue, not just the reference.
doc.Info.Description = """
Start here: https://developer.example.com.au/orders/getting-started
Errors: https://developer.example.com.au/errors
Rate limits: 100 requests per minute per subscription key.
""";
return Task.CompletedTask;
});
options.AddOperationTransformer((operation, ctx, ct) =>
{
// Add a realistic 409 example to the cancel operation.
if (operation.OperationId == "cancelOrder"
&& operation.Responses?.TryGetValue("409", out var conflict) == true
&& conflict.Content?.TryGetValue("application/problem+json", out var media) == true)
{
media.Example = JsonNode.Parse("""
{
"type": "https://developer.example.com.au/errors#order-already-shipped",
"title": "Order already shipped",
"status": 409,
"detail": "Order 4821 shipped on 18 Nov 2026 and can't be cancelled.",
"code": "ORDER_ALREADY_SHIPPED",
"traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
}
""");
}
return Task.CompletedTask;
});
});
var app = builder.Build();
app.MapOpenApi();
app.MapPost("/v1/orders/{id:int}/cancellation", (int id) => TypedResults.NoContent())
.WithName("cancelOrder")
.WithSummary("Cancel an order")
.WithDescription("Cancels an order that hasn't shipped. Safe to retry with the same Idempotency-Key.")
.ProducesProblem(StatusCodes.Status409Conflict);
app.Run();
# .spectral.yaml - fail CI if examples don't match their schemas or operations lack descriptions
extends: ["spectral:oas"]
rules:
oas3-valid-media-example: error
operation-description: error
Documentation quality shows up in support load and integration speed, so I measure it that way: time to first successful call for new integrators, the number of integration support tickets, and which doc pages they reference. If a question comes up twice in support, it becomes a doc change. I also build a feedback loop into the docs themselves: a "was this helpful?" or "report a problem" link on each page that opens an issue in the API repo, and a short survey after a partner goes live.
Docs serve more than developers. Product and sales need the capabilities overview and limits to answer "can your API do X?"; support needs the error catalogue and trace id instructions to triage tickets. I involve them in reviewing those pages, because they hear the questions first.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Rendered spec only (Scalar/Swagger UI) | Internal APIs with one or two consumers | Minimal | Partners or public developers |
| Spec + Markdown guides as code | Most partner APIs | Writing and review time | Prototypes |
| APIM developer portal | External developers needing self-service keys and products | APIM cost, portal customisation | Teams not using APIM |
| Generated SDKs with samples | Many consumers in a few languages | SDK release process | Very small or fast-changing APIs |
The senior move is to make docs part of the definition of done and to automate the parts that drift: spec, examples and changelog.
OpenAPI is the vendor-neutral specification for describing HTTP APIs (paths, operations, schemas, security), currently 3.0 and 3.1. Swagger was the original name of that spec up to 2.0 and is now SmartBear's tooling brand (Swagger UI, Swagger Editor). In ASP.NET Core two jobs are separate: a generator builds the OpenAPI document from your endpoints, and a viewer renders it.
Microsoft.AspNetCore.OpenApi (AddOpenApi, MapOpenApi) instead of Swashbuckle, and ship no UI.The trade-off: the built-in generator is first-party and AOT-friendly, while Swashbuckle and NSwag have more mature extensions and, for NSwag, client generation.
Hiding the docs is not security: every endpoint must be protected by authentication and authorisation regardless. But publishing the full document hands an attacker a map: internal and admin endpoints, parameter names, limits, error shapes, sometimes examples with real personal data or OAuth client settings in the UI config.
My default for internal APIs is to map MapOpenApi() and the UI only in Development. If people need it in production, I put it behind RequireAuthorization("api-docs"), serve a separate curated document that excludes internal endpoints, or publish through an API Management developer portal.
For public or partner APIs a public document is the right call, as long as it's curated and the UI is patched. The trade-off: convenience for consumers versus cheaper reconnaissance.
I return ProblemDetails (RFC 9457, which replaced RFC 7807 in 2023) with Content-Type: application/problem+json. Its fields are type (a stable URI identifying the error kind), title (a constant summary for that type), status, detail (this occurrence) and instance, plus extensions.
errors map from field to messages.code from a published catalogue, like ORDER_ALREADY_SHIPPED, so clients branch on codes, not message text.traceId and log the detail.Consistency comes from one shared configuration (AddProblemDetails, exception handler) and API guidelines. The trade-off: a code catalogue is a contract you must maintain, but it's what lets clients handle errors reliably.
How to tell it (STAR)
**S:** Eight partners were integrating with our freight API in one quarter and our two-person team was drowning in support tickets because the only docs were the generated Swagger page. **T:** I took on making partners self-sufficient. **A:** I categorised three months of tickets, found [70]% were about auth scopes, error codes and paging, and wrote a getting-started guide, an error catalogue linked from our ProblemDetails types, and examples for every error, all in the repo with CI validation. **R:** Time to first successful call dropped from [two days] to [40 minutes] and weekly tickets fell from [25] to [about 10].
Last updated 23 Nov 2026.