MetaDataType filtering

I know there are some options available to include or exclude types towards client code generation.
IncludeTypes only works for namespaces (or namespace wildcards) or exact types, ExcludeTypes only works by specifying the exact type name.
I actually need another level of filtering; I have one servicestack service deployed, and I have like 4 vue websites working with it, a Xamarin app, a Flutter(web) app. Of course it is always a subset of the services I need in these various applications. These services are not an exact mapping with namespaces for example.
I was thinking of an attribute you can place on the types like you can with the ExcludeMetadataAttribute but with a TAG.
IncludeMetadataAttribute with a list of TAGS you can set.
In the various client dtos configurations you could add the IncludeTags. That way you can optionally mark services with [IncludeMetadata("App1", "Mobile")].
Is this something you would consider adding, or willing to accept a PR if we could agree on the naming and feature?

Yeah could have a Tag type filtering as we already have a [Tag] attribute. Will look into it.

I’ve added support for Tags where you can annotate your Request DTOs to group them by a user-defined tag where you can also annotate Request DTOs with multiple [Tag] Attributes, e.g:

public class WebApi : IReturn<MyResponse> {}

public class MobileApi : IReturn<MyResponse> {}

public class WebAndMobileApi : IReturn<MyResponse> {}

The tags are also visible the metadata pages where you can additionally filter APIs under the tag they belong to:

It’s also supported in the IncludeTypes DTO customization option where you can specify tags in braces in the format {tag} or {tag1,tag2,tag3}, e.g:

/* Options:
IncludeTypes: {web,mobile}

Or individually:

/* Options:
IncludeTypes: {web},{mobile}

It works similar to Dependent Type References wildcard syntax where it expands all Request DTOs with the tag to include all its reference types so including a {web} tag would be equivalent to including all Request DTOs & reference types with that reference, e.g:

/* Options:
IncludeTypes: WebApi.*,WebAndMobileApi.*

I’m only supporting IncludingTypes on Request DTOs, i.e. as basically a way to group operations, where you can also query them from HostContext.Metadata.GetOperationsByTags() API. It’s not supported on individual DTOs or for excluding types.

This change is available from the latest v5.9.1 that’s now available on MyGet.

Wow! Thanks! That’s great.

1 Like