Search code examples
c#swaggerfluentvalidationdocumentation-generation

Auto Generate Documentation based on FluentValidator written


is there a way to generate documentation based on FluentValidator that has been written for request? I need information like: the field is NotEmpty(), MaximumLength(40), etc.

Please direct me

Thank you in advance!

EDIT: I mean to get validations that a certain filed have. So if validator looks like this:

RuleFor(x => x.Email)
            .NotEmpty()
            .EmailAddress()
            .MaximumLength(30);
        RuleFor(x => x.Password)
            .NotEmpty()
            .MinimumLength(ValidationConstants.MinLength)
            .MaximumLength(ValidationConstants.MaxLengthPassword)

I want to get that 1st field has to be Not Empty with Maximum Length 30 and so on


Solution

  • No such feature. FluentValidator only generates error messages for the validations.

    If relevant, the error message can be used in the response body of the request, along with a 400 Bad Request status code.