You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using dotnet 7 minapi, and I have fluent validation that does work on my endpoints, as well as working swagger docs.
However, the swagger docs do not pick up the rules from my validators.
For instance, the Create User API has this rule:
public class CreteUserValidator : AbstractValidator<CreateUserDTO>
{
public CreteUserValidator()
{
RuleFor(x => x.FirstName).NotEmpty().MaximumLength(100);
RuleFor(x => x.LastName).NotEmpty().MaximumLength(100);
RuleFor(x => x.Email).NotEmpty().MaximumLength(256).EmailAddress();
RuleFor(x => x.PhoneNumber).MaximumLength(100);
}
}
I am using dotnet 7 minapi, and I have fluent validation that does work on my endpoints, as well as working swagger docs.
However, the swagger docs do not pick up the rules from my validators.
For instance, the Create User API has this rule:
I see it working if I omit email:
But the information is not in Swagger:
The validators are added here:
srv.AddValidatorsFromAssemblyContaining<CreteUserValidator>(ServiceLifetime.Singleton);
And to Swagger here (later on):
The text was updated successfully, but these errors were encountered: