I've recently asked about C# classes to T4 viewmodels, but this is different so I separated it out into a second question
I'd like to automate the generate of a client library in typescript that includes endpoints for every web api method that is adorned with the HttpGet, Post, Put, Delete, Patch attributes.
This would generate the jQuery ajax calls to interface with the web api calls.
Anyone seen anything like this? I would LOVE to save some time having to hack together a T4 script.
Thanks!
t4 template is used to scaffold a DbContext class for the database, and the EntityType. t4 template is used to scaffold entity type classes for each table and view in the database.
TT stands for - Visual Studio Text Template is a software development tool created by the Microsoft. Further explanation - TT file contains text block and control logic used for generating new files. To write the Text Template file we can use either - Visual C# or Visual Basic Code.
Design-time T4 text templates let you generate program code and other files in your Visual Studio project. Typically, you write the templates so that they vary the code that they generate according to data from a model. A model is a file or database that contains key information about your application's requirements.
It looks like this guy used T4 to generate a TypeScript proxy to his Web API service. http://galador.net/codeblog/post/2013/11/12/Client-Side-Web-Application-primer.aspx
However, if your only client will be from the browser, you may want to consider using SignalR instead with this T4 template. https://gist.github.com/robfe/4583549
There are also a few libraries that generate TypeScript definition files from CLR types:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With