Skip to content

Instantly share code, notes, and snippets.

@spaasis
spaasis / SwaggerFeatureGateFilter.cs
Last active March 25, 2025 03:06
Swashbuckle IDocumentFilter for hiding paths based on IFeatureManagement and FeatureGateAttribute
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.Mvc;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
/// <summary>Checks the current Feature Management configuration and removes all paths with disabled features</summary>
public class SwaggerFeatureGateFilter : IDocumentFilter {
private readonly IFeatureManager _featureManager;
@spaasis
spaasis / AuditableEntity.cs
Last active April 1, 2020 07:20
EF Core audit logging
using System;
using System.Collections.Generic;
namespace Infra {
public class AuditableEntity {
public string CreatedBy { get; set; } = null!; //user name, could be id etc.
public DateTime Created { get; set; }
public string? LastModifiedBy { get; set; } //user name, could be id etc.