-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add parameter SchemaFile to Test-Json cmdlet
#11934
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
adityapatwardhan
merged 28 commits into
PowerShell:master
from
beatcracker:test-json_schema-from-file
Jun 2, 2020
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3a6f1fd
Add SchemaPath parameter
beatcracker 3d5e834
Remove unnecessary usings
beatcracker 576866b
Add tests
beatcracker 0b27f48
Add newline at the EOF
beatcracker f07bec0
Use named argument for 'ResolveFilePath'
beatcracker 8b4f4d5
Remove "ReportFileOpenFailure" usage
beatcracker 1e991d2
Handle AggregateException from async methods
beatcracker 5a183bc
Add tests for JSON schema file open failure
beatcracker 77a24af
Replace "An JSON" with "A JSON"
beatcracker c86c47d
Replace "A JSON" with "A JSON string"
beatcracker 5b5ef80
Replace "SchemaPath" with "SchemaFile"
beatcracker 11a2d4f
Rename inner exception variable: "i" -> "ie"
beatcracker 0899edb
Convert delegates to private method
beatcracker 7b064f7
Remove top-level declaration of the "resolvedpath"
beatcracker 34f8473
Sort usings
beatcracker f002d31
Remove class name in parameter definition
beatcracker de7f360
Simplify comment
beatcracker 046dc27
Simplify commment
beatcracker 486bdaf
Remove comments
beatcracker 3f17982
Add resource string for "JsonSchemaFileOpenFailure"
beatcracker 28e8c27
Change resource string wording to include filename
beatcracker 8116c23
Add file path to the "JsonSchemaFileOpenFailure" error message
beatcracker 80a2671
Add schema path as a targetObject to the ErrorRecord
beatcracker 6082522
Fix Codefactor warnings
beatcracker 735683c
Fix Codefactor warnings
beatcracker a724c7c
Fix Codefactor warnings
beatcracker 80e0006
Fix SA1623 for CodeFactor
beatcracker 8429e2f
Add HelpUri
beatcracker 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
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
8 changes: 8 additions & 0 deletions
8
test/powershell/Modules/Microsoft.PowerShell.Utility/assets/invalid_schema_definitions.json
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,8 @@ | ||
| { | ||
| "definitions": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "hobbies" | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
test/powershell/Modules/Microsoft.PowerShell.Utility/assets/invalid_schema_reference.json
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,12 @@ | ||
| { | ||
| "description": "A person", | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "$ref": "invalid_schema_definitions.json#/definitions/name" | ||
| }, | ||
| "hobbies": { | ||
| "$ref": "invalid_schema_definitions.json#/definitions/hobbies" | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json
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,13 @@ | ||
| { | ||
| "definitions": { | ||
| "name": { | ||
| "type": "string" | ||
| }, | ||
| "hobbies": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_reference.json
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,12 @@ | ||
| { | ||
| "description": "A person", | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "$ref": "valid_schema_definitions.json#/definitions/name" | ||
| }, | ||
| "hobbies": { | ||
| "$ref": "valid_schema_definitions.json#/definitions/hobbies" | ||
| } | ||
| } | ||
| } |
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.
I think we could avoid re-throw and write an error here.
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.
As discussed below, if schema is invalid (or not found) shouldn't we treat it as an invalid input and throw terminating error?
E.g.:
Test-Connectionwill throw if it can't resolve host,Test-ModuleManifestthrows if path is invalid or not pointing to thepsd1file..