Forked from rafalkasa/LowercaseDocumentFilter.cs
Last active
October 12, 2018 18:50
-
-
Save IOrlandoni/5fdb592384b697101e61bc6a209d43c2 to your computer and use it in GitHub Desktop.
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
using System.Collections.Generic; | |
using Swashbuckle.SwaggerGen.Generator; | |
using Swashbuckle.Swagger.Model; | |
namespace BoundedContext.Web.Swagger | |
{ | |
public class LowercaseDocumentFilter : IDocumentFilter | |
{ | |
public void Apply(SwaggerDocument swaggerDoc, DocumentFilterContext context) | |
{ | |
var paths = new Dictionary<string, PathItem>(swaggerDoc.Paths); | |
foreach (var path in paths) | |
{ | |
var lowercase_key = path.Key.ToLower(); | |
if (lowercase_key != path.Key) | |
{ | |
swaggerDoc.Paths.Add(lowercase_key, path.Value); | |
swaggerDoc.Paths.Remove(path.Key); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment