Specified type not generating on DTO when added to ExportTypes

Viewed 22

I have an enum that I want generated in my TS DTO file but it is not directly referenced on a response object.

public enum UserGridUserType
{
    Admin,
    User,
    Etc
}

I tried:

var nativeTypes = this.GetPlugin<NativeTypesFeature>();

nativeTypes.MetadataTypesConfig.ExportTypes.Add(typeof(UserGridUserType));

But it does not generate. How do I get it to generate on typescript DTO?

1 Answers

Add ServiceStack Reference only generates types referenced from selected Services. So you’d need to create a Dummy Request DTO containing all the types you want generated that aren’t already referenced, e.g:

public class GenTypes : IReturn<GenTypes> {
    public UserGridUserTypes UserGridUserTypes { get; set; }
}

class MyServices : IService {
    public object Any(GenTypes request) => request;
}
Related