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
-
objectDtoEnumBuilder
- 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
keystringThe key identifying the schema.
schemaOpenApiSchemaThe schema to generate a type for.
namingINamingStrategyDecides what the generated type is called.
typeNamesTypeNameRegistryKeeps 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()