Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bld = WebApplication.CreateBuilder(args);
- bld.Services
- .SwaggerDocument()
- .AddFastEndpoints()
- .AddLocalization();
- var app = bld.Build();
- app.UseFastEndpoints()
- .UseSwaggerGen()
- .UseRequestLocalization();
- app.Run();
- public partial class Program;
- sealed class MyRequest
- {
- public int Id { get; set; }
- public sealed class MyValidator : Validator<MyRequest>
- {
- public MyValidator(IStringLocalizer<MyValidator> localizer)
- {
- RuleFor(r => r.Id).GreaterThan(0).WithMessage(r => localizer["InvalidId"].Value);
- }
- }
- }
- sealed class MyEndpoint : Endpoint<MyRequest>
- {
- public override void Configure()
- {
- Post("test");
- AllowAnonymous();
- }
- public override async Task HandleAsync(MyRequest r, CancellationToken c)
- {
- await SendAsync(r);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement