v5.9.2 Patch Release
This patch release resolves a JWT signature verification issue, if you’re using JWT please upgrade to v5.9.2 when possible.
If you’re unable to upgrade to the latest version, older versions should ensure a minimum length signature with a custom ValidateToken
, e.g:
new JwtAuthProvider(...) {
ValidateToken = (js,req) =>
req.GetJwtToken().LastRightPart('.').FromBase64UrlSafe().Length >= 32
}
Group Services by Tag
We’ve extended the Tag support in Open API to group related Services by annotating Request DTOs with the [Tag]
attribute, e.g. you can use this to tag which Services are used by different platforms:
[Tag("web")]
public class WebApi : IReturn<MyResponse> {}
[Tag("mobile")]
public class MobileApi : IReturn<MyResponse> {}
[Tag("web"),Tag("mobile")]
public class WebAndMobileApi : IReturn<MyResponse> {}
Where they’ll now appear as a tab to additionally filter APIs in metadata pages:
Support for tags was also added to Add ServiceStack Reference where it can be used in the IncludeTypes DTO customization option where tags can be specified using 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.*
AutoQuery AutoGen Customizations
AutoGen is our exciting feature to Instantly Servicify existing Systems by automatically generating the AutoQuery & Crud APIs and Data Models for all tables in the configured RDBMS’s.
We’ve extended the existing Customizable Code Generation filters to allow customization of the DataModel Name, the user-defined Route Path they’re hosted at & the name of individual AutoQuery APIs for each operation.
E.g. If you had an existing table name called applications the default convention based names would be:
- Data Model: Applications
- APIs: CreateApplications, PatchApplications, QueryApplications, etc
- Route: /applications, /applications/{Id}
You can change each of these default conventions with the new GenerateOperationsFilter
, e.g:
Plugins.Add(new AutoQueryFeature {
MaxLimit = 1000,
GenerateCrudServices = new GenerateCrudServices {
AutoRegister = true,
GenerateOperationsFilter = ctx => {
if (ctx.TableName == "applications")
{
ctx.DataModelName = "Application";
ctx.RoutePathBase = "/apps";
ctx.OperationNames = new Dictionary<string, string> {
[AutoCrudOperation.Create] = "CreateApp",
[AutoCrudOperation.Query] = "SearchApps",
};
}
}
}
});
Would result in:
- Data Model: Application
- APIs: CreateApp, PatchApplication, SearchApps
- Route: /apps, /apps/{Id}
Dart Improvements
Added ClientFactory
to enable source-compatible Service Client instance creation where both Dart VM / Flutter JsonServiceClient
and Dart Web JsonWebClient
IServiceClient’s can be created with:
var client = ClientFactory.create();
Where you can use the same initClient
lambda to configure all ServiceClients instances, e.g. you could configure them to use the same JWT Token with:
ClientConfig.initClient = (client) => client.bearerToken = "...";
Ignore AutoCrud Properties
If you’re creating Custom AutoQuery CRUD Services you can ignore & skip the validation of properties that don’t map to the Request’s Data Model individually annotating properties with the [AutoIgnore]
Attribute, e.g:
public class CustomRockstarService
: ICreateDb<Rockstar>, IReturn<RockstarWithIdResponse>
{
public int Id { get; set; }
public int? Age { get; set; }
[AutoIgnore]
public CustomInfo CustomInfo { get;set; }
}
Or you can ignore validation for all properties with the same name by registering it on AutoQuery.IncludeCrudProperties
, e.g:
AutoQuery.IncludeCrudProperties.Add(nameof(CustomInfo));
OrderBy Random
OrderBy
includes special support for returning results in Random order using Random
, e.g:
/rockstars?OrderBy=Random
Using Service Client:
client.Get(new QueryRockstars { OrderBy = "Random" });
Support for Naked Lists
Fixed an issue with Release Builds in Flutter to support Naked Lists, e.g:
class GetFoo : OrderedRequest, IReturn<List<FooDto>>
Unfortunately the Release Builds on Device returns a different runtimeType.toString()
to Dart VM, to workaround this issue the JsonConverters.TypeFactories
are populated with additional concrete Type mappings for all generic types.
Other fixes/features in this release include:
- Rewritten JsonHttpClient to use async/await - to resolve issues in Xamarin platforms
- Enable AllowSyncIO to sync deserializers
- CacheClient WithPrefix auto excludes keys with existing prefixes
- Restore using user-defined Routes in Admin UI
- Resolve displaying meta properties in new /auth page
A number of enhancements was also added to our Windows Desktop Apps support which we’ll announce soon.