Skip to content

Commit e036750

Browse files
committed
- fixes a bug where paths with multiple parameters would be considered conflicting
Signed-off-by: Vincent Biret <[email protected]>
1 parent 1465fff commit e036750

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Microsoft.OpenApi/Validations/Rules/OpenApiPathsRules.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static class OpenApiPathsRules
3636
}
3737
});
3838

39-
private static readonly Regex regexPath = new Regex("\\{([^/]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
39+
private static readonly Regex regexPath = new Regex("\\{([^/}]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
4040
/// <summary>
4141
/// A relative path to an individual endpoint. The field name MUST begin with a slash.
4242
/// </summary>

test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,22 @@ public void ValidatePathsAreUnique()
4545
errors.Should().NotBeEmpty();
4646
errors.Select(e => e.Message).Should().BeEquivalentTo(error);
4747
}
48+
[Fact]
49+
public void ValidatePathsAreUniqueDoesNotConsiderMultiParametersAsIdentical()
50+
{
51+
// Arrange
52+
var paths = new OpenApiPaths
53+
{
54+
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height},fittingMode='{fittingMode}')",new OpenApiPathItem() },
55+
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() },
56+
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width})", new OpenApiPathItem() },
57+
};
58+
59+
// Act
60+
var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet());
61+
62+
// Assert
63+
errors.Should().BeEmpty();
64+
}
4865
}
4966
}

0 commit comments

Comments
 (0)