Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class OpenApiPathsRules
}
});

private static readonly Regex regexPath = new Regex("\\{([^/]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
private static readonly Regex regexPath = new Regex("\\{([^/}]+)\\}", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
/// <summary>
/// A relative path to an individual endpoint. The field name MUST begin with a slash.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,38 @@ public void ValidatePathsAreUnique()
errors.Should().NotBeEmpty();
errors.Select(e => e.Message).Should().BeEquivalentTo(error);
}
[Fact]
public void ValidatePathsAreUniqueDoesNotConsiderMultiParametersAsIdentical()
{
// Arrange
var paths = new OpenApiPaths
{
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height},fittingMode='{fittingMode}')",new OpenApiPathItem() },
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() },
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width})", new OpenApiPathItem() },
};

// Act
var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet());

// Assert
errors.Should().BeEmpty();
}
[Fact]
public void ValidatePathsAreUniqueConsidersMultiParametersAsIdentical()
{
// Arrange
var paths = new OpenApiPaths
{
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={height})",new OpenApiPathItem() },
{"/drives/{drive-id}/items/{driveItem-id}/workbook/worksheets/{workbookWorksheet-id}/charts/{workbookChart-id}/image(width={width},height={size})",new OpenApiPathItem() },
};

// Act
var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet());

// Assert
errors.Should().NotBeEmpty();
}
}
}