-
Notifications
You must be signed in to change notification settings - Fork 279
[472] Add path signature unique validator #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
baywet
merged 10 commits into
microsoft:vnext
from
fabich:feature/add-path-signature-unique-validation
Oct 24, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e6535f7
added validation & renabled OpenApiPaths validators
7fcef5b
Merge branch 'vnext' into feature/add-path-signature-unique-validation
darrelmiller 6bf85c5
Update src/Microsoft.OpenApi/Properties/SRResource.resx
darrelmiller 6c0b9fa
Merge branch 'vnext' into feature/add-path-signature-unique-validation
darrelmiller 3ce6830
Merge branch 'vnext' into feature/add-path-signature-unique-validation
e74cae9
Merge branch 'vnext' into feature/add-path-signature-unique-validation
baywet 9429da4
- cleans up duplicated method
baywet 6bda890
- makes regex static for performance
baywet da035fa
- fixes string comparison
baywet 5140baf
- fixes unit tests
baywet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/Microsoft.OpenApi.Tests/Validations/OpenApiPathsValidationTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using System.Linq; | ||
| using FluentAssertions; | ||
| using Microsoft.OpenApi.Extensions; | ||
| using Microsoft.OpenApi.Models; | ||
| using Microsoft.OpenApi.Properties; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.OpenApi.Validations.Tests | ||
| { | ||
| public class OpenApiPathsValidationTests | ||
| { | ||
| [Fact] | ||
| public void ValidatePathsMustBeginWithSlash() | ||
| { | ||
| // Arrange | ||
| var error = string.Format(SRResource.Validation_PathItemMustBeginWithSlash, "pets/{petId}"); | ||
| var paths = new OpenApiPaths | ||
| { | ||
| {"pets/{petId}",new OpenApiPathItem() } | ||
| }; | ||
|
|
||
| // Act | ||
| var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet()); | ||
|
|
||
| // Assert | ||
| errors.Should().NotBeEmpty(); | ||
| errors.Select(e => e.Message).Should().BeEquivalentTo(error); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ValidatePathsAreUnique() | ||
| { | ||
| // Arrange | ||
| var error = string.Format(SRResource.Validation_PathSignatureMustBeUnique, "/pets/{}"); | ||
| var paths = new OpenApiPaths | ||
| { | ||
| {"/pets/{petId}",new OpenApiPathItem() }, | ||
| {"/pets/{name}",new OpenApiPathItem() } | ||
| }; | ||
|
|
||
| // Act | ||
| var errors = paths.Validate(ValidationRuleSet.GetDefaultRuleSet()); | ||
|
|
||
| // Assert | ||
| errors.Should().NotBeEmpty(); | ||
| errors.Select(e => e.Message).Should().BeEquivalentTo(error); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.