Last active
May 15, 2020 19:21
-
-
Save yann510/76a2fc61605811f4e95720c2d405ca00 to your computer and use it in GitHub Desktop.
Lowercase document filters except for parameters [swashbuckle]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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