Table of Contents

Class NamingStrategy

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

The default INamingStrategy for TypeScript clients.

public class NamingStrategy : INamingStrategy
Inheritance
object
NamingStrategy
Implements

Constructors

NamingStrategy(string, string, string, TsIdentifier?)

The default INamingStrategy for TypeScript clients.

public NamingStrategy(string serviceName, string endpointDirectory, string dtoDirectory, TsIdentifier? untypedFallback = null)

Parameters

serviceName string

The service name to use for the entry endpoint.

endpointDirectory string

The directory the endpoint modules live in, relative to the output directory.

dtoDirectory string

The directory the DTO modules live in, relative to the output directory.

untypedFallback TsIdentifier

The type to use for schemas that carry no usable type information.

Fields

DtoDirectory

The directory the DTO modules live in, relative to the output directory.

protected readonly string DtoDirectory

Field Value

string

EndpointDirectory

The directory the endpoint modules live in, relative to the output directory.

protected readonly string EndpointDirectory

Field Value

string

ServiceName

The service name to use for the entry endpoint.

protected readonly string ServiceName

Field Value

string

UntypedFallback

The type to use for schemas that carry no usable type information.

protected readonly TsIdentifier UntypedFallback

Field Value

TsIdentifier

Methods

DtoType(string)

The name and module of a generated DTO type.

public virtual TsIdentifier DtoType(string key)

Parameters

key string

Returns

TsIdentifier

EndpointType(string, IEndpoint, string?)

The name and module of a generated endpoint class.

public virtual TsIdentifier EndpointType(string key, IEndpoint endpoint, string? prefix = null)

Parameters

key string
endpoint IEndpoint
prefix string

Returns

TsIdentifier

Generated(string, string)

Builds an identifier for a type generated into directory, one type per file.

protected static TsIdentifier Generated(string directory, string name)

Parameters

directory string
name string

Returns

TsIdentifier

NormalizeDirectory(string?)

Turns a namespace-style value such as MyCompany.MyService into a directory path.

protected static string NormalizeDirectory(string? value)

Parameters

value string

Returns

string

Property(string)

The name of the getter exposing a child endpoint.

public virtual string Property(string key)

Parameters

key string

Returns

string

TypeFor(OpenApiSchema?)

The TypeScript type a schema maps to.

public virtual TsIdentifier TypeFor(OpenApiSchema? schema)

Parameters

schema OpenApiSchema

Returns

TsIdentifier

Remarks

Every string format maps to string: TypedRest for TypeScript deserializes with JSON.parse() and a cast, so there is nothing that could turn a date-time into a Date.