📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Beyond an OpenAPI document, what makes API documentation good? Talk about examples, documenting errors and edge cases, getting-started guides, changelogs, and when a developer portal such as Azure API Management's is worth it. How do you keep documentation accurate as the API changes?

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.

Mid-Level Theory Intermediate api-documentation azure-api-management changelog developer-portal openapi web-api

🎯 Key points

  • A generated spec is reference documentation, not a guide; developers need tasks and examples
  • Getting started: auth, first call, environments and sandbox in under 15 minutes (time to first call)
  • Realistic examples per operation, including error responses, kept in the OpenAPI document
  • Error catalogue: each code, cause, retryability and fix
  • Operational docs: rate limits (e.g. 100 requests/min, 429 with Retry-After), pagination, idempotency keys, versioning and deprecation policy
  • Changelog generated from spec diffs plus human release notes; deprecation notices with dates
  • Developer portal (APIM, Scalar, Redocly) for self-service keys, try-it console and products
  • Docs as code validated in CI, refined continuously from support tickets and reader feedback

⏱ 30-second answer

The OpenAPI document is reference documentation: it tells you every field, not how to get a job done. Good API docs add:

  • A getting-started guide: authentication, a sandbox, and a first successful call in minutes.
  • Realistic examples for every operation, including error responses.
  • An error catalogue with each code's cause, fix and whether to retry, plus docs for rate limits, pagination, idempotency and versioning.
  • A changelog and dated deprecation notices.

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.

🗣 Full answer (senior)

How I would answer this in an interview

"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."


Three layers of API documentation

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

What a getting-started page contains

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

Developer portal options

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

Production example

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.

🔍 What the interviewer is checking

Checks that the candidate sees documentation as part of the product and knows how to keep it accurate.

Green flags

  • Distinguishes reference, guides and operational docs
  • Talks about time to first call, examples and error documentation
  • Docs as code with CI validation and generated changelogs
  • Knows when a developer portal is worth it

Red flags

  • "Swagger is our documentation"
  • No plan to keep docs in sync
  • Ignores errors, limits and deprecation

📚 Learn in depth

1. Who reads API docs, and when

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.

2. Examples in the OpenAPI document

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.

3. Documenting errors

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.

4. Changelog and deprecation

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.

5. Developer portal in Azure API Management

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.

6. Docs as code

  • Guides in Markdown in the API repo.
  • Spec generated at build time and committed.
  • PR template asks "Docs updated?" and CI fails if the spec changed but the changelog didn't.
  • Link checker and example validation in CI.
  • Publish docs on merge, versioned alongside the API.

7. Privacy in examples

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.

Try it yourself

  1. Time yourself making a first authenticated call to one of your APIs using only its docs; write down every point you got stuck.
  2. Add response examples to two operations through an OpenAPI operation transformer and check them in Scalar.
  3. Run Spectral with the example validation rule and fix any invalid examples.
  4. Generate a changelog between two spec versions with oasdiff changelog.
  5. Write an error catalogue entry for one ProblemDetails type and point the type URI at it.

💻 Code

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

⚠ Common mistakes

  • Mistake: Treating the generated Swagger page as the documentation. Why it is wrong: It lists fields but doesn't explain tasks, flows or rules. Instead: Add a getting-started guide, task guides and operational docs.
  • Mistake: Documenting only success responses. Why it is wrong: Developers spend most of their time on errors. Instead: Document every error per operation and keep a catalogue with retry guidance.
  • Mistake: Docs in a wiki separate from the code. Why it is wrong: They drift as soon as the API changes. Instead: Docs as code in the repo, reviewed in the same PR.
  • Mistake: Examples that don't validate against the schema. Why it is wrong: Developers copy them and get 400s. Instead: Validate examples in CI with Spectral.
  • Mistake: No changelog or deprecation page. Why it is wrong: Clients discover changes in production. Instead: Generate structural changes with oasdiff and add human release notes.
  • Mistake: Real personal data in examples or sandbox data. Why it is wrong: It's a privacy breach risk under the Privacy Act. Instead: Use clearly synthetic data and test card numbers.
  • Mistake: Building a full developer portal for two internal consumers. Why it is wrong: Cost and maintenance without benefit. Instead: Rendered spec plus Markdown guides for internal APIs.

🏛 Senior insight: trade-offs

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.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions Swagger UI or Scalar Why: Checks the difference between OpenAPI, Swagger tooling and the built-in .NET support.
    How to answer

    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.

    • Since .NET 9 the templates use Microsoft's own Microsoft.AspNetCore.OpenApi (AddOpenApi, MapOpenApi) instead of Swashbuckle, and ship no UI.
    • In .NET 10 it emits OpenAPI 3.1 by default.
    • Swagger UI or Scalar are optional viewers you add yourself.

    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.

  2. When: Candidate talks about publishing docs or a try-it console Why: Checks the security implications of exposing API docs in production.
    How to answer

    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.

  3. When: Candidate mentions an error catalogue Why: Checks error response design with ProblemDetails and stable codes.
    How to answer

    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.

    • Validation errors: 400 with an errors map from field to messages.
    • Business errors: a stable machine-readable code from a published catalogue, like ORDER_ALREADY_SHIPPED, so clients branch on codes, not message text.
    • No internals: no stack traces or SQL; return a 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.

🛠 Real-world problems: how you handle them

Partner integrations stalled on undocumented errors
Situation
A [freight booking] API had [eight] partners integrating in one quarter. The only docs were the generated Swagger page. The integration team of [two] engineers was also the support team.
Signals
Integration support tickets averaged [25] a week; median time to first successful call was [two days]; most tickets asked about 401s from missing scopes, 409s on duplicate bookings and how pagination worked.
Investigation
Categorised three months of tickets: [70]% were answered by information that existed only in engineers' heads (scopes, error codes, retry rules). Timed a new developer following the docs: they needed help at auth, at the first POST and at pagination.
Resolution
Wrote a getting-started guide with sandbox keys through the APIM developer portal, added examples for every error response to the spec, published an error catalogue linked from ProblemDetails `type` URIs, and documented rate limits, idempotency and paging.
Prevention
Docs live in the repo; PRs that change the spec must update guides or the changelog (CI check); Spectral validates examples; every repeated support question becomes a docs task.

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].

More in API Design

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me