-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility moduleWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Get to latest 7.4.0 (or preview) version of Powershell
Create schema.json file as follows:
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://lol.com/lol.json",
"type": "object",
"properties": {
"lol": {
"type": "integer"
},
"muth": {
"type":"boolean"
}
},
"required": [
"lol","muth"
],
"additionalProperties": false
}Create a sample JSON file as follows:
{
"lol": 4,
"muth": false
}Expected behavior
PS> Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json
TrueActual behavior
PS C:\Temp\toto> Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json
Test-Json: Cannot parse the JSON.
FalseError details
Exception :
Type : System.Exception
Message : Cannot parse the JSON.
InnerException :
Type : Json.Schema.JsonSchemaException
TargetSite :
Name : DetermineSpecVersion
DeclaringType : Json.Schema.JsonSchema
MemberType : Method
Module : JsonSchema.Net.dll
Message : Custom meta-schema `$schema` keywords must eventually resolve to a meta-schema for a supported
specification version.
Source : JsonSchema.Net
HResult : -2146233088
StackTrace :
at Json.Schema.JsonSchema.DetermineSpecVersion(JsonSchema schema, SchemaRegistry registry, SpecVersion desiredDraft)
at Json.Schema.JsonSchema.Evaluate(JsonNode root, EvaluationOptions options)
at Microsoft.PowerShell.Commands.TestJsonCommand.ProcessRecord()
HResult : -2146233088
TargetObject : {
"lol": 4,
"muth": false
} CategoryInfo : InvalidData: ({ "lol": 4, "muth": false } :String) [Test-Json], Exception FullyQualifiedErrorId : InvalidJson,Microsoft.PowerShell.Commands.TestJsonCommand InvocationInfo : MyCommand : Test-Json ScriptLineNumber : 1 OffsetInLine : 31 HistoryId : 11 Line : Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json Statement : Test-Json -SchemaFile .\schema.json PositionMessage : At line:1 char:31 + Get-Content .\the.json -Raw | Test-Json -SchemaFile .\schema.json + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ InvocationName : Test-Json CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1 PipelineIterationInfo :Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 7.4.0-rc.1
PSEdition Core
GitCommitId 7.4.0-rc.1
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
FormindAPE, nejadb, orpjones, thomas-aure and o-l-a-v
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility moduleWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group