Skip to content

Instantly share code, notes, and snippets.

@yann510
Last active May 15, 2020 19:21
Show Gist options
  • Save yann510/76a2fc61605811f4e95720c2d405ca00 to your computer and use it in GitHub Desktop.
Save yann510/76a2fc61605811f4e95720c2d405ca00 to your computer and use it in GitHub Desktop.
Lowercase document filters except for parameters [swashbuckle]
public class LowercaseDocumentFilter : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, DocumentFilterContext context)
{
swaggerDoc.Paths = swaggerDoc.Paths.ToDictionary(entry => LowercaseEverythingButParameters(entry.Key), entry => entry.Value);
}
private static string LowercaseEverythingButParameters(string key)
{
return string.Join('/', key.Split('/').Select(x => x.Contains("{") ? x : x.ToLower()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment