28 lines
842 B
C#
28 lines
842 B
C#
using Microsoft.OpenApi.Models;
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CrasyStudio.Core.Common
|
|
{
|
|
public class AddRequiredHeaderParameter : IOperationFilter
|
|
{
|
|
public static string HeaderKey { get; set; } = "Authorization";
|
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
|
{
|
|
if (operation.Parameters == null)
|
|
operation.Parameters = new List<OpenApiParameter>();
|
|
operation.Parameters.Add(new OpenApiParameter
|
|
{
|
|
Name = HeaderKey,
|
|
In = ParameterLocation.Header,
|
|
Required = false,
|
|
AllowEmptyValue = true,
|
|
});
|
|
}
|
|
}
|
|
}
|