All Projects → greymind → WebApiToTypeScript

greymind / WebApiToTypeScript

Licence: MIT license
A tool for code generating TypeScript endpoints for your ASP.NET Web API controllers

Programming Languages

C#
18002 projects
typescript
32286 projects

Projects that are alternatives of or similar to WebApiToTypeScript

Toolkit
Collection of useful patterns
Stars: ✭ 137 (+426.92%)
Mutual labels:  code-generator, code-generation
regen
Easy C++ reflection and code generation
Stars: ✭ 29 (+11.54%)
Mutual labels:  code-generator, code-generation
Php Code Generator
PHP code generator library
Stars: ✭ 141 (+442.31%)
Mutual labels:  code-generator, code-generation
Mid
mid is a generic domain-specific language for generating code and documentation
Stars: ✭ 68 (+161.54%)
Mutual labels:  code-generator, code-generation
evon
Fast and versatile event dispatcher code generator for Golang
Stars: ✭ 15 (-42.31%)
Mutual labels:  code-generator, code-generation
Goreuse
Generic Code for Go
Stars: ✭ 93 (+257.69%)
Mutual labels:  code-generator, code-generation
Xcassetpacker
A command line tool for converting a folder of images into an .xcasset package for Xcode
Stars: ✭ 150 (+476.92%)
Mutual labels:  code-generator, code-generation
Laravel Code Generator
An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.
Stars: ✭ 485 (+1765.38%)
Mutual labels:  code-generator, code-generation
Evolutility Ui Jquery
Model-driven Web UI for CRUD using REST or localStorage.
Stars: ✭ 164 (+530.77%)
Mutual labels:  code-generator, code-generation
Jennifer
Jennifer is a code generator for Go
Stars: ✭ 2,257 (+8580.77%)
Mutual labels:  code-generator, code-generation
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (+88.46%)
Mutual labels:  code-generator, code-generation
ByteScout-SDK-SourceCode
ALL source code samples for ByteScout SDKs and Web API API products.
Stars: ✭ 24 (-7.69%)
Mutual labels:  asp-net, webapi
Dogen
Reference implementation of the MASD Code Generator.
Stars: ✭ 44 (+69.23%)
Mutual labels:  code-generator, code-generation
Geco
Simple code generator based on a console project, running on .Net core and using C# interpolated strings
Stars: ✭ 97 (+273.08%)
Mutual labels:  code-generator, code-generation
Colfer
binary serialization format
Stars: ✭ 597 (+2196.15%)
Mutual labels:  code-generator, code-generation
Dbcc
CAN DBC to C (and CSV, JSON and XML) compiler using the mpc parser combinator library
Stars: ✭ 142 (+446.15%)
Mutual labels:  code-generator, code-generation
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+15176.92%)
Mutual labels:  code-generator, code-generation
Codemaker
A idea-plugin for Java/Scala, support custom code template.
Stars: ✭ 440 (+1592.31%)
Mutual labels:  code-generator, code-generation
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (+484.62%)
Mutual labels:  code-generator, code-generation
codegenerator
Generate EF6 WebApi with an AngularJS font-end
Stars: ✭ 11 (-57.69%)
Mutual labels:  asp-net, webapi

Web API To TypeScript

Join the chat at https://gitter.im/WebApiToTypeScript/Lobby

A tool for code generating TypeScript endpoints for your ASP.NET Web API controllers and their actions. No more need for dumb repositories!

  • Generates typed endpoints with required and optional parameters for GET, PUT, POST and DELETE verbs
    • Generates cached endpoints for GET verb actions
  • Generates enumerations and interfaces for DTOs used in all controller actions
    • Generates enum descriptions based on the [Description] attribute
  • Generates Angular service to expose typed call() function to fetch response from server
  • Generates typed views to use on front-end
  • Generates resources files based on .resx files

Examples

Take a look at the generated files and sample test files here

Getting the tool from NuGet

https://www.nuget.org/packages/WebApiToTypeScript/

Install-Package WebApiToTypeScript

Using as standalone tool

Just run the executable with the config file as the argument

watts.exe "Path/To/Config/File.json"

Using as MSBuild Target

I haven't tested this in a while, so if you find any inconsistencies with working directory and such, feel free to file an issue or better yet, submit a pull request!

Ensure the DLL is part of the build process, so you have access to it. Easiest way is to reference it in your project.

<UsingTask TaskName="WebApiToTypeScript.WebApiToTypeScript" AssemblyFile="$(ProjectDir)..\WebApiToTypeScript\bin\Debug\WebApiToTypeScript.dll" />
<Target Name="AfterBuild">
    <WebApiToTypeScript ConfigFilePath="$(ProjectDir)Watts.config.json" />
</Target>

T4 Template

If you wish to integrate the executable as part of your workflow from within Visual Studio, you may consider wiring it up to a T4 template. Here is a sample.

Protip

You can build just the C# parts of the solution by adding a condition to the TypeScript target in the csproj file. This way you can ensure that before you run WebApiToTypeScript, you have a hassle-free build of the backend code.

  <PropertyGroup>
    <SkipTypeScript Condition="'$(SkipTypeScript)'==''">False</SkipTypeScript>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets') AND '$(SkipTypeScript)'=='False'" />
Path\To\msbuild.exe /t:build /p:SkipTypeScript=True Path\To\Project.csproj

Using Angular Endpoints Service

You'll need to register the Endpoints service to your app and inject it as is typical in Angular

angular.module('framework').service('AngularEndpointsService', Framework.Endpoints.AngularEndpointsService);

Config

{
  "WebApiModuleFileName": "string",
  "WebApiModuleFileNames": [ "string" ]
  
  "GenerateEndpointsReturnTypes": "boolean",
  "GenerateEndpoints": "boolean",  
  "EndpointsOutputDirectory": "string",
  "EndpointsSupportCaching": "boolean",
  "EndpointsFileName": "string",
  "EndpointsNamespace": "string",
  
  "GenerateMobileEndpoints": "boolean",
  "MobileEndpointsOutputDirectory": "string",
  "MobileEndpointsFileName": "string",
  "MobileEndpointsNamespace": "string",
  "MobileEndpointAttributeName": "string",

  "GenerateService": "boolean",
  "ServiceOutputDirectory": "string",
  "ServiceFileName": "string",
  "ServiceNamespace": "string",
  "ServicesName": "string",

  "GenerateEnums": "boolean",
  "GenerateEnumDescriptions": "boolean",
  "EnumsOutputDirectory": "string",
  "EnumsFileName": "string",
  "EnumsNamespace": "string",

  "GenerateInterfaces": "boolean",
  "InterfacesOutputDirectory": "string",
  "InterfacesFileName": "string",
  "InterfacesNamespace": "string",
  "InterfaceMembersInCamelCase": "boolean",
  "InterfaceCamelCaseCustomAttribute": "string",
  "InterfaceMatches": [
    "Match": "string",
    "ExcludeMatch": "string",
    "BaseTypeName": "string"
  ],

  "GenerateViews": "boolean",
  "ViewConfigs": [
    {
      "SourceDirectory": "string",
      "Namespace": "string",
      "OutputFilename": "string",
      "Prefix": "string",
      "UrlEncodePath": "boolean"
    }
  ],
  "ViewsPattern": "string",
  "ViewsOutputDirectory": "string",
  "UseViewsGroupingNamespace": "boolean",
  "ViewsIgnoredExtensions": [
      "string"
  ]

  "ScanOtherModules": "boolean",
  "WriteNamespaceAsModule": "boolean",

  "TypeMappings": [
    {
      "WebApiTypeName": "string",
      "TypeScriptTypeName": "string",
      "AutoInitialize": "boolean",
      "TreatAsAttribute": "boolean"
      "TreatAsConstraint": "boolean",
      "Match": "string"
    }
  ]
}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].