From 7861490c2259ea4d86807ce74cb5e0bb9297e5b0 Mon Sep 17 00:00:00 2001 From: Richard Beauchamp Date: Mon, 4 Jan 2016 19:33:54 -0800 Subject: [PATCH] Fix duplicate param strings in operationId --- .../Swashbuckle.OData.NuGet.nuproj | 2 +- .../EnsureUniqueOperationIdsFilter.cs | 19 +++++++++---------- Swashbuckle.OData/Properties/AssemblyInfo.cs | 2 +- appveyor.yml | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj b/Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj index 39eea03..de2d607 100644 --- a/Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj +++ b/Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj @@ -30,7 +30,7 @@ https://github.com/rbeauchamp/Swashbuckle.OData/blob/master/License.txt Copyright 2015 Swashbuckle Swagger SwaggerUi OData Documentation Discovery Help WebApi AspNet AspNetWebApi Docs WebHost IIS - 2.9.1 + 2.9.2 diff --git a/Swashbuckle.OData/EnsureUniqueOperationIdsFilter.cs b/Swashbuckle.OData/EnsureUniqueOperationIdsFilter.cs index 2312384..149749c 100644 --- a/Swashbuckle.OData/EnsureUniqueOperationIdsFilter.cs +++ b/Swashbuckle.OData/EnsureUniqueOperationIdsFilter.cs @@ -42,18 +42,17 @@ private static void AppendParameterNamesToOperationId(List allOperati { Contract.Requires(allOperations != null); - foreach (var operation in allOperations) + foreach (var operation in allOperations.Where(operation => !operation.operationId.Contains("By") + && operation.parameters != null + && operation.parameters.Any(p => p.@in == "path"))) { - if (operation.parameters != null && operation.parameters.Any(p => p.@in == "body" || p.@in == "path")) - { - // Select the capitalized parameter names - var parameters = operation.parameters - .Where(p => p.@in == "body" || p.@in == "path") - .Select(p => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(p.name)); + // Select the capitalized parameter names + var parameters = operation.parameters + .Where(p => p.@in == "path") + .Select(p => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(p.name)); - // Set the operation id to match the format "OperationByParam1AndParam2" - operation.operationId = $"{operation.operationId}By{string.Join("And", parameters)}"; - } + // Set the operation id to match the format "OperationByParam1AndParam2" + operation.operationId = $"{operation.operationId}By{string.Join("And", parameters)}"; } } diff --git a/Swashbuckle.OData/Properties/AssemblyInfo.cs b/Swashbuckle.OData/Properties/AssemblyInfo.cs index bfffef9..8844d15 100644 --- a/Swashbuckle.OData/Properties/AssemblyInfo.cs +++ b/Swashbuckle.OData/Properties/AssemblyInfo.cs @@ -37,4 +37,4 @@ [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("2.9.1")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("2.9.2")] \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 0fc82ea..9666290 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.9.1.{build} +version: 2.9.2.{build} before_build: - cmd: nuget restore