Tech stack used : .NET 6.0, C# 9.0
SwaggerExampleAttr is lightweight .NET core library that allow developers to customize their request model examples in Swagger. this library would be focus on new feature to create more readable request model examples for your apis.
SwaggerExampleAttr is now available in NuGet extends your Swashbuckle.AspNetCore
library
install nuget library
Install-Package SwaggerExampleAttrLib -Version 0.1.23
add schema filter in SwaggerGen
services.AddSwaggerGen(c =>
{
c.SchemaFilter<ExampleSchemaFilter>();
...
}
if you want to use this library you should use Example
attribute above of your properties like:
public class TestModel{
[Example("Test")]
public string Address { get; set; }
[Example(12.2)]
public decimal Lat { get; set; }
[Example(1, 2, 3)]
public List<int> Ints { get; set; }
...
}
string
int
double
decimal
System.Collections.Generic
simple types like (List<int>
,List<string>
,IEnumrable<int>
)