Automatically generate TypeScript client code for ASP.NET Core controllers

前端 未结 6 877
醉话见心
醉话见心 2021-01-30 18:23

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

6条回答
  •  感情败类
    2021-01-30 18:38

    If you need to generate DTOs and API clients, then your options are

    • NSwag. The most popular tool for the job. But it generates everything in one file that makes it hard to maintain/debug.
    • Swagger Codegen or its fork with more features OpenAPI Generator. A Java-based option producing separate files, but with limited customisation.
    • AutoRest. A npm solution for packing up API clients in npm packages.
    • WebApiClientGen. A solution mentioned by the author below in this thread.
    • TypeWriter. VS extension, where you can craft your own implementation.

    If you need DTOs only, then I'd look towards

    • Reinforced.Typings
    • TypeGen

    More on these tools in this post - 6+ ways to marry C# with TypeScript.

提交回复
热议问题