Sqiddler.Core
0.0.3
See the version list below for details.
dotnet add package Sqiddler.Core --version 0.0.3
NuGet\Install-Package Sqiddler.Core -Version 0.0.3
<PackageReference Include="Sqiddler.Core" Version="0.0.3" />
<PackageVersion Include="Sqiddler.Core" Version="0.0.3" />
<PackageReference Include="Sqiddler.Core" />
paket add Sqiddler.Core --version 0.0.3
#r "nuget: Sqiddler.Core, 0.0.3"
#:package Sqiddler.Core@0.0.3
#addin nuget:?package=Sqiddler.Core&version=0.0.3
#tool nuget:?package=Sqiddler.Core&version=0.0.3
Sqiddler
Sqiddler applies Sqids to serialize integer ids to obfuscated strings. It uses ASP.NET Core's built-in JSON serialization and model binding features to automatically convert between integers and Sqid-strings. It also shuffles the alphabet by entity to make it harder to mix ids.
Getting Started
Install NuGet package Sqiddler
dotnet add package Sqiddler
Annotate your id properties with [JsonSqid<TEntity>] and id route parameters with SqidParam<TEntity> to serialize them to Sqid-strings.
public class Person
{
public int Id { get; set; }
}
public class PersonDto
{
// Id gets serialized to Sqid-string
[JsonSqid<Person>]
public int Id { get; set; }
public string OtherProperty { get; set; }
}
public class PersonEndpoints
{
public void Map(WebApplication app)
{
app.MapGet("person/{id}", GetPerson);
}
public static async Task<Ok<MyDto>> GetPerson(ISender sender, SqidParam<Person> id)
{
return Task.FromResult(new PersonDto()
{
Id = 42,
OtherProperty = "Hello, World!"
}
}
}
Configuration
Configure Sqids in Program.cs
var builder = WebApplication.CreateBuilder(args);
// configure SqidsOptions from appsettings.json
builder.Configuration.GetSection("Sqids").Bind(SqidsOptionsFactory.Default);
// optimize SqidsOptions.MinLength for TEntity
SqidsOptionsFactory.Configure<Person>(4); // enough for 100_000
var app = builder.Build();
app.Run();
Configure Sqids.SqidsOptions in appsettings.json
"Sqids": {
// generated from https://sqids.org/playground
"Alphabet": "kBZDsjNeIWrQUSqExvwgdcnyl05X2F7f3pYVO9MaRhtLoP8GbiuzCm1T6KAJH4"
}
Open API
Install NuGet package Sqiddler.OpenApi instead of Sqiddler
dotnet add package Sqiddler.OpenApi
Register Open API in Program.cs
var builder = WebApplication.CreateBuilder(args);
services.AddOpenApi(options =>
{
// reflect Sqid-string changes in Open API
options.AddSqids(options);
});
var app = builder.Build();
app.MapOpenApi();
app.Run();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Sqiddler.Core:
| Package | Downloads |
|---|---|
|
Sqiddler
Use Sqids in ASP.NET Core with Attributes |
GitHub repositories
This package is not used by any popular GitHub repositories.