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
Hey everyone! We are using Fluent Validation for all of our API request models but those that contain maximum items validation on arrays in query parameters do not get the maxItems property set in the swagger schema.
Those arrays that are in the body and have the same validation applied do get reflected in the schema.
For example, for this request model:
public class GetTenantMembersModel : PaginatedQueryModel
{
[FromQuery(Name = "user_id")]
[JsonProperty("user_id")]
public List<Guid> UserIds { get; set; } = new();
...
}
We have the following validator
public class GetTenantMembersModelValidator : AbstractValidator<GetTenantMembersModel>
{
public GetTenantMembersModelValidator()
{
RuleFor(x => x.UserIds)
.MaximumItems(50)
.WithMessage(ErrorMessages.HasMaximumItemsOfMaxItems)
.ForPropertyName("user_id");
...
}
}
And it results in the following swagger schema:
As you can see, the maxItems property is not set, but for body parameters it is set using the exact same validation.
If I go ahead and use the [MaxLength(50)] ComponentModel annotation, it is added to the schema:
Is this a known issue? Is there any workaround? Thanks in advance!
The text was updated successfully, but these errors were encountered:
Hey everyone! We are using Fluent Validation for all of our API request models but those that contain maximum items validation on arrays in query parameters do not get the
maxItems
property set in the swagger schema.Those arrays that are in the body and have the same validation applied do get reflected in the schema.
For example, for this request model:
We have the following validator
And it results in the following swagger schema:
As you can see, the
maxItems
property is not set, but for body parameters it is set using the exact same validation.If I go ahead and use the
[MaxLength(50)]
ComponentModel annotation, it is added to the schema:Is this a known issue? Is there any workaround? Thanks in advance!
The text was updated successfully, but these errors were encountered: