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

📚 Interview question

How do you keep TypeScript types in sync with an ASP.NET Core API's contracts?

Junior Theory Beginner

🎯 Key points

  • AddOpenApi / MapOpenApi built into ASP.NET Core (.NET 9+, current on .NET 10)
  • Generate with openapi-typescript, Kiota or NSwag in the build
  • Run in CI, fail on unexpected drift
  • Breaking-change check on the spec (oasdiff)
  • API versioning so old and new generated types coexist during migration
  • Compile error instead of runtime undefined

⏱ 30-second answer

On .NET 10, expose the OpenAPI document from ASP.NET Core with the built-in AddOpenApi / MapOpenApi (Microsoft.AspNetCore.OpenApi, available since .NET 9), then generate TypeScript in the build with openapi-typescript, Kiota or NSwag. Regenerate in CI and fail the build if the output changes unexpectedly, and run a breaking-change check (e.g. oasdiff) on the spec. Version the API (URL or header) and keep old contracts until clients move, so generated types for v1 and v2 can coexist. This turns a renamed field into a compile error instead of a production bug.

🔍 What the interviewer is checking

Checks they can stop contract drift between backend and frontend

↩ Usually asked after

More in Web Basics

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me