[Bug]: MinLength attribute on a dictionary property generates invalid minLength constraint
bug
### Describe the bug
I have a model class with a dictionary property. At request time, I want to require the dictionary be non-empty. MVC supports doing that via the `[MinLength]` attribute:
```csharp
[Required]
[MinLength(1)]
public IReadOnlyDictionary<string, string?> Values { get; }
```
However, Swashbuckle then applies `"minLength": 1` to the schema definition instead of `"minProperties": 1`.
### Expected behavior
The generated OpenAPI document includes `"minProperties": 1` for the `Values` schema.
### Actual behavior
The generated OpenAPI document includes `"minLength": 1` for the `Values` schema.
### Steps to reproduce
```csharp
public class MyModel
{
[Required]
[MinLength(1)]
public IReadOnlyDictionary<string, string?> Values { get; init; }
}
[ApiController]
public class MyController
{
[HttpPost]
public void MyAction([FromBody] MyModel model)
{
}
}
```
### Exception(s) (if any)
_No response_
### Swashbuckle.AspNetCore version
10.1.7
### .NET Version
10.0.202
### Anything else?
This was found by running the `vacuum` linter against the generated OpenAPI document.
0 条评论