Initial Commit ...
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Constants;
|
||||
using xCommons.Extensions;
|
||||
|
||||
namespace xCommons.Filters {
|
||||
/// <summary>
|
||||
/// RequireXPowered for NGSwag
|
||||
/// </summary>
|
||||
public partial class RequireXPoweredOperationFilter : IOperationFilter {
|
||||
private readonly XAppConfiguration config;
|
||||
|
||||
public RequireXPoweredOperationFilter (XAppConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void Apply (OpenApiOperation operation, OperationFilterContext context) {
|
||||
//
|
||||
if (operation.Parameters.IsNull ()) {
|
||||
operation.Parameters = new List<OpenApiParameter> ();
|
||||
}
|
||||
|
||||
//
|
||||
operation.Parameters.Add (new OpenApiParameter {
|
||||
In = ParameterLocation.Header,
|
||||
Name = XAuthorization.XPoweredBy,
|
||||
Description = "a Basic Authorization Filter",
|
||||
Required = false,
|
||||
Schema = new OpenApiSchema {
|
||||
Type = "String",
|
||||
Default = new OpenApiString (config.XPoweredValue)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user