30 lines
858 B
C#
30 lines
858 B
C#
using xApi.Constants;
|
|
using Microsoft.OpenApi.Any;
|
|
using Microsoft.OpenApi.Models;
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
|
|
namespace xApi.Attributes
|
|
{
|
|
public class SwaggerDefaultValues : IOperationFilter
|
|
{
|
|
/// <summary>
|
|
/// Apply Default Values ...
|
|
/// </summary>
|
|
/// <param name="operation"></param>
|
|
/// <param name="context"></param>
|
|
public void Apply(
|
|
OpenApiOperation operation,
|
|
OperationFilterContext context
|
|
)
|
|
{
|
|
//
|
|
// Detect Version Parameter ...
|
|
var versionParam = operation.Parameters
|
|
.FirstOrDefault(p => p.Name == Params.ApiVersionParam);
|
|
if (versionParam is not null)
|
|
{
|
|
versionParam.Schema.Default = new OpenApiString("1.0");
|
|
}
|
|
}
|
|
}
|
|
} |