Home / Companies / LogRocket / Blog / Post Details
Content Deep Dive

Generate TypeScript and C# clients with NSwag based on an API

Blog post from LogRocket

Post Details
Company
Date Published
Author
John Reilly
Word Count
2,330
Language
-
Hacker News Points
-
Summary

The article provides a comprehensive guide on using NSwag to automate API client generation, highlighting its utility in reducing manual coding work. It explains how NSwag, an open-source tool that combines functionalities of Swashbuckle and AutoRest, can generate OpenAPI specifications from ASP.NET Web API controllers and create client code from these specifications. The guide covers the process of creating a .NET API with a Swagger endpoint and a React app, using NSwagStudio for code generation, and creating a .NET console application for more controlled API generation. The article also details setting up scripts to streamline API client generation and demonstrates how to consume the generated clients in a React app. Additionally, it touches on the utility of NSwag schemas in defining API endpoints and data types, emphasizing the efficiency and error reduction benefits of using NSwag for API code generation.