You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi/Extensions/SwaggerOperationFilter.cs

29 lines
910 B

using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Authorization;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Ombi
{
public class SwaggerOperationFilter : IOperationFilter
{
public string Name { get; private set; }
public SwaggerOperationFilter()
{
Name = "Authorization";
}
public void Apply(Operation operation, OperationFilterContext context)
{
if (operation.Parameters == null)
operation.Parameters = new List<IParameter>();
var tokenAuthDict = new Dictionary<string, IEnumerable<string>> {{Name, new List<string>()}};
operation.Security = new IDictionary<string, IEnumerable<string>>[] { tokenAuthDict };
}
}
}