Class NamingStrategy
- Namespace
- TypedRest.CodeGeneration.TypeScript
- Assembly
- TypedRest.CodeGeneration.TypeScript.dll
The default INamingStrategy for TypeScript clients.
public class NamingStrategy : INamingStrategy
- Inheritance
-
objectNamingStrategy
- 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
serviceNamestringThe service name to use for the entry endpoint.
endpointDirectorystringThe directory the endpoint modules live in, relative to the output directory.
dtoDirectorystringThe directory the DTO modules live in, relative to the output directory.
untypedFallbackTsIdentifierThe 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
EndpointDirectory
The directory the endpoint modules live in, relative to the output directory.
protected readonly string EndpointDirectory
Field Value
ServiceName
The service name to use for the entry endpoint.
protected readonly string ServiceName
Field Value
UntypedFallback
The type to use for schemas that carry no usable type information.
protected readonly TsIdentifier UntypedFallback
Field Value
Methods
DtoType(string)
The name and module of a generated DTO type.
public virtual TsIdentifier DtoType(string key)
Parameters
keystring
Returns
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
Returns
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
Returns
NormalizeDirectory(string?)
Turns a namespace-style value such as MyCompany.MyService into a directory path.
protected static string NormalizeDirectory(string? value)
Parameters
valuestring
Returns
Property(string)
The name of the getter exposing a child endpoint.
public virtual string Property(string key)
Parameters
keystring
Returns
TypeFor(OpenApiSchema?)
The TypeScript type a schema maps to.
public virtual TsIdentifier TypeFor(OpenApiSchema? schema)
Parameters
schemaOpenApiSchema
Returns
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.