I'm using Swagger with ASP.Net Core 2.1 Web API project. Here's an example controller action method:
[HttpGet]
public string GetString([Required, MaxLength(20)] string name) =>
$"Hi there, {name}.";
And here's what I get in the Swagger documentation. As you can see, Swagger shows the Required
attribute, but not the MaxLength
one:
If I use Required
and MaxLength
attributes on a DTO class that's the argument of a POST action method, then Swagger shows them both:
How can I get Swagger to show MaxLength
(and other) validation attributes for query parameters?
Note: I have tried to replace the string name
argument with a class that has one string property called name
- Swagger produces exactly the same documentation.