SSE only dto's not generated through ss-util

Hi Demis,
we have a couple of dto’s only used within SSE. If we generate the dto’s through ss-util we don’t get them generated because they arent implemented in any service nor have the [Route] Attribute since there is no route.

What is the recommendet way to have those Dto’s also included?

Cheers
tobi

The easiest way is to create a “stub” Service containing all the DTOs you want included in the generated DTOs:

class StubService
{
   public MyDto IncludeMyDto { get; set; }
}

public object Any(StubService request) => request;

Otherwise you can export them with:

appHost.GetPlugin<NativeTypesFeature>().
    MetadataTypesConfig.ExportTypes.Add(typeof(MyDto));
1 Like

cool thank you. 2nd approach much cleaner and doesn’t feel like a workaround.

Hey @mythz,

Is the NativeTypesFeature workaround still supposed to work?

I have this DTO:

public class SyncWalletNotification
{
    public long Id { get; set; }
}

And I register it with:

AppHost.GetPlugin<NativeTypesFeature>().
    MetadataTypesConfig.ExportTypes.Add(typeof(SyncWalletNotification));

But I do not get any output for SyncWalletNotification when I re-generate using typescript-ref.

What am I missing here?

@joao it was only for overriding the default visibility and to export classes that were excluded (i.e. built-in System or ServiceStack Types). You can use a stub Service class to include DTOs which you want included.

Using [ExcludeMetadata] will hide this service from being disclosed in any of the metadata services, e.g:

[ExcludeMetadata]
public class ExportTypes
{
    SyncWalletNotification { get; set; } 
}

class ExportTypesService : Service
{
    public object Any(ExportTypes request) => request;
}
1 Like

I tried this attribute, but it also seems to disable generation of the export types in the TypeScript generated output.