refactor: distribute configurations by classes
This commit is contained in:
16
Endpoint/Configuration/Swagger/SwaggerExampleFilter.cs
Normal file
16
Endpoint/Configuration/Swagger/SwaggerExampleFilter.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration.Swagger;
|
||||
|
||||
public class SwaggerExampleFilter : ISchemaFilter
|
||||
{
|
||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
||||
{
|
||||
var att = context.ParameterInfo?.GetCustomAttribute<SwaggerDefaultAttribute>();
|
||||
if (att != null)
|
||||
schema.Example = new Microsoft.OpenApi.Any.OpenApiString(att.Value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user