Skip to content

Commit a9a9572

Browse files
authored
Merge pull request #1504 from microsoft/bugfix/conflicting-path
bugfix/conflicting path
2 parents 1465fff + 670b259 commit a9a9572

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,38 @@ 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+
}
65+
[Fact]
66+
public void ValidatePathsAreUniqueConsidersMultiParametersAsIdentical()
67+
{
68+
// Arrange
69+
var paths = new OpenApiPaths
70+
{
71+
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() },
72+
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={size})",new OpenApiPathItem() },
73+
};
74+
75+
// Act
76+
var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet());
77+
78+
// Assert
79+
errors.Should().NotBeEmpty();
80+
}
4881
}
4982
}

0 commit comments

Comments
 (0)