Table of Contents

Class EndpointGenerator

Namespace
TypedRest.CodeGeneration.TypeScript.Endpoints
Assembly
TypedRest.CodeGeneration.TypeScript.dll

Generates TypeScript types for a tree of IEndpoints.

public class EndpointGenerator : IEndpointGenerator
Inheritance
object
EndpointGenerator
Implements

Constructors

EndpointGenerator(INamingStrategy, BuilderRegistry, TypeNameRegistry?)

Generates TypeScript types for a tree of IEndpoints.

public EndpointGenerator(INamingStrategy namingStrategy, BuilderRegistry builders, TypeNameRegistry? typeNames = null)

Parameters

namingStrategy INamingStrategy

Decides what the generated types and members are called.

builders BuilderRegistry

Decides what code is emitted for each kind of endpoint.

typeNames TypeNameRegistry

Keeps the generated names from colliding. Share this with a DTO generator writing to the same output directory.

Properties

Log

Collects messages about aspects of the document that TypeScript cannot express.

public IGenerationLog Log { get; set; }

Property Value

IGenerationLog

Modules

The modules of the TypedRest runtime library to import from.

public Modules Modules { get; set; }

Property Value

Modules

Naming

Decides what the generated types and members are called.

public INamingStrategy Naming { get; }

Property Value

INamingStrategy

Methods

EndpointType(string, IEndpoint)

Reserves a unique name for a generated endpoint class.

public TsIdentifier EndpointType(string key, IEndpoint endpoint)

Parameters

key string
endpoint IEndpoint

Returns

TsIdentifier

Generate(string, IEndpoint)

Generates the getter exposing an endpoint on its parent, plus any types needed for it.

public (TsGetter getter, IEnumerable<ITsType> types) Generate(string key, IEndpoint endpoint)

Parameters

key string
endpoint IEndpoint

Returns

(TsGetter getter, IEnumerable<ITsType> types)

Generate(EntryEndpoint)

Generates the types for an entire client.

public IEnumerable<ITsType> Generate(EntryEndpoint endpoint)

Parameters

endpoint EntryEndpoint

Returns

IEnumerable<ITsType>

PopParent()

Records that generation has left the children of the most recently pushed endpoint.

public void PopParent()

PushParent(string)

Records that generation has descended into the children of the endpoint with this key.

public void PushParent(string key)

Parameters

key string