Blog Logo
TAGS

# .NET 6 OpenAPI with TypeScript Client Generation

This is a sample application demonstrating .NET 6 with OpenAPI client code generation. While gRPC and GraphQL seem to be en vogue, REST with OpenAPI offers many of the same benefits in terms of contract and client generation. REST cant match subscriptions and streaming capabilities built into gRPC and GraphQL (not to mention the other features on those platforms), but its hard to beat the universal support for simple HTTP request/responses, ease of development, linear and predictable scaling of complexity, and maturity of REST. OpenAPI makes it more productive than ever to work with REST APIs and paired with managed WebSockets via Azure SignalR or Azure Web PubSub, building low-complexity, high performance web APIs is easier than ever. See for more discussion and my thoughts on gRPC, GraphQL, and REST: https://charliedigital.com/2021/11/25/net-6-web-apis-openapi-typescript-client-generation/ Google Cloud Run Version If you want to see how to deploy this into Google Cloud Run, check out the branch here: https://github.com/CharlieDigital/dotnet6-openapi/tree/dockerized Organization This project is set up as a mono-repo for simplicity. - root - api contains the .NET 6 web API - web contains the static web front-end in Svelte - references contains the generated client reference - web-vue contains the static web front-end in Vue DIY .NET Web API Start by creating the directory for the API: mkdir api cd api Then we set up the .NET 6 Web API project: dotnet new webapi This will create a default project using the .NET web APIs. You can start this project by running dotnet run Youll s