I\'m searching for a way to automatically generate the TypesScript client code from a ASP.NET Core Web-Application (Currently using Visual Studio 2017RC and webpack).
Ar
Both NSwag and Swashbuckle/swagger-codegen are awesome.
Typewriter is another awesome option.
So, here is how I would take the decision:
Need to generate complete client side code with command line that you can add as a build or publish step go for Swagger Code Gen
Need to play with the generated Swagger Spec or Generated Code to add your customizations - go for NSwag
You can also take a look at autorest.typescript client code generator. It provides good interfaces for all the model definitions, accurately defines readonly properties and enums. It supports a bunch of custom extensions that can be useful to improve the user experience of the generated client. You can take a look at some generated sample clients.
Bonus: The generated typescript client works in node.js and also in the browser.
If you need to generate DTOs and API clients, then your options are
If you need DTOs only, then I'd look towards
More on these tools in this post - 6+ ways to marry C# with TypeScript.
You can add Swashbuckle to your ASP.NET Core webapp and then generate Swagger/OpenAPI spec.
With the Swagger/OpenAPI spec, you can then use Swagger Codegen to generate not only TypeScript API clients (Node, Angular, Angular2, Fetch), but also API clients in C#, Java, JS, Swift, etc as well as API documentation.
The easiest way to try Swagger Codegen is to use https://editor.swagger.io by importing your spec and then select the target API client/server you want to generate. (https://editor.swagger.io leverages https://generator.swagger.io to generate code and generator.swagger.io is powered by Swagger Codegen)
Swagger Codegen can also generate server stubs in C# Nancyfx or ASP.NET core so you may consider following the contract-first approach by writing the spec using https://editor.swagger.io and then generating both API clients and server stubs.
UPDATE: On May 2018, about 50 top contributors and template creators of Swagger Codegen decided to fork Swagger Codegen to maintain a community-driven version called OpenAPI Generator. Please refer to the Q&A for more information.
If your TypeScript clients are with jQuery or Angular 2+, an alternative ASP.NET Web API Client Generators may be more handy, less overhead than swagger toolchain during SDLC.
And it supports .NET Core in addition to .NET Framework and .NET Standard.
Another option is NSwag which can generate Swagger specs from your ASP.NET (Core) controllers and TypeScript clients from this Swagger spec (for Angular, AngularJS, Fetch, etc.). The integration is very simple and it supports many advanced features (inheritance, named enums, code extensions, etc).
http://NSwag.org
Using the NSwagStudio UI it is very simple to get started and then you can automate everything with NPM package (i.e. running the config file in the cmd line).
I'm one of the authors of the project.