I finaly found my answer here Delegate 'RequestDelegate' does not take 2 arguments - ASP.NET Core 8 Minimal API
When TypedResults are used i must specify the possible retursn in the lambda like async Task<Results<Ok<InternalGenericEmail>, NotFound<string>>>
very important here to specify the type that takes eg return TypedResults.NotFound("hi") needs NotFound<string>
public void MapEndpoint(IEndpointRouteBuilder app) => app.MapGet("api/notifier/generic/check/{id}", async Task<Results<Ok<InternalGenericEmail>, NotFound<string>>> (string id, IEmailRepository emailRepository) =>
{
IEnumerable<InternalGenericEmail> a = await emailRepository.GetAllAsync();
InternalGenericEmail? result = a.FirstOrDefault(p => p.Id.ToString() == id);
if (result is not null)
{
return TypedResults.Ok(result);
}
return TypedResults.NotFound($"Die angegebne Id: {id} ist nciht vorhanden");
}
)
.AddFluentValidationAutoValidation()
.WithTags("Generic")
.WithName($"GenericEmail123")
.WithDescription("GenericEmailDesc")
.WithSummary("GenericEmailSum")
.Produces((int)HttpStatusCode.NoContent, null)
.ProducesValidationProblem()
;