-
Notifications
You must be signed in to change notification settings - Fork 281
Alternative Validation implementation #163
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
Merged
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7316184
Init implementation for the Open API validation
xuzhg 0988b1b
add the whole visitor classes for validation
xuzhg 620b0f2
add the rules and modify the header copyright
xuzhg 31a3cd9
Add test cases for external docs and response
xuzhg 401072c
add a validation rule for the OAuthFlow object
xuzhg bd39460
modify to give more meaningful comments
xuzhg da5f90a
add the OpenApiRuleAttribute for each rule classes
xuzhg 4a6ca43
change to lazy loading for the validation visitors
xuzhg 2e7e2dd
Change the namespace for the Validation test files
xuzhg aebee6f
Add the test cases for ValidationRuleSet
xuzhg df86936
resolve the comments, typos and some test codes
xuzhg bc530c3
Validation using walker and single visitor class
darrelmiller b29d532
Change debug.assert to throw arugment null and use the resource from …
xuzhg 5eccf02
Merge branch 'sam/validation3' into dm/validation
darrelmiller 0188565
Remove visitor classes
darrelmiller 43ae516
Enhancements to walker
darrelmiller fc4c334
Removed unused test
darrelmiller 26561e3
Merge remote-tracking branch 'origin/master' into dm/validation
darrelmiller 2fd11fa
Updated Walker to use separate methods for each element
darrelmiller d6dba10
Updated walkers and added validate method
darrelmiller 9f7c7f6
Merge branch 'master' into dm/validation
darrelmiller 6c47d49
Merge branch 'master' into dm/validation
darrelmiller 0a4c3ee
Merge branch 'master' into dm/validation
darrelmiller 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
31 changes: 31 additions & 0 deletions
31
src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.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,31 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using Microsoft.OpenApi.Interfaces; | ||
| using Microsoft.OpenApi.Models; | ||
| using Microsoft.OpenApi.Services; | ||
| using Microsoft.OpenApi.Validations; | ||
|
|
||
| namespace Microsoft.OpenApi.Extensions | ||
| { | ||
| /// <summary> | ||
| /// Extension methods that apply across all OpenAPIElements | ||
| /// </summary> | ||
| public static class OpenApiElementExtensions | ||
| { | ||
| /// <summary> | ||
| /// Validate element and all child elements | ||
| /// </summary> | ||
| /// <typeparam name="T"></typeparam> | ||
| /// <param name="element"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<ValidationError> Validate(this IOpenApiElement element) { | ||
| var validator = new OpenApiValidator(); | ||
| var walker = new OpenApiWalker(validator); | ||
| walker.Walk(element); | ||
| return validator.Errors; | ||
| } | ||
| } | ||
| } | ||
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, for the customer/developer, he will check:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking errors.Any() should be sufficient because returning IEnumerable as null is just evil. I will add documentation to convey the fact that the function will never return null.