In this Text, I want to talk about Swagger Example I developed in GitHub
as below URL:
SwaggerExampleAttr for .NET core
and this is Nuget library:
<PackageReference Include="SwaggerExampleAttrLib" Version="0.1.23" />
if you want to add customized examples for the rest API models to show in swagger UI, you can use this library.
Install Instructions:
1- first install Nuget library
Install-Package SwaggerExampleAttrLib -Version 0.1.23
2- add schema filter in SwaggerGen
services.AddSwaggerGen(c =>
{
c.SchemaFilter<ExampleSchemaFilter>();
...
}
Example
if you want to use this library you should use the 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; }
...
}
*Supported Types:
string
int
double
decimal
System.Collections.Generic simple types like (List<int>, List<string>,IEnumrable<int>)
Comments
Post a Comment