This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet("publish"), AllowAnonymous] | |
sealed class MyEndpoint : EndpointWithoutRequest | |
{ | |
public override async Task HandleAsync(CancellationToken c) | |
{ | |
var evnt = new MyEvent { Message = "hello!" }; | |
await PublishAsync(evnt); | |
await SendAsync("all good!"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bld = WebApplication.CreateBuilder(args); | |
bld.Services | |
.SwaggerDocument() | |
.AddFastEndpoints(); | |
var app = bld.Build(); | |
app.UseFastEndpoints( | |
c => | |
{ | |
c.Errors.UseProblemDetails(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Testcontainers.MongoDb; | |
public class Sut : AppFixture<Program> | |
{ | |
const string Database = "TestingDB"; | |
const string RootUsername = "root"; | |
const string RootPassword = "password"; | |
MongoDbContainer _container = null!; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseSwaggerGen( | |
s => | |
{ | |
//where to serve swagger.json files from | |
s.Path = "/PREFIX/swagger/{documentName}/swagger.json"; | |
//api endpoint server base path customization | |
s.PostProcess = (document, request) => | |
{ | |
document.Servers.Clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bld = WebApplication.CreateBuilder(args); | |
bld.Services | |
.AddFastEndpoints() | |
.SwaggerDocument(); | |
var app = bld.Build(); | |
app.UseFastEndpoints() | |
.UseSwaggerGen(); | |
app.Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
JsonPolymorphic(TypeDiscriminatorPropertyName = "_t"), | |
JsonDerivedType(typeof(MultiChoiceQuestionRequest), "mcq"), | |
JsonDerivedType(typeof(RatingQuestionRequest), "rq") | |
] | |
public class BaseQuestionRequest | |
{ | |
public int Id { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class MyRequest | |
{ | |
public int Id { get; set; } | |
} | |
public sealed class MyCommand : ICommand<int> | |
{ | |
public string Identity { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal sealed class AddCustomHeader : IOperationProcessor | |
{ | |
public bool Process(OperationProcessorContext context) | |
{ | |
var hdrParameter = new OpenApiParameter() | |
{ | |
Name = "x-custom", | |
Kind = OpenApiParameterKind.Header, | |
IsRequired = true, | |
Type = JsonObjectType.String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bld = WebApplication.CreateBuilder(); | |
bld.Services | |
.AddFastEndpoints() | |
.SwaggerDocument(o => | |
{ | |
o.DocumentSettings = s => | |
{ | |
s.DocumentName = "Initial Release"; | |
s.Version = "v0"; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseRequest | |
{ | |
public string? Id { get; init; } | |
} | |
public class BaseRequestValidator : Validator<BaseRequest> | |
{ | |
public BaseRequestValidator() | |
{ | |
RuleFor(x => x.Id) |
NewerOlder