TSCodegen.WebAPI 1.2.8

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package TSCodegen.WebAPI --version 1.2.8                
NuGet\Install-Package TSCodegen.WebAPI -Version 1.2.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TSCodegen.WebAPI" Version="1.2.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TSCodegen.WebAPI --version 1.2.8                
#r "nuget: TSCodegen.WebAPI, 1.2.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TSCodegen.WebAPI as a Cake Addin
#addin nuget:?package=TSCodegen.WebAPI&version=1.2.8

// Install TSCodegen.WebAPI as a Cake Tool
#tool nuget:?package=TSCodegen.WebAPI&version=1.2.8                

TSCodegen.WebAPI

Library for C# ASP.NET controllers conversion to TypeScript axios services. Available as NuGet package.

Based on TSCodegen library.

Compatible with .NET Standard 2.0 and higher!

How it works

Codegen will examine calling assembly for all classes with the ApiController attribute. Then for each matching class Codegen will iterate over all methods with any attribute that starts with "Http" prefix (e.g. HttpGet).

Codegen will also handle methods with first argument having attribute FromBody for GET, DELETE, HEAD, OPTIONS methods and FromForm for POST, PUT, PATCH methods, though such methods must contain only one argument.

Prerequisites

Install axios and qs (querystring) to your frontend project.

npm i axios
npm i qs

Usage

Add to the start of the Main function:

#if DEBUG
Codegen.Run(new Codegen.Config
{
    OutputPath = @"\ui\api",
    AxiosImportPath = @"axios",
    Indentation = 4,
    IgnoreControllers = new()
    {
        typeof(BaseController),
    },
    ForbiddenNamespaces = new()
    {
        "Project.Database.Core.Entities",
    }
});
#endif

Codegen.Config properties

OutputPath

Output path that is relative to the .sln file.

AxiosImportPath

Path for import expression, e.g. with axios value will emit import axios from "axios";. Can be used to specify custom file with axios instance default export.

Indentation

Space indentation size for generated code.

IgnoreControllers

List of controllers that will be omited.

ForbiddenNamespaces

List of namespaces that entities of will throw exception.

DateTime conversion

C# DateTime class will be converted to Date | DateTimeString. You need to declare DateTimeString in any of your *.d.ts files. Example:

declare type DateString = "YYYY-MM-DD";
declare type TimeString = "HH:mm:ss";
declare type DateTimeString = `${DateString}T${TimeString}`;

Generated files

Library will generate file structure:

api\
├ myController\
│  ├ myMethod1.ts
│  ├ myMethod2.ts
│  ├ types.ts
│  └ index.ts
└ index.ts

Where api\index.ts will contain default export with all APIs as objects with functions (e.g. api.myController.myMethod).

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated