Skip to content

Commit

Permalink
Fix duplicate param strings in operationId
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Beauchamp committed Jan 5, 2016
1 parent 0fc7fd8 commit 7861490
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Swashbuckle.OData.Nuget/Swashbuckle.OData.NuGet.nuproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<LicenseUrl>https://github.com/rbeauchamp/Swashbuckle.OData/blob/master/License.txt</LicenseUrl>
<Copyright>Copyright 2015</Copyright>
<Tags>Swashbuckle Swagger SwaggerUi OData Documentation Discovery Help WebApi AspNet AspNetWebApi Docs WebHost IIS</Tags>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Swashbuckle.OData\Swashbuckle.OData.csproj" />
Expand Down
19 changes: 9 additions & 10 deletions Swashbuckle.OData/EnsureUniqueOperationIdsFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,17 @@ private static void AppendParameterNamesToOperationId(List<Operation> 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)}";
}
}

Expand Down
2 changes: 1 addition & 1 deletion Swashbuckle.OData/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("2.9.1")]
[assembly: AssemblyInformationalVersion("2.9.2")]
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.9.1.{build}
version: 2.9.2.{build}

before_build:
- cmd: nuget restore
Expand Down

0 comments on commit 7861490

Please sign in to comment.