Table of Contents

Class DtoEnumBuilder

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

Builds a TypeScript literal union type alias for a schema with an enum.

public class DtoEnumBuilder : DtoBuilder
Inheritance
object
DtoEnumBuilder
Inherited Members

Remarks

A TypeScript enum would be the closer analogue of the C# output, but a string enum refuses assignment of a bare string literal - which is exactly what JSON.parse() produces. Unions accept the literals directly and are fully erased at runtime.

Constructors

DtoEnumBuilder(string, OpenApiSchema, INamingStrategy, TypeNameRegistry?)

Builds a TypeScript literal union type alias for a schema with an enum.

public DtoEnumBuilder(string key, OpenApiSchema schema, INamingStrategy naming, TypeNameRegistry? typeNames = null)

Parameters

key string

The key identifying the schema.

schema OpenApiSchema

The schema to generate a type for.

naming INamingStrategy

Decides what the generated type is called.

typeNames TypeNameRegistry

Keeps the names of types generated for inline schemas from colliding with other generated types.

Remarks

A TypeScript enum would be the closer analogue of the C# output, but a string enum refuses assignment of a bare string literal - which is exactly what JSON.parse() produces. Unions accept the literals directly and are fully erased at runtime.

Methods

BuildTypeInner()

Builds the type for Schema, without the parts common to all kinds of DTO.

protected override ITsType BuildTypeInner()

Returns

ITsType